diff --git a/.gitignore b/.gitignore index d2510c8..05cbf9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ bin/ node_modules/ .nyc_output -.env -.env-dev +.env* diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8d18862 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# CHANGELOG + +### v0.0.3 + +Deployment version: +- working bot with buttons +- support for null areas +- improved thanks message \ No newline at end of file diff --git a/README.md b/README.md index 5570c47..df4261c 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,5 @@ Adjust .travis.yml to deploy via Travis as need. ### Configuration Save a copy of sample.env as .env in local directory with appropriate credentials as defined in sample.env +### Facebook Configuration +- 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 \ No newline at end of file diff --git a/package.json b/package.json index 629c0de..8d9a48b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cognicity-reports-facebook", - "version": "1.0.0", + "version": "0.0.3", "description": "Facebook Messenger bot running on AWS lambda", "main": "index.js", "scripts": { diff --git a/src/config.js b/src/config.js index 8842a0a..d178136 100644 --- a/src/config.js +++ b/src/config.js @@ -5,6 +5,8 @@ export default { CARDS_API: process.env.CARDS_API || 'https://data.riskmap.us/cards/', CARDS_API_KEY: process.env.CARDS_API_KEY, CARDS_URL: process.env.CARDS_URL || 'https://cards.riskmap.us/flood/', + DEFAULT_INSTANCE_REGION_CODE: process.env.DEFAULT_INSTANCE_REGION_CODE || + 'brw', DEFAULT_LANGUAGE: process.env.DEFAULT_LANGUAGE || 'id', FACEBOOK_ENDPOINT: process.env.FACEBOOK_ENDPOINT || 'https://graph.facebook.com/v2.6/me/messages', FACEBOOK_PAGE_ACCESS_TOKEN: process.env.FACEBOOK_PAGE_ACCESS_TOKEN, diff --git a/src/lib/facebook.js b/src/lib/facebook.js index 13cbd3d..0f3101a 100644 --- a/src/lib/facebook.js +++ b/src/lib/facebook.js @@ -148,6 +148,10 @@ export default class Facebook { **/ sendThanks(body) { return new Promise((resolve, reject) => { + if (body.instanceRegionCode === 'null') { + // catch reports outside the reporting area and reply a default + body.instanceRegionCode = this.config.DEFAULT_INSTANCE_REGION_CODE; + } Promise.all([this.bot.thanks(body), this.bot.card(body)]) .then((values) => { console.log(values);