Here’s a blog on how you can create an Amazon Lex bot with the Facebook messenger platform. Take a look at the steps:
1.Publish the Bot
a. In the Amazon Lex console, choose one of the bots you created.
b. Verify that the console shows the $LATEST as the bot version next to the bot’s name.
c. Choose Publish.
d. On the Publish botname wizard, specify the alias BETA, and then choose Publish.
e. Verify that the Amazon Lex console shows the new version next to the bot’s name.
2. Create a Facebook Application
On the Facebook developer portal, create a Facebook application and a Facebook page. For instructions, refer to this Quick Start documentation on the Facebook Messenger platform documentation. Jot down the following:
- The App Secret for the Facebook App
- The Page Access Token for the Facebook page
3. Integrate Facebook Messenger with the Amazon Lex Bot
- To integrate Facebook Messenger with your bot
- Sign in to the AWS Management Console and open the Amazon Lex console at https://console.aws.amazon.com/lex/.
- Choose your Amazon Lex bot.
- Go to Channels.
- Select the category Facebook under Chatbots. The console will display the Facebook integration page.
- On the Facebook integration page, do the following:
- Type the following name: BotFacebookAssociation.
- For KMS key, choose aws/lex .
- For Alias, choose the bot alias.
- For Verify token, type a token. This can be any string that you choose (for example, ExampleToken). This token can be used later in the Facebook developer portal when you set up the webhook.
- For Page access token, type the token that you obtained from Facebook in Step 2.
- For App secret key, type the key that you obtained from Facebook in Step 2.
- Choose Activate.
- The console creates the bot channel association and returns a callback URL. Write down this URL.
2. On the Facebook developer portal, choose your app.
3. Choose the Messenger product, and select Setup webhooks in the Webhooks section of the page.
4. For instructions, refer to the Quick Start document on the Facebook Messenger platform.
5. On the webhook page of the subscription wizard, do the following:
- For Callback URL, type the callback URL provided in the Amazon Lex console earlier in the procedure.
- For Verify Token, type the same token that you used in Amazon Lex.
- Choose Subscription Fields (messages, messaging_postbacks, and messaging_optins).
- Verify and Save. This initiates a handshake between Facebook and Amazon Lex.
6. Enable Webhooks integration. Select the page that you created, and then subscribe.Note: If you update or recreate a webhook, unsubscribe and then resubscribe to the page.
4. Take your bot live for everyoneTo allow your bot to send and receive messages, we will be needing a special permission from facebook, “pages_messaging."
Follow the official facebook document to achieve the same.
And that's how you create a chatbot with Facebook Messenger. Let me know how it goes for you, or if you would have done anything differently. Would love to hear new tricks on doing this.