diff --git a/lib/facebook/setup.js b/lib/facebook/setup.js index 1df238a..5210495 100644 --- a/lib/facebook/setup.js +++ b/lib/facebook/setup.js @@ -47,7 +47,7 @@ module.exports = function fbSetup(api, bot, logError, optionalParser, optionalRe stageName: lambdaDetails.alias }).then(data => { if (options['configure-fb-bot']) { - let token, pageAccessToken; + let token, pageAccessToken, pageID; return Promise.resolve().then(() => { if (data.variables && data.variables.facebookVerifyToken) @@ -69,13 +69,14 @@ module.exports = function fbSetup(api, bot, logError, optionalParser, optionalRe console.log(`\n\n${color.green}Facebook Messenger setup${color.reset}\n`); console.log(`\nFollowing info is required for the setup, for more info check the documentation.\n`); console.log(`\nYour webhook URL is: ${color.cyan}${lambdaDetails.apiUrl}/facebook${color.reset}\n`); - console.log(`Your verify token is: ${color.cyan}${token}${color.reset}\n`); + console.log('\nYour verify token is: ${color.cyan}${token}${color.reset}\n`); - return prompt(['Facebook page access token', 'Facebook App Secret']); + return prompt(['Facebook page access token', 'Facebook App Secret', 'Facebook Page ID']); }) .then(results => { console.log('\n'); pageAccessToken = results['Facebook page access token']; + pageID = results['Facebook Page ID']; const deployment = { restApiId: lambdaDetails.apiId, stageName: lambdaDetails.alias, @@ -84,13 +85,12 @@ module.exports = function fbSetup(api, bot, logError, optionalParser, optionalRe facebookAppSecret: results['Facebook App Secret'] } }; - if (!data.variables || (!data.variables.facebookAppSecret && !results['Facebook App Secret'])) console.log(`\n${color.yellow}Deprecation warning:${color.reset} your bot is not using facebook validation. Please re-run with --configure-fb-bot to set it. This will become mandatory in the next major version. See https://github.com/claudiajs/claudia-bot-builder/blob/master/docs/API.md#message-verification for more information.\n`); return utils.apiGatewayPromise.createDeploymentPromise(deployment); }) - .then(() => rp.post(`https://graph.facebook.com/v2.6/me/subscribed_apps?access_token=${pageAccessToken}`)); + .then(() => rp.post(`https://graph.facebook.com/v3.2/${pageID}/subscribed_apps?subscribed_fields=['messages']&access_token=${pageAccessToken}`)); } }); })