npm i @botpress/channel-messenger
npm start. Since you don't have configuration an error will be displayed to console which is fine. Once it's displayed bot will create default configuration which you'll need to edit after stopping the bot.
- You need to create Facebook App
1)2) Click on Messenger `Set Up` 3. Get all required fields from `config/channel-messenger.json` [config template](https://github.com/botpress/botpress/blob/master/packages/channels/botpress-channel-messenger/config.json)
1)2) 3) 4)
In you facebook-app configuration at https://developers.facebook.com/ set webhook (an url should be something like
https://[bot-hostname]/api/botpress-messenger/webhook) and chose next option.. (webhook template
You need to send review request to FB. Do following:
- Go to https://developers.facebook.com -> Select your App ->
Submit Items for Approval->
Start a Submission-> pick up:
manage_pages-> Resolve all
Additional Information Required
Settings-> Go to section
App Review for Messenger-> Select all fields -> Resolve all
Additional Information Required
- Go to
Basic-> Need resolve all
Currently Ineligible for Submission
Explaining config keys
"displayGetStarted" - exclude/include interaction with Get Started.
"greetingMessage" - set default messege.
Default: "Default greeting message"
"enableAllProfileFields" - If you need to know user timezone, gender, locale set
true and send you app to review.
"persistentMenu" - added menu to your messenger. See more
"targetAudience" - decied who will can/can't use your chat.
"openToSome"- chat is available for people from
"closeToSome"- chat isn't available for people from
"closeToAll"- chat unavailable for all
"autoResponseOption" - used for send automaticaly something (depend on used value) to user when he/she click on
It has three variant of value
"autoResponseText"- send text to user. Text takes from
"noResponse"- auto response off
- Display Get Started
- Greeting message
- Persistent menu
- Automatically mark as read
- Composer input disabled
- Trusted domains
- Automatic profile lookup
- Save users in DB
- Webhook security check
You can listen to incoming event easily with Botpress by using
hear function. You only need to listen to specific Messenger event to be able to react to user's actions.
In fact, this module preprocesses almost all types of message (message, attachment, postback, quick_reply, delivery, read, optin, referrals...) and send them to incoming middlewares. When you build a bot or a module, you can access to all information about incoming messages that have been send to middlewares.
You can acces to all user's profile information by using this module. A cache have been implemented to fetch all information about users and this information is sent to middlewares.
id: profileidplatform: 'facebook'gender: profilegendertimezone: profiletimezonelocale: profilelocalepicture_url: profileprofile_picfirst_name: profilefirst_namelast_name: profilelast_name
Note: All new users are automatically saved by this module in Botpress built-in database (
event is sent to middlewares for each incoming text message from Messenger platform with all specific information.
platform: 'facebook'type: 'message'user: profiletext: emessagetextraw: e
Then, you can listen easily to this
event in your module or bot
platform: 'facebook'type: 'postback'user: profiletext: epostbackpayloadraw: e
The original attachments messenger event. May contain multiple attachments. Individual attachments are also emmited individually (see Image, Video, File below)
platform: 'facebook'type: 'attachments'user: profiletext: emessageattachmentslength + ' attachments'raw: e
Individual Attachment extracted from the Attachments event.
Note that Stickers, Thumbs Up, GIFs and Pictures are considered images too.
platform: 'facebook'type: 'image' // Same for 'video', 'file' and 'audio'user: profiletext: ''raw: type: 'image' payload: url: '...'
Same signature as
platform: 'facebook'type: 'referral'user: profiletext: ereferralrefraw: e
platform: 'facebook'type: 'quick_reply'user: profiletext: emessagequick_replypayloadraw: e
platform: 'facebook'type: 'optin'user: profiletext: eoptinrefraw: e
platform: 'facebook'type: 'delivery'user: profiletext: edeliverywatermarkraw: e
platform: 'facebook'type: 'read'user: profiletext: ereadwatermarkraw: e
By using our module, you can send anything you want to your users on Messenger. In fact, this module support all types of messages that are available on Facebook (text, images, videos, audios, webviews...).
bp.renderers.sendToUser(userId, elementOrRenderer, data) -> Promise
userId(String): Correspond to unique Messenger's recipient identifier
elementOrRenderer(String): The name of the renderer to use OR an element id
data(Object): Additionnal data that will be passed to the renderer
This module support postbacks. Postbacks occur when a Postback button, Get Started button, Persistent menu or Structured Message is tapped (facebook doc).
This module also support referrals. In fact, the value of the
ref parameter is passed by the server via webhook and we are able to access these referrals in parameters of input messages (facebook doc).
Display Get Started
To active get started button on Messenger, users can modify display setting directly in user interface (facebook doc).
Directly in module view, users are able to modify greeting message (facebook doc).
Users can directly modify persistent menu in module user interface. By using UI, it's possible to add, modify and remove items (facebook doc).
Automatically mark as read
Directly in UI, users can setup if they want to automatically mark all messages as read (facebook doc).
Composer input disabled
Directly in UI, users can setup if they want to deactivate or not the user input (facebook doc).
By using UI, users can configure (add, modify and remove) trusted domains (facebook doc).
Using the UI, you can set the home URL for your chat extension (facebook doc).
Note: the URL you specify must use HTTPS. Facebook will return an error if you enter an URL that is not using HTTPS.
Chat extensions supports the following configuration options:
- Update Home URL: the url that hosts your chat extension. You can remove the URL by leaving the box blank.
- Show Share Button: if checked, this will show a Facebook share button in the header of your webview.
- In Test: if checked, your chat extension is in test mode and is only viewable by people associated with your Messenger app in the developer console. Uncheck this box when you want your chat extension to be viewable to the general public
Using the UI, you can assign users to be "Payment Testers."
In order for this to work, the user must be a registered admin, developer or test user through your Facebook developer console and they must have initiated conversation with your bot. You cannot just add any user to be a payment tester. It is also important to note that this is the only way to run a test payment with Messenger Extensions.
When adding a new user, you can start typing their name into the box. This will pull up a list of matching users who have been communicating with your bot. The value in the parentheses is the page-scoped user ID for that user.
Automatic profile lookup
Profiles are automatically lookedup using Facebook Graph API. The profile of the user can be found in the incoming middleware events:
The following properties are available: first_name, last_name, locale, gender, timezone.
Save users in Database
Users are automatically persisted in the built-in botpress database using the built-in
Webhook security check
botpress-messenger verifies that requests really come from Facebook's servers by validating requests hash.
- Botpress examples (soon).
- Youtube Channel.
There's a Slack community where you are welcome to join us, ask any question and even help others.
Get an invite and join us now! 👉 https://slack.botpress.io
botpress-messenger is licensed under AGPL-3.0