{"id":18753134,"url":"https://github.com/bottenderjs/bottender-facebook","last_synced_at":"2026-02-19T23:02:04.419Z","repository":{"id":42108357,"uuid":"112184442","full_name":"bottenderjs/bottender-facebook","owner":"bottenderjs","description":"Facebook connector for Bottender.","archived":false,"fork":false,"pushed_at":"2023-01-04T01:20:06.000Z","size":1194,"stargazers_count":9,"open_issues_count":19,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T00:53:10.345Z","etag":null,"topics":["bottender","facebook"],"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/bottenderjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-11-27T10:52:42.000Z","updated_at":"2022-09-10T01:05:47.000Z","dependencies_parsed_at":"2023-02-01T17:31:02.854Z","dependency_job_id":null,"html_url":"https://github.com/bottenderjs/bottender-facebook","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/bottenderjs/bottender-facebook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bottenderjs%2Fbottender-facebook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bottenderjs%2Fbottender-facebook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bottenderjs%2Fbottender-facebook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bottenderjs%2Fbottender-facebook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bottenderjs","download_url":"https://codeload.github.com/bottenderjs/bottender-facebook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bottenderjs%2Fbottender-facebook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29636040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"ssl_error","status_checked_at":"2026-02-19T22:32:38.330Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bottender","facebook"],"created_at":"2024-11-07T17:24:27.263Z","updated_at":"2026-02-19T23:02:04.402Z","avatar_url":"https://github.com/bottenderjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bottender Facebook\n\n[![npm](https://img.shields.io/npm/v/bottender-facebook.svg?style=flat-square)](https://www.npmjs.com/package/bottender-facebook)\n[![Build Status](https://travis-ci.org/bottenderjs/bottender-facebook.svg?branch=master)](https://travis-ci.org/bottenderjs/bottender-facebook)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\u003e Facebook connector for [Bottender](https://github.com/Yoctol/bottender).\n\n## Installation\n\n```sh\nnpm install bottender-facebook bottender messaging-api-messenger\n```\n\n## Requirement\n\n### Facebook App Graph API verion\n\nUsing the API version before `v2.10` may cause unexpected behavior.\\\nWe highly recommend the API version after `v2.11`.\n\n### Subscribe to essential fields\n\nYou need to make sure the webhook of your page is subscribing to the `feed` field on API version after `v2.11`.\n\n### User Permissions Required\n\n- **manage_pages**\n- **publish_pages** - for public replies\n- **read_page_mailboxes** - for private replies\n\n## Example\n\n```js\nconst { Bot } = require('bottender');\nconst { createServer } = require('bottender/express');\nconst { FacebookConnector } = require('bottender-facebook');\n\n// We can get `story_fbid` in URL query string\nconst POST_ID =\n  process.env.POST_ID || `${process.env.PAGE_ID}_${process.env.STORY_FBID}`;\n\nconst bot = new Bot({\n  connector: new FacebookConnector({\n    accessToken: process.env.ACCESS_TOKEN,\n    appSecret: process.env.APP_SECRET,\n  }),\n});\n\nbot.onEvent(async context =\u003e {\n  if (\n    context.event.isCommentAdd \u0026\u0026\n    context.event.comment.post_id === POST_ID \u0026\u0026\n    context.event.comment.parent_id === POST_ID\n  ) {\n    await context.sendPrivateReply('OK!');\n    await context.sendComment('Public comment!');\n  }\n});\n\nconst server = createServer(bot);\n```\n\n### Custom Graph API version\n\nThe default `Graph API` version is `v3.2` (recommended). \\\nYou can use other version by following this example:\n\n```js\nconst { Bot } = require('bottender');\nconst { FacebookConnector, FacebookClient } = require('bottender-facebook');\n\nconst bot = new Bot({\n  connector: new FacebookConnector({\n    appSecret: APP_SECRET,\n    client: FacebookClient.connect({\n      accessToken: ACCESS_TOKEN,\n      version: '3.2',\n    }),\n  }),\n});\n```\n\n## API Reference\n\n### Client\n\n- `client.sendComment(objectId, comment)`\n\n```js\nawait client.sendComment('\u003cobject_id\u003e', 'ok!'); // send as text message\nawait client.sendComment('\u003cobject_id\u003e', { message: 'ok!' });\nawait client.sendComment('\u003cobject_id\u003e', { attachment_id: '\u003cattachment_id\u003e' });\nawait client.sendComment('\u003cobject_id\u003e', {\n  attachment_share_url: 'https://example.com/img.gif',\n});\nawait client.sendComment('\u003cobject_id\u003e', {\n  attachment_url: 'https://example.com/img.jpg',\n});\n```\n\n- `client.sendPrivateReply(objectId, text)`\n\n```js\nawait client.sendPrivateReply('\u003cobject_id\u003e', 'ok!');\n```\n\n- `client.sendLike()`\n- `client.getComment()`\n- `client.getLikes()`\n\n### Context\n\n- `context.sendComment(comment)`\n\n```js\nawait context.sendComment('ok!'); // send as text message\nawait context.sendComment({ message: 'ok!' });\nawait context.sendComment({ attachment_id: '\u003cattachment_id\u003e' });\nawait context.sendComment({\n  attachment_share_url: 'https://example.com/img.gif',\n});\nawait context.sendComment({ attachment_url: 'https://example.com/img.jpg' });\n```\n\n- `context.sendPrivateReply(text)`\n\n```js\nawait context.sendPrivateReply('ok!');\n```\n\n- `context.sendLike()`\n- `context.getComment()`\n\n```js\nconst comment = await context.getComment({ fields: ['message_tags'] });\n\nconsole.log(comment);\n// {\n//   id: '2013582382205928_2258908961006601',\n//   // facebook returns undefined as message_tags instead of empty array\n//   // when there is no tag\n//   message_tags: [\n//     {\n//       id: '1895382890692545',\n//       length: 8,\n//       name: 'Bot Demo',\n//       offset: 0,\n//       type: 'page'\n//     },\n//   ],\n// }\n```\n\n- `context.getLikes()`\n- `context.canReplyPrivately()`\n\n```js\nawait context.canReplyPrivately(); // true\n```\n\n### Event\n\n- `event.isFeed`\n- `event.isStatus`\n- `event.isStatusAdd`\n- `event.isStatusEdited`\n- `event.status`\n- `event.isPost`\n- `event.isPostRemove`\n- `event.post`\n- `event.isComment`\n- `event.isCommentAdd`\n- `event.isCommentEdited`\n- `event.isCommentRemove`\n- `event.isFirstLayerComment`\n- `event.comment`\n- `event.isLike`\n- `event.isLikeAdd`\n- `event.isLikeRemove`\n- `event.like`\n- `event.isReaction`\n- `event.isReactionAdd`\n- `event.isReactionEdit`\n- `event.isReactionRemove`\n- `event.reaction`\n\n## Contributing\n\nPull Requests and issue reports are welcome. You can follow steps below to\nsubmit your pull requests:\n\nFork, then clone the repo:\n\n```sh\ngit clone git@github.com:your-username/bottender-facebook.git\n```\n\nInstall the dependencies:\n\n```sh\ncd bottender-facebook\nyarn\n```\n\nMake sure the tests pass (including eslint, flow checks and jest tests):\n\n```sh\nyarn test\n```\n\nMake your changes and tests, and make sure the tests pass.\n\n## License\n\nMIT © [Yoctol](https://github.com/bottenderjs/bottender-facebook)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbottenderjs%2Fbottender-facebook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbottenderjs%2Fbottender-facebook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbottenderjs%2Fbottender-facebook/lists"}