{"id":19425583,"url":"https://github.com/botmasterai/botmaster-messenger","last_synced_at":"2025-07-15T19:38:38.864Z","repository":{"id":57124741,"uuid":"83366828","full_name":"botmasterai/botmaster-messenger","owner":"botmasterai","description":"The Facebook Messenger Botmaster integration","archived":false,"fork":false,"pushed_at":"2018-08-24T06:34:37.000Z","size":168,"stargazers_count":13,"open_issues_count":3,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-16T07:14:53.979Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/botmasterai.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-27T23:13:16.000Z","updated_at":"2025-02-21T15:49:11.000Z","dependencies_parsed_at":"2022-08-31T08:12:01.972Z","dependency_job_id":null,"html_url":"https://github.com/botmasterai/botmaster-messenger","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botmasterai%2Fbotmaster-messenger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botmasterai%2Fbotmaster-messenger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botmasterai%2Fbotmaster-messenger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botmasterai%2Fbotmaster-messenger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/botmasterai","download_url":"https://codeload.github.com/botmasterai/botmaster-messenger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250663544,"owners_count":21467366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T14:04:09.494Z","updated_at":"2025-04-24T16:31:39.796Z","avatar_url":"https://github.com/botmasterai.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Botmaster-messenger\n\n[![Build Status](https://travis-ci.org/botmasterai/botmaster-messenger.svg?branch=master)](https://travis-ci.org/botmasterai/botmaster-messenger)\n[![Coverage Status](https://coveralls.io/repos/github/botmasterai/botmaster-messenger/badge.svg?branch=master)](https://coveralls.io/github/botmasterai/botmaster-messenger?branch=master)\n[![npm-version](https://img.shields.io/npm/v/botmaster-messenger.svg)](https://www.npmjs.com/package/botmaster-messenger)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](LICENSE)\n\nThis is the FB messenger integration for botmaster. It allows you to use your \nbotmaster bot on FB Messenger\n\nBotmaster is a lightweight chatbot framework. Its purpose is to integrate your existing chatbot into a variety of messaging channels - currently Facebook Messenger, Twitter DM and Telegram.\n\n## Documentation\n\nFind the whole documentation for the Botmaster framework on: \u003chttp://botmasterai.com/documentation/latest\u003e\n\n## Installing\n\n```bash\nyarn add botmaster-messenger\n```\n\nor\n\n```bash\nnpm install --save botmaster-messenger\n```\n\n## Getting your Credentials\n\nIf you don't already have these, follow the steps **1-4** on the Facebook Messenger guide:\n\u003chttps://developers.facebook.com/docs/messenger-platform/guides/quick-start\u003e\n\nIn **step 2**, where you setup your webhook, no need to code anything. Just specify the webhook, enter any secure string you want as a verify token(`verifyToken`) and copy that value in the settings object. Also, click on whichever message [those are \"update\"s using botmaster semantics] type you want to receive from Messenger (`message_deliveries`, `messages`, `message_postbacks` etc...).\n\nTo find your Facebook App Secret (`fbAppSecret`), navigate to your apps dashboard and under `App Secret` click show, enter your password if prompted and then there it is.\n\n## Code\n\nExample code using a single page for a bot. When using a single page, botmaster can be used\nas expected.\n\n```js\nconst Botmaster = require('botmaster');\nconst MessengerBot = require('botmaster-messenger');\nconst botmaster = new Botmaster();\n\nconst messengerSettings = {\n  credentials: {\n    verifyToken: 'YOUR verifyToken',\n    pageToken: 'YOUR pageToken',\n    fbAppSecret: 'YOUR fbAppSecret',\n  },\n  webhookEndpoint: 'webhook1234',\n};\n\nconst messengerBot = new MessengerBot(messengerSettings);\n\nbotmaster.addBot(messengerBot);\n\nbotmaster.use({\n  type: 'incoming',\n  name: 'my-middleware',\n  controller: (bot, update) =\u003e {\n    return bot.reply(update, 'Hello world!');\n  }\n});\n```\n\nmulti-page bot example\n\n```js\nconst Botmaster = require('botmaster');\nconst MessengerBot = require('botmaster-messenger');\nconst botmaster = new Botmaster();\n\nconst messengerSettings = {\n  credentials: {\n    verifyToken: 'YOUR_VERIFY_TOKEN',\n    fbAppSecret: 'YOUR_FB_APP_SECRET',\n    pages: {\n      'YOUR_PAGE_ID_1': {\n        pageToken: 'YOUR_PAGE_TOKEN_1',\n      },\n      'YOUR_PAGE_ID_2': {\n        pageToken: 'YOUR_PAGE_TOKEN_2',\n      },\n    },\n  },\n  webhookEndpoint: 'webhook1234',\n};\n\nconst messengerBot = new MessengerBot(messengerSettings);\n\nbotmaster.addBot(messengerBot);\n\nbotmaster.use({\n  type: 'incoming',\n  name: 'my-middleware',\n  controller: (bot, update) =\u003e {\n    // 1) if you simply want to respond as the page that received the update.\n    bot.reply(update, 'Hello World');\n    // 2) or if you want to specify another page to response as, you can always set\n    // the messageToSend.sender.id param as some other pageId as such.\n    const messageToSend = bot.createOutgoingMessageFor(update.sender.id); // or any other page-scoped userId you know is using your page\n    messageToSend.addText('Hello World');\n    messageToSend.sender = {\n      id: 'SOME_PAGE_ID', // update.sender.id would be this page. But you can set it to something else.\n    };\n    return bot.sendMessage(messageToSend);\n  }\n});\n```\n\n## Webhooks\n\nIf you are not too sure how webhooks work and/or how to get them to run locally, go to [webhooks](/getting-started/webhooks) to read some more.\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### MessengerBot\n\n**Extends BaseBot**\n\nThe class to use if you want to add support for FB Messenger in your\nBotmaster project.\n\n**Parameters**\n\n-   `settings`  \n\n#### constructor\n\nConstructor to the MessengerBot class\n\n**Parameters**\n\n-   `settings` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** MessengerBot take a settings\n    object as first param.\n\n**Examples**\n\n```javascript\n// single page bot\nconst messengerBot = new MessengerBot({\n  credentials: {\n    verifyToken: 'YOUR verifyToken',\n    pageToken: 'YOUR pageToken',\n    fbAppSecret: 'YOUR fbAppSecret',\n  },\n  webhookEndpoint: 'someEndpoint'\n})\n```\n\n```javascript\n// multi-page bot\nconst messengerBot = new MessengerBot({\n  credentials: {\n    verifyToken: 'YOUR_VERIFY_TOKEN',\n    fbAppSecret: 'YOUR_FB_APP_SECRET',\n    pages: {\n      'YOUR_PAGE_ID_1': {\n         pageToken: 'YOUR_PAGE_TOKEN_1',\n       },\n      'YOUR_PAGE_ID_2': {\n         pageToken: 'YOUR_PAGE_TOKEN_2',\n       },\n      etc...\n    },\n  },\n  webhookEndpoint: 'someEndpoint'\n})\n```\n\n#### \\_setGetStartedButton\n\nAdds get start button to your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/get-started-button\u003e\n\n**Parameters**\n\n-   `getStartedButtonPayload` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The payload of the postback\n    you will get when a user clicks on the get started button.\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_getGetStartedButton\n\ngets get started button payload from your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/get-started-button\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_removeGetStartedButton\n\nremoves get started button from your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/get-started-button\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_setPersistentMenu\n\nAdds account Linking to your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu\u003e\n\n**Parameters**\n\n-   `persistentMenu` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** persistent menu to use for your messenger\n    bot\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_getPersistentMenu\n\nget persistent menu from your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_removePersistentMenu\n\nremoves persistent menu from your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_setGreetingText\n\nAdds greeting text to your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text\u003e\n\n**Parameters**\n\n-   `greetingObject` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** greeting objects. Can be localized.\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_getGreetingText\n\nget greeting text from your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_removeGreetingText\n\nremoves greeting text from bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_setWhitelistedDomains\n\nAdds white listed domains to your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/domain-whitelisting\u003e\n\n**Parameters**\n\n-   `domainNameLists` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** List of domains to whitelist.\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_getWhitelistedDomains\n\nget whitelisted domains from your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_removeWhitelistedDomains\n\nremoves whitelisted domains from bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text\u003e\n\n**Parameters**\n\n-   `domainNameLists`  \n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_setAccountLinkingUrl\n\nAdds account Linking url to your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/account-linking-url\u003e\n\n**Parameters**\n\n-   `accountLinkingURL` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Authentication callback URL.\n    Must use https protocol.\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_getAccountLinkingUrl\n\nget account linking url from your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/account-linking-url\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_removeAccountLinkingUrl\n\nremoves account Linking to your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/account-linking-url\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId`  \n\n#### \\_setTargetAudience\n\nAdds target audience url to your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/target-audience\u003e\n\n**Parameters**\n\n-   `targetAudience` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_getTargetAudience\n\nget target audience url from your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/target-audience\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_removeTargetAudience\n\nremoves target audience to your bot. Read more here:\n\u003chttps://developers.facebook.com/docs/messenger-platform/messenger-profile/target-audience\u003e\n\n**Parameters**\n\n-   `resolveWithFullResponse` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** specify wether request should\n    resolve with full response or not. By default, this is false\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** specify the page you want to set the get started button\n    for. This iw valid only if you are using botmaster-messenger with multiple pages\n\n#### \\_getUserInfoFromPage\n\nget the info for a certain user from a certain page\n\n**Parameters**\n\n-   `userId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** id of the user whose information is requested\n-   `pageId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** specify the page you want to get the user info from.\n    Different pages may have different rights.\n\n## Contributing\n\nIn order to contribute, you will need to make sure the tests run on your local machine. To do so, follow these steps:\n\n1.  Create a `./tests/_config.js` file that looks like this:\n\n```js\n'use strict';\n\nconst config = {\n  messengerCredentials: () =\u003e ({\n    verifyToken: 'YOUR_VERIFY_TOKEN',\n    pageToken: 'YOUR_PAGE_TOKEN',\n    fbAppSecret: 'YOUR_FB_APP_SECRET',\n  }),\n\n  messengerMultiPageCredentials: () =\u003e ({\n    verifyToken: 'YOUR_VERIFY_TOKEN',\n    fbAppSecret: 'YOUR_FB_APP_SECRET',\n    pages: {\n      'YOUR_PAGE_ID_1': {\n        pageToken: 'YOUR_PAGE_TOKEN_1',\n      },\n      'YOUR_PAGE_ID_2': {\n        pageToken: 'YOUR_PAGE_TOKEN_2',\n      },\n    },\n  }),\n\n  messengerUserId: () =\u003e 'YOUR_USER_ID_FOR_THIS_PAGE', // who to send messages to in tests (most probably one of your accounts)\n  messengerBotId: () =\u003e 'YOUR_BOT_ID', // the id of the bot (as sent in message updates). I.E. your page id\n};\n\nmodule.exports = config;\n```\n\nThis file is gitignored so won't be committed.\n\n2.  Just run the tests\n\n`yarn test`\n\n## License\n\nThis library is licensed under the MIT [license](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbotmasterai%2Fbotmaster-messenger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbotmasterai%2Fbotmaster-messenger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbotmasterai%2Fbotmaster-messenger/lists"}