
Prerequisites
- A Meta developer app that will serve as the primary platform for managing connection between Messenger and Botpress, including the configuration of webhooks and access tokens.
- A Facebook page that you own or has the developer role, this is needed to use the Messenger API.
- A Botpress Cloud account and a Botpress Bot
Setting up the Messenger integration in Botpress
- Go to the Integration Hub in Botpress Cloud (if you don’t have the integration installed yet).
- Find and open the Messenger integration then click on the “Install to Bot” button, now go back to your bot settings.
- Enabled: Whether Botpress will communicate with Messenger
- Webhook URL: The URL for receiving data in Botpress
- App ID: The ID of your Meta App
- App Secret: The secret of your Meta App
- Verify Token: The token used to verify the webhook requests
- Page ID: The ID of your Facebook page
- Access Token: The access token used to send messages to the Messenger API
Setting up Messenger
Create a Facebook Page
If you don’t already have a Facebook page, you’ll need to create one. To link your bot to a preexisting page, you must have an administrator or developer role.Messenger API version
Botpress can only interact with the version 15.0 or higher of the Messenger API. It isn’t the default version in the app settings so it must be changed.- Go to your Meta app start page
- In the left sidebar, expand the Settings menu and select Advanced
- In the Upgrade API version section, select v15.0 or higher as the API version
- Click on Save changes
Add Messenger Product
Messenger isn’t added by default in your Meta app, so it must be added manually- In the left sidebar, click on Add Product
- In the Facebook Messenger section click Set Up
App ID and Secret
- In the left sidebar, expand the Settings menu and select Basic. Here you can find the App ID and App Secret
- Click on the Show button in the App Secret text box. Copy the App ID and App Secret to your channel configuration
Verify Token
The verify token is used by Facebook to verify that you are the real owner of the provided webhook You can generate any random alphanumerical string for this configuration. Paste it in your Verify Token channel configurationPage ID and Access Token
- In the left sidebar, expand the Messenger menu and select Messenger API Settings
- In the Access Tokens section, click Add or remove Pages and add your Facebook page
- Copy the number under your page name and paste it in your Page ID channel configuration
- Click on Generate token. Copy this token and paste it in the Access Token channel configuration
Save Configuration
Channel configuration is completed—you can now click Save. It’s important to save your configuration in Botpress before updating the webhook in the Meta app settings; otherwise, Meta will be unable to validate the webhook URL.Webhook Configuration
To receive messages from Messenger in your Botpress bot, you will need to set up a webhook.- Go to your Meta app.
- In the left sidebar, expand the Messenger menu and select Messenger API Settings
- In the Webhooks section, click Add Callback URL
- Copy paste the Webhook URL provided in the integration configuration page in Botpress.
- Copy and paste the Verify Token that you generated earlier in the integration configuration page in Botpress.
- Click on Verify and save. Make sure your channel configuration was saved before doing this step; otherwise, the webhook validation will fail
- Click on Add Subscriptions, then select
messages
andmessaging_postbacks
. Then click Save.
NoteIf the bot doesn’t answer to some people, that’s probably because your app hasn’t been reviewed by Meta yet (see this section). But don’t worry, this isn’t mandatory to test your bot.