- Git Clone (use SSH)
- Go to develop branch
cd functions
npm install -g firebase-tools
npm install
- run
firebase login --no-localhost
then login with your betterSG email - run
npm run build:watch
on one shell for typescript to build and work with emulator's hot reload - run
npm run serve
on another shell - you should now be able to hit the url at http://127.0.0.1:5001/checkmate-373101/asia-southeast1/xxxxx successfully
- Now can work on your individual functions in the /functions/definitions folder
- Uncomment the exports when ready to test with the local emulator!
- Rmb to use https://ngrok.com/ (can install vs code extension) to expose localhost as an internet URL, in case you want to run locally but test with actual Whatsapp and Telegram. Note...might need to have premium Ngrok for this to work with whatsapp.
- Put all keys and access tokens in the .env file and make sure its gitignored!
- Always refer to https://www.notion.so/better/Technical-Documentation-6ddc93791fdb43ff974adf7b3a7b6b3b and follow the DB schema. If you'd like to make changes to the schema, feel free! But we should let each other know on the Telegram chat, before making the change to the notion, so everyone is on the same page! It's super important to follow the schema, because that's the core of the system.
- Test locally first using the emulator and ngrok. Once the functions are ready, we will deploy the whole setup to the production firestore.
- Do add comments if needed, and try and write code that's easily understandable
- Feel free to do things differently from what I've laid out (for example, you can tweak the schema), so long it makes sense! But do let us know if you are making schema changes.
- If there's anything you're unsure or stuck on, just ask in the chat :) better to unblock early than to bang the wall!
- Firebase Console - https://console.firebase.google.com/, login with your bettersg email. Go here to manage the product resources and to change the production DB (later on, for a start we can just use the emulator)
- Adding subcollections - https://stackoverflow.com/questions/47514419/how-to-add-subcollection-to-a-document-in-firebase-cloud-firestore
- Getting started with firestore and firebase (basically I've adapted that for this repo) https://firebase.google.com/docs/functions/get-started
- WhatsApp send message API documentation - https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-messages
- WhatsApp webhook object documentation - https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components
- Telegram Bot API documentation - https://core.telegram.org/bots/api