.then(() => { if (options['configure-telegram-bot']) { return prompt(['Telegram Access Token']) .then(results => { const deployment = { restApiId: lambdaDetails.apiId, stageName: lambdaDetails.alias, variables: { telegramAccessToken: results['Telegram Access Token'] } }; return utils.apiGatewayPromise.createDeploymentPromise(deployment) .then(() => { let options = { method: 'POST', host: 'api.telegram.org', path: `/bot${deployment.variables.telegramAccessToken}/setWebhook`, port: 443, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ url: `${lambdaDetails.apiUrl}/telegram` }) }; return rp(options); }); }); } })
return utils.Promise.resolve().then(() => { if (options['configure-slack-slash-command']) { console.log(`\nYour Slack redirect URL is ${lambdaDetails.apiUrl}/slack/landing\n`); console.log(`\nYour Slack slash command Request URL is ${lambdaDetails.apiUrl}/slack/slash-command\n`); return prompt(['Slack Client ID', 'Slack Client Secret', 'Slack token', 'Home page URL']) .then(results => { const deployment = { restApiId: lambdaDetails.apiId, stageName: lambdaDetails.alias, variables: { slackClientId: results['Slack Client ID'], slackClientSecret: results['Slack Client Secret'], slackToken: results['Slack token'], slackHomePageUrl: results['Home page URL'], slackRedirectUrl: `${lambdaDetails.apiUrl}/slack/landing` } }; console.log(` `); return utils.apiGatewayPromise.createDeploymentPromise(deployment); }); } })
.then(() => { if (options['configure-viber-bot']) { console.log(`\n\n${color.green}Viber setup${color.reset}\n`); console.log(`\nFollowing info is required for the setup, for more info check the documentation.\n`); console.log(`\nYour Viber bot Request URL (POST only) is ${color.cyan}${lambdaDetails.apiUrl}/viber${color.reset}\n`); return prompt(['Viber Access Token']) .then(results => { const deployment = { restApiId: lambdaDetails.apiId, stageName: lambdaDetails.alias, variables: { viberAccessToken: results['Viber Access Token'] } }; return utils.apiGatewayPromise.createDeploymentPromise(deployment) .then(() => { let body = JSON.stringify({ auth_token: deployment.variables.viberAccessToken, url: `${lambdaDetails.apiUrl}/viber`, event_types: ['delivered', 'seen'] }); let options = { headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body, 'utf8') }, body: body }; return rp.post(`https://chatapi.viber.com/pa/set_webhook`, options); }); }); } })
.then(() => { // Do not delete empty console.logs and closing brackets in new lines // They are used as a new line separators console.log(`\nYour webhook URL is: ${lambdaDetails.apiUrl}/facebook\n`); console.log(`Your verify token is: ${token}\n`); return prompt(['Facebook access token']); })
return utils.Promise.resolve().then(() => { if (options['configure-skype-bot']) return prompt(['Skype App ID', 'Skype Private key']) .then(results => { const deployment = { restApiId: lambdaDetails.apiId, stageName: lambdaDetails.alias, variables: { skypeAppId: results['Skype App ID'], skypePrivateKey: results['Skype Private key'] } }; return utils.apiGatewayPromise.createDeploymentPromise(deployment); }); })
.then(() => { if (options['configure-groupme-bot']) { console.log(`\n\n${color.green}GroupMe setup${color.reset}\n`); console.log(`\nFollowing info is required for the setup, for more info check the documentation.\n`); console.log(`\nYour GroupMe bot Request URL (POST only) is ${color.cyan}${lambdaDetails.apiUrl}/groupme${color.reset}\n`); return prompt(['GroupMe Bot Id']) .then(results => { const deployment = { restApiId: lambdaDetails.apiId, stageName: lambdaDetails.alias, variables: { GROUPME_BOT_ID: results['GroupMe Bot Id'] } }; return utils.apiGatewayPromise.createDeploymentPromise(deployment); }); } })