{"_id":"facebook-bot-messenger","_rev":"31-2d349e0993836f310e8d66c928bb6cf8","time":{"0.0.1":"2020-10-25T04:18:15.050Z","0.0.10":"2020-10-25T04:18:15.050Z","0.0.11":"2020-10-25T04:18:15.050Z","0.0.12":"2020-10-25T04:18:15.050Z","0.0.13":"2020-10-25T04:18:15.050Z","0.0.14":"2020-10-25T04:18:15.050Z","0.0.15":"2020-10-25T04:18:15.050Z","0.0.16":"2020-10-25T04:18:15.050Z","0.0.2":"2020-10-25T04:18:15.050Z","0.0.3":"2020-10-25T04:18:15.050Z","0.0.4":"2020-10-25T04:18:15.050Z","0.0.5":"2020-10-25T04:18:15.050Z","0.0.6":"2020-10-25T04:18:15.050Z","0.0.7":"2020-10-25T04:18:15.050Z","0.0.8":"2020-10-25T04:18:15.050Z","0.0.9":"2020-10-25T04:18:15.050Z","1.0.0":"2020-10-25T04:18:15.050Z","1.0.1":"2020-10-25T04:18:15.050Z","1.0.2":"2020-10-25T04:18:15.050Z","1.0.3":"2020-10-25T04:18:15.050Z","1.0.4":"2020-10-25T04:18:15.050Z","1.0.5":"2020-10-25T04:18:15.050Z","1.0.6":"2020-10-25T04:18:15.050Z","1.0.7":"2020-10-25T04:18:15.050Z","1.0.8":"2020-10-25T04:18:15.050Z","created":"2020-10-26T22:10:26.913Z","1.0.9":"2020-10-26T22:10:27.051Z","modified":"2022-05-02T02:36:31.941Z"},"name":"facebook-bot-messenger","dist-tags":{"latest":"1.0.9"},"versions":{"1.0.9":{"name":"facebook-bot-messenger","version":"1.0.9","description":"SDK of the Facebook messenger platform for Node.js","main":"index.js","scripts":{"test":"mocha test"},"repository":{"type":"git","url":"git+https://github.com/snlangsuan/facebook-bot-messenger.git"},"keywords":["Facebook","Messenger","bot","api"],"author":{"name":"decimo.me"},"license":"ISC","bugs":{"url":"https://github.com/snlangsuan/facebook-bot-messenger/issues"},"homepage":"https://github.com/snlangsuan/facebook-bot-messenger#readme","dependencies":{"request":"^2.75.0"},"devDependencies":{"chai":"^3.5.0","express":"^4.14.0","mocha":"^3.1.0","nock":"^8.0.0"},"gitHead":"124374f41657892cdb306d489d4b396324a59255","_id":"facebook-bot-messenger@1.0.9","_nodeVersion":"12.14.1","_npmVersion":"6.14.5","dist":{"integrity":"sha512-pxXilgEHJEfISViFlfmNXUZAv/bgqb20hDPrhn2v0CE+n40YFZQ4cRWl7BnlNK3AEMC7bSjYe4+fN7GYnZWQEw==","shasum":"ad41b835878e6da0edcdbab038301d74c29e1f6b","tarball":"https://registry.npmjs.org/facebook-bot-messenger/-/facebook-bot-messenger-1.0.9.tgz","fileCount":62,"unpackedSize":95649,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfl0lTCRA9TVsSAnZWagAAkd8P/i0F7b01UhP5tSKUDhEA\nUeItJ7keYqVrgk92l86eGJIjFjfL1JawaOjNNSC2MhTfRXJnAUpOIII6gKgw\nm1arLfQrMo6x3hYBnNHyyn778DMMl80MQHaKxNJmw7cpHEy4sC2xxsZ09Ns7\nlS6yAvFW0wQ5bcdYOsEp4I3v/mcfXSkpB+1dHXsCwdXvjAOGYlde/lRmb0fH\nPn/lQrrBsyCtW/Qs1VNZAfWA+e7zzUyuNotm65/WHN8ZHJKC8rKyuvN1AQQ7\nfMhQQCyxu8aHFiYTzywb2U9BmnQ3/D+Or6sIrbi+YNQ4hZ1ectK58tEs2J63\n/a0v63JZjx1nzCA5peZKlx7f0sZaOFrS1Ot9IAVutn+KG1Fhydr8Oj8toAzf\n9dniX+rsmGnnWDOC0ivLqwDMhRYNnda0VBn5K+r2Z41PkWIosjsiwmmwltnD\n/6d6S2TDnz5sAA8JUhBcvf0JdQs+QPXmaRFlf4Yu3I5HRg2jitQ4rDG01dY2\nqsslzsdn4P0XACUvot9Pq5SJLYAu7PBS+SP2Cpz1SF+wiRbFCQq3sYLAGJVz\nU7zIpRJYrtlY8Hm5Ipggz4v7Ho5Ul1FVTiDh9N+/qi/VMffK1gMyl4d6+5Ju\niZ+LK/w5CfnNFmEwiXQGdF/X1VmZyqnOgNhjh35uFIu1kd74myotKy8PkUgF\nJv3a\r\n=E7uv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCZZNpyQV8AHBdlFMizqk3dO+GTYBJuMQ48Ju8mxDr+ZwIgTKsyFisIGPSnja5ScDdaU+bZ0wwl3XV+DOowJMw9jy0="}]},"maintainers":[{"name":"uzlopak","email":"aras.abbasi@googlemail.com"}],"_npmUser":{"name":"uzlopak","email":"aras.abbasi@googlemail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/facebook-bot-messenger_1.0.9_1603750226914_0.9983797557688634"},"_hasShrinkwrap":false}},"maintainers":[{"name":"uzlopak","email":"aras.abbasi@googlemail.com"}],"description":"SDK of the Facebook messenger platform for Node.js","homepage":"https://github.com/snlangsuan/facebook-bot-messenger#readme","keywords":["Facebook","Messenger","bot","api"],"repository":{"type":"git","url":"git+https://github.com/snlangsuan/facebook-bot-messenger.git"},"author":{"name":"decimo.me"},"bugs":{"url":"https://github.com/snlangsuan/facebook-bot-messenger/issues"},"license":"ISC","readme":"# facebook-bot-messenger\n\n==\n\n[![npm version](https://badge.fury.io/js/facebook-bot-messenger.svg)](https://badge.fury.io/js/facebook-bot-messenger)\n[![Build Status](https://travis-ci.org/snlangsuan/facebook-bot-messenger.svg?branch=master)](https://travis-ci.org/snlangsuan/facebook-bot-messenger)\n\nSDK of the Facebook Messenger Platform for Node.js\n\nInstallation\n--\n\nThe Facebook Messenger Platform SDK can be installed with [NPM](https://www.npmjs.com).\n\n```\n$ npm install facebook-bot-messenger\n```\n\nGetting started\n--\n\n### Require the SDK\n```js\nvar MessengerPlatform = require('facebook-bot-messenger');\n```\n\n### Create bot server with bot client instance (support on v.1.1.x)\nsample is following\n```js\nvar bot = MessengerPlatform.create({\n  pageID: '<your page id>',\n  appID: '<your app id>',\n  appSecret: '<your app secret>',\n  validationToken: '<your validation token>',\n  pageToken: '<your page token>'\n});\nbot.webhook('/webhook');\nbot.on(MessengerPlatform.Events.MESSAGE, function(userId, message) {\n  // add code below.\n});\nbot.listen(8080);\n```\n\n#### Using with Node http server\n```js\nvar server = require('http').createServer(handler);\nvar bot = MessengerPlatform.create({\n  pageID: '<your page id>',\n  appID: '<your app id>',\n  appSecret: '<your app secret>',\n  validationToken: '<your validation token>',\n  pageToken: '<your page token>'\n}, server);\nbot.webhook('/webhook');\nbot.on(MessengerPlatform.Events.MESSAGE, function(userId, message) {\n  // add code below.\n});\nserver.listen(8080);\n```\n\n#### Using with Express 3/4\n```js\nvar app = require('express')();\nvar server = require('http').Server(app);\nvar bot = MessengerPlatform.create({\n  pageID: '<your page id>',\n  appID: '<your app id>',\n  appSecret: '<your app secret>',\n  validationToken: '<your validation token>',\n  pageToken: '<your page token>'\n}, server);\napp.use(bot.webhook('/webhook'));\nbot.on(MessengerPlatform.Events.MESSAGE, function(userId, message) {\n  // add code below.\n});\nserver.listen(8080);\n```\n\n### Create the bot client instance\nInstance of bot client is a handler of the Messenger Platform.\n\n```js\nvar bot = MessengerPlatform.create({\n  pageID: '<your page id>',\n  appID: '<your app id>',\n  appSecret: '<your app secret>',\n  validationToken: '<your validation token>',\n  pageToken: '<your page token>'\n});\n```\n\n### Call API\n\nYou can call API through the bot client instance.\n\n#### Get profile\nGet detail information of user.\n\n```js\nbot.getProfile('<user id>').then(function(data) {\n  // add your code when success.\n}).catch(function(error) {\n  // add your code when error.\n});\n```\n\nWhen MessengerPlatform#getProfile() success return JSON object.\n\n#### Send action\n\nSend readed message\n```js\nbot.sendReadedAction('<user id>');\n```\n\nSend typing on\n```js\nbot.sendTypingAction('<user id>');\n```\n\nSend typing off\n```js\nbot.sendClearTypingAction('<user id>');\n```\n\n#### Send message\nsample is following\n\n```js\nbot.sendTextMessage('<user id>', '<message>');\n```\n\nThis procedure sends a message to the destination that is associated with <user id>.\n\nMore advanced sample is below;\n\n```js\nvar textMessageBuilder = new MessengerPlatform.TextMessageBuilder('<message>');\nbot.sendMessage('<user id>', textMessageBuilder);\n```\n\nAnd other send method;\n\nSend image attachment message\n```js\nbot.sendImageMessage('<user id>', '<url>', '<is reusable');\n```\n\nSend audio attachment message\n```js\nbot.sendAudioMessage('<user id>', '<url>', '<is reusable');\n```\n\nSend video attachment message\n```js\nbot.sendVideoMessage('<user id>', '<url>', '<is reusable');\n```\n\nSend file attachment message\n```js\nbot.sendFileMessage('<user id>', '<url>', '<is reusable');\n```\n\n#### Message builder\nType of message depends on the type of instance of MessageBuilder. That means this method sends text message if you pass TextMessageBuilder\n\nThe type of instance of MessageBuilder\n\nTextMessageBuilder\n```js\nvar builder = new MessengerPlatform.TextMessageBuilder('<message>');\n```\n\nQuickRepliesMessageBuilder\n```js\nvar builder = new MessengerPlatform.QuickRepliesMessageBuilder('Pick a color:');\nbuilder.addImageOption('Red', 'DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_RED', 'http://petersfantastichats.com/img/red.png')\n       .addImageOption('Green', 'DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_GREEN', 'http://petersfantastichats.com/img/green.png');\n```\n\nAttachmentMessageBuilder\n```js\nvar builder = new MessengerPlatform.AttachmentMessageBuilder();\nbuilder.addImageAttachment('<url>', '<is reusable>');\n```\n\nTemplate attachment message:\n\n- Generic\n\n```js\nvar element = new MessengerPlatform.GenericElementTemplateBuilder('Welcome to Peter\\'s Hats', 'https://petersfancybrownhats.com', 'https://petersfancybrownhats.com/company_image.png', 'We\\'ve got the right hat for everyone.');\nelement1.addButton(new MessengerPlatform.URLButtonBuilder('View Website', 'https://petersfancybrownhats.com'));\nvar template = new MessengerPlatform.GenericTemplateBuilder();\ntemplate.addElement(element);\nvar builder = new MessengerPlatform.AttachmentMessageBuilder(template);\n```\n\n- Button\n\n```js\nvar btnUrl = new MessengerPlatform.URLButtonBuilder('Show Website', 'https://petersapparel.parseapp.com');\nvar btnPostback = new MessengerPlatform.PostbackButtonBuilder('Start Chatting', 'DEVELOPER_DEFINED_PAYLOAD');\nvar template = new MessengerPlatform.ButtonTemplateBuilder('What do you want to do next?', [btnUrl, btnPostback]);\nvar builder = new MessengerPlatform.AttachmentMessageBuilder(template);\n```\n\n- List\n\n```js\nvar element1 = new MessengerPlatform.ListElementTemplateBuilder('Classic Black T-Shirt', 'https://peterssendreceiveapp.ngrok.io/img/black-t-shirt.png', '100% Cotton, 200% Comfortable');\nelement1.setDefaultAction('https://peterssendreceiveapp.ngrok.io/view?item=102', 'https://peterssendreceiveapp.ngrok.io/', true, MessengerPlatform.WebviewHeight.TALL)\n        .addURLButton('Buy', 'https://peterssendreceiveapp.ngrok.io/view?item=102');\n\nvar element2 = new MessengerPlatform.ListElementTemplateBuilder('Classic Gray T-Shirt', 'https://peterssendreceiveapp.ngrok.io/img/gray-t-shirt.png', '100% Cotton, 200% Comfortable');\nelement2.setDefaultAction('https://peterssendreceiveapp.ngrok.io/view?item=103', 'https://peterssendreceiveapp.ngrok.io/', true, MessengerPlatform.WebviewHeight.TALL)\n        .addURLButton('Buy', 'https://peterssendreceiveapp.ngrok.io/shop?item=103');\nvar template = new MessengerPlatform.ListTemplateBuilder();\ntemplate.isLargeTopElement(true)\n        .addElement(element1)\n        .addElement(element2)\n        .addPostbackButton('View More', 'USER_DEFINED_PAYLOAD');\nvar builder = new MessengerPlatform.AttachmentMessageBuilder(template);\n```\n\n- Receipt\n\n```js\nvar template = new MessengerPlatform.ReceiptTemplateBuilder('Stephane Crozatier', '12345678902', 'USD', 'Visa 2345');\ntemplate.setOrderUrl('http://petersapparel.parseapp.com/order?order_id=123456')\n        .setTimestamp('1428444852')\n        .addElement('Classic White T-Shirt', 50, 'http://petersapparel.parseapp.com/img/whiteshirt.png', 2, '100% Soft and Luxurious Cotton', 'USD')\n        .addElement('Classic Gray T-Shirt', 25, 'http://petersapparel.parseapp.com/img/grayshirt.png', 1, '100% Soft and Luxurious Cotton', 'USD')\n        .setAddress(['1 Hacker Way'], 'Menlo Park', 'CA', '94025', 'US')\n        .setSummary('56.14', '75.00', '4.95', '6.19')\n        .addAdjustment('New Customer Discount', 20)\n        .addAdjustment('$10 Off Coupon', 10);\nvar builder = new MessengerPlatform.AttachmentMessageBuilder(template);\n```\n#### Webhook\nFacebook's server sends user action (message, message delivered, message read and etc.) to your bot server. Request of that contains event(s); event is action of the user.\n\nWebhook events:\n- **MESSAGE** Event name will occur when a message has been sent to your page. You may receive text messages or messages with attachments.\n- **MESSAGE_DELIVERED** Event name will occur when a message a page has sent has been delivered.\n- **MESSAGE_READ** Event name will occur when a message a page has sent has been read by the user.\n- **MESSAGE_ECHO** Event name will occur when a message has been sent by your page. You may receive text messsages or messages with attachments.\n- **POSTBACK** Event name will occur when a Postback button, Get Started button, Persistent menu or Structured Message is tapped.\n- **OPTIN** Event name will occur when the Send-to-Messenger plugin has been tapped.\n- **REFERRAL** Event name will occur when an m.me link is used with a referral param and only in a case this user already has a thread with this bot.\n- **PAYMENTS** Event name will occurs when a persons taps the pay button from the checkout dialog rendered by the Buy Button.\n- **CHECKOUT_UPDATE** Event name enables you to update pricing for flexible-amount transactions on the checkout dialog displayed by the Buy Button.\n- **ACCOUNT_LINKING** Event name will occur when the Linked Account or Unlink Account call-to-action have been tapped.\n\nSee Also\n--\n\n- [Messenger Platform Guides](https://developers.facebook.com/docs/messenger-platform/guides)\n- [Messenger Platform Webhook Reference](https://developers.facebook.com/docs/messenger-platform/webhook-reference)\n- [Messenger Platform Send API Reference](https://developers.facebook.com/docs/messenger-platform/send-api-reference)\n","readmeFilename":"README.md"}