This module deploys AWS lambda functions that, after user initiates a conversation via Facebook messenger, uses the cognicity-bot-core module to fetch a report card from a CogniCity server and sends it to the user.
npm install
- Create Facebook app and page and get
APPSECRET
andPAGEACCESSTOKEN
as explained here. Hold off on completing Step 2 (Set up webhooks) in the guide unitl you complete the steps below - Deploy functions to AWS Lambda
- Set AWS Lambda environment variables that are listed in
config.js
, including FacebookAPPSECRET
andPAGEACCESSTOKEN
(see Configuration below). - Connect your functions to an AWS API gateway instance
- Subscribe your Facebook app to your Facebook page as explained here
- Register the AWS API Gateway URL with the Facebook app and subscribe to messenger events
- Send a text to your Facebook messenger bot to test if it is up and running!
Adjust .travis.yml to deploy via Travis as need.
Save a copy of sample.env as .env in local directory with appropriate credentials as defined in sample.env
Configuration variables are as follows:
API_GW_WEBHOOK
- the API GW address for the webhook endpoint (e.g. https://chatbots.riskmap.us/facebook/webhook). Currently this is unused by functions and is for referenceCARDS_API
- the endpoint to get new report cardsCARDS_DECK
- which cards decks are deployed on this instance. Subset of 'flood,prep'.CARDS_API_KEY
- the api key for the cards endpointCARDS_URL
- the URL for card resources as sent to the clientDEFAULT_INSTANCE_REGION_CODE
- in case a report is submitted outside a city, what city should the code fallback onDEFAULT_LANGUAGE
- default language for user interactionsFACEBOOK_APP_SECRET
- the Facebook application secret used by Facebook to sign messenger eventsFACEBOOK_ENDPOINT
- the Facebook API endpoint to send messagesFACEBOOK_PAGE_ACCESS_TOKEN
- a token generated by Facebook for page accessFACEBOOK_VALIDATION_TOKEN
- a random string that is a shared secret between Facebook and this software (e.g. a UUID)MAP_URL
- the risk map URLNETWORK_NAME
- 'facebook' for CogniCity loggingPREP_URL
- the prep card url (e.g. https://cards-dev.riskmap.in/prep/)
- To subscribe to the get started button, make sure the app is subscrived to
messaging_postbacks
as set in the Messenger -> Settings -> Webhooks -> Edit events config page in developers.facebook.com - To setup messenger buttons and greeting see the scripts in the
commands
folder (scripts require a .env file with Facebook app secrets to populate config.js)
run npm run test
- Update CHANGELOG.md
- Commit all changes
- Tag release in Git and create release in GitHub
- On the dev branch increment the version number, new development takes place in the new version