{"id":13486711,"url":"https://github.com/conbus/fbmq","last_synced_at":"2026-01-14T08:47:46.179Z","repository":{"id":57428782,"uuid":"66074467","full_name":"conbus/fbmq","owner":"conbus","description":"(Deprecated) Facebook Messenger Platform Python Library (Facebook Chatbot Library)","archived":false,"fork":false,"pushed_at":"2019-10-11T08:26:30.000Z","size":7159,"stargazers_count":169,"open_issues_count":20,"forks_count":63,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-09-22T15:52:40.793Z","etag":null,"topics":["chatbot","facebook-chatbot","facebook-messenger-api","facebook-messenger-bot","facebook-messenger-platform"],"latest_commit_sha":null,"homepage":"","language":"Python","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/conbus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"2016-08-19T10:26:47.000Z","updated_at":"2025-08-30T22:38:54.000Z","dependencies_parsed_at":"2022-09-02T16:40:39.931Z","dependency_job_id":null,"html_url":"https://github.com/conbus/fbmq","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/conbus/fbmq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conbus%2Ffbmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conbus%2Ffbmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conbus%2Ffbmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conbus%2Ffbmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conbus","download_url":"https://codeload.github.com/conbus/fbmq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conbus%2Ffbmq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28414693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"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":["chatbot","facebook-chatbot","facebook-messenger-api","facebook-messenger-bot","facebook-messenger-platform"],"created_at":"2024-07-31T18:00:50.191Z","updated_at":"2026-01-14T08:47:46.160Z","avatar_url":"https://github.com/conbus.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# (Deprecated Project)\n## FBMQ (Facebook Messenger Platform Python Library)\n[![PyPI](https://img.shields.io/pypi/v/fbmq.svg?v=1\u0026maxAge=3601)](https://pypi.python.org/pypi/fbmq)\n[![Build Status](https://travis-ci.org/conbus/fbmq.svg?branch=master\u0026v=1)](https://travis-ci.org/conbus/fbmq)\n[![Coverage Status](https://coveralls.io/repos/github/conbus/fbmq/badge.svg?branch=master)](https://coveralls.io/github/conbus/fbmq?branch=master)\n[![PyPI](https://img.shields.io/pypi/l/fbmq.svg?v=1\u0026maxAge=2592000)](https://pypi.python.org/pypi/fbmq)\n\nA Python Library For Using The Facebook Messenger Platform API (Python Facebook Chat \u0026 Chatbot Library)\nFacebook messenger platform api full features are supported\n## Table of Contents\n\n* [Install](#install)\n* [Handle webhook](#handle-webhook)\n  * [usage (with flask)](#usage-with-flask)\n  * [handlers](#handlers)\n* [Send a message](#send-a-message)\n  * [basic](#basic)\n    * [text](#text)\n    * [image](#image) / [audio](#audio) / [video](#video) / [file](#file)\n    * [quick reply](#quick-reply)\n      * [quick reply callback](#quick-reply-callback)\n    * [typing on/off](#typing-onoff)\n  * [templates](#templates)\n    * [button](#template--button)\n      * [button callback](#button-callback)\n    * [generic](#template--generic)\n    * [receipt](#template--receipt)\n  * [options](#options)\n    * [notification type](#notification-type)\n    * [callback](#callback) \n* [Thread settings](#thread-settings)\n  * [greeting text](#greeting-text)\n  * [get started button](#get-started-button)\n  * [persistent menu](#persistent-menu)\n* [Fetch user/page profile](#fetch-userpage-profile)\n* [Example](#example)\n\n\n# Install\n```\npip install fbmq\n```\n\n# Handle webhook\nhow to handle messages from user to facebook page\n\n### Usage (with flask)\n```python\nfrom flask import Flask, request\nfrom fbmq import Page\n\npage = Page(PAGE_ACCESS_TOKEN)\n\n@app.route('/webhook', methods=['POST'])\ndef webhook():\n  page.handle_webhook(request.get_data(as_text=True))\n  return \"ok\"\n\n@page.handle_message\ndef message_handler(event):\n  \"\"\":type event: fbmq.Event\"\"\"\n  sender_id = event.sender_id\n  message = event.message_text\n  \n  page.send(sender_id, \"thank you! your message is '%s'\" % message)\n\n@page.after_send\ndef after_send(payload, response):\n  \"\"\":type payload: fbmq.Payload\"\"\"\n  print(\"complete\")\n```\n\n### handlers\nA spec in detail - https://developers.facebook.com/docs/messenger-platform/webhook-reference\n\n`@page.handle_message` - This callback will occur when a message has been sent to your page. (`quick reply` is also handled in here)\n\n`@page.handle_echo` - This callback will occur when a message has been sent by your page\n\n`@page.handle_delivery` - This callback will occur when a message a page has sent has been delivered.\n\n`@page.handle_optin` - This callback will occur when the [Send-to-Messenger](https://developers.facebook.com/docs/messenger-platform/plugin-reference/send-to-messenger) plugin has been tapped\n\n`@page.handle_postback` - Postbacks occur when a Postback button, Get Started button, Persistent menu or Structured Message is tapped.\n\n`@page.handle_read` - This callback will occur when a message a page has sent has been read by the user.\n\n`@page.handle_account_linking` - This callback will occur when the Linked Account or Unlink Account call-to-action have been tapped.\n\n`@page.after_send` - This callback will occur when page.send function has been called.\n\n#### Event parameter (fbmq.Event class)\n\n`event.sender_id` _str_ : message sender id, user id\n\n`event.recipient_id` _str_ : message receiver id, page id\n\n`event.timestamp` _number_ : timestamp when message is received\n\n`event.message` _dict_ : message dict that is received. [more detail](https://developers.facebook.com/docs/messenger-platform/webhook-reference/message-received)\n\n`event.message_text` _str_ : `event.message.get('text')`\n\n`event.message_attachments` _str_ : `event.message.get('attachments')`\n\n`event.quick_reply` _dict_ : quick reply dict that is received. [more detail](https://developers.facebook.com/docs/messenger-platform/webhook-reference/message-received)\n\n`event.quick_reply_payload` _str_ : `event.quick_reply.get('payload')\n\n`event.postback` _dict_ : postback dict that is received. [more detail](https://developers.facebook.com/docs/messenger-platform/webhook-reference/postback-received)\n\n`event.postback_payload` _str_ : `event.postback.get('payload')\n\n`event.optin` _dict_ : dict that is received. [more detail](https://developers.facebook.com/docs/messenger-platform/webhook-reference/authentication)\n\n`event.account_linking` _dict_: dict that is received. [more detail](https://developers.facebook.com/docs/messenger-platform/account-linking)\n\n`event.delivery` _dict_: dict that is received. [more detail](https://developers.facebook.com/docs/messenger-platform/webhook-reference/message-delivered)\n\n`event.read` _dict_: dict that is received. [more detail](https://developers.facebook.com/docs/messenger-platform/webhook-reference/message-read)\n\n\n`event.is_*` _bool_ - True if event type is valid\n\n#### if you don't need a decorator\n```python\npage = fbmq.Page(PAGE_ACCESS_TOKEN, after_send=after_send)\n\n@app.route('/webhook', methods=['POST'])\ndef webhook():\n  page.handle_webhook(request.get_data(as_text=True),\n                      message=message_handler)\n  return \"ok\"\n\ndef message_handler(event):\n  \"\"\":type event: fbmq.Event\"\"\"\n  sender_id = event.sender_id\n  message = event.message_text\n  \n  page.send(sender_id, \"thank you! your message is '%s'\" % message)\n\ndef after_send(payload, response):\n  \"\"\":type event: fbmq.Payload\"\"\"\n  print(\"complete\")\n```\n\n# Send a message\nhow to send a message from facebook page to user\n\n### Basic\n\n##### Import\n```python\nfrom fbmq import Attachment, Template, QuickReply, Page\n```\n\n##### Text\n```python\npage.send(recipient_id, \"hello world!\")\n```\n\n\n##### Image\njpg, png, gif support\n```python\npage.send(recipient_id, Attachment.Image(image_url))\n```\n\n\n##### Audio\n```python\npage.send(recipient_id, Attachment.Audio(audio_url))\n```\n\n##### Video\n```python\npage.send(recipient_id, Attachment.Video(video_url))\n```\n\n\n##### File\n```python\npage.send(recipient_id, Attachment.File(file_url))\n```\n\n\n\n##### quick reply\n```python\nquick_replies = [\n  QuickReply(title=\"Action\", payload=\"PICK_ACTION\"),\n  QuickReply(title=\"Comedy\", payload=\"PICK_COMEDY\")\n]\n\n# you can use a dict instead of a QuickReply class\n#\n# quick_replies = [{'title': 'Action', 'payload': 'PICK_ACTION'},\n#                {'title': 'Comedy', 'payload': 'PICK_COMEDY'}]\n\n\npage.send(recipient_id, \n          \"What's your favorite movie genre?\",\n          quick_replies=quick_replies,\n          metadata=\"DEVELOPER_DEFINED_METADATA\")\n```\n\n##### quick reply callback\nyou can define easily a quick reply callback method.\n```python\n@page.callback(['PICK_ACTION', 'PICK_COMEDY'])\ndef callback_picked_genre(payload, event):\n  print(payload, event)\n  \n# Also supported regex, it works corretly\n# @page.callback(['PICK_(.+)'])\n```\n\nif you want to handle only quick_reply callback without button postback\n```python\n@page.callback(['PICK_ACTION', 'PICK_COMEDY'], types=['QUICK_REPLY'])\n```\n\n##### typing on/off\n```python\npage.typing_on(recipient_id)\npage.typing_off(recipient_id)\n```\n\n\n\n### Templates\n\n##### Template : Button\n```python\nbuttons = [\n  Templates.ButtonWeb(\"Open Web URL\", \"https://www.oculus.com/en-us/rift/\"),\n  Templates.ButtonPostBack(\"trigger Postback\", \"DEVELOPED_DEFINED_PAYLOAD\"),\n  Templates.ButtonPhoneNumber(\"Call Phone Number\", \"+16505551234\")\n]\n\n# you can use a dict instead of a Button class\n#\n# buttons = [{'type': 'web_url', 'title': 'Open Web URL', 'value': 'https://www.oculus.com/en-us/rift/'},\n#          {'type': 'postback', 'title': 'trigger Postback', 'value': 'DEVELOPED_DEFINED_PAYLOAD'},\n#          {'type': 'phone_number', 'title': 'Call Phone Number', 'value': '+16505551234'}]\n\npage.send(recipient_id, Template.Buttons(\"hello\", buttons))\n```\n\n##### button callback\nyou can define easily a button postback method (it works only postback type buttons).\n```python\n@page.callback(['DEVELOPED_DEFINED_PAYLOAD'])\ndef callback_clicked_button(payload, event):\n  print(payload, event)\n  \n# Also supported regex, it works corretly\n# @page.callback(['DEVELOPED_DEFINE(.+)'])\n```\n\nif you want to handle only button's postback without quick_reply callback\n```python\n@page.callback(['DEVELOPED_DEFINED_PAYLOAD'], types=['POSTBACK'])\n```\n\n\n##### Template : Generic\n```python\npage.send(recipient_id, Template.Generic([\n  Template.GenericElement(\"rift\",\n                          subtitle=\"Next-generation virtual reality\",\n                          item_url=\"https://www.oculus.com/en-us/rift/\",\n                          image_url=CONFIG['SERVER_URL'] + \"/assets/rift.png\",\n                          buttons=[\n                              Template.ButtonWeb(\"Open Web URL\", \"https://www.oculus.com/en-us/rift/\"),\n                              Template.ButtonPostBack(\"tigger Postback\", \"DEVELOPED_DEFINED_PAYLOAD\"),\n                              Template.ButtonPhoneNumber(\"Call Phone Number\", \"+16505551234\")\n                          ]),\n  Template.GenericElement(\"touch\",\n                          subtitle=\"Your Hands, Now in VR\",\n                          item_url=\"https://www.oculus.com/en-us/touch/\",\n                          image_url=CONFIG['SERVER_URL'] + \"/assets/touch.png\",\n                          buttons=[\n                              Template.ButtonWeb(\"Open Web URL\", \"https://www.oculus.com/en-us/rift/\"),\n                              Template.ButtonPostBack(\"tigger Postback\", \"DEVELOPED_DEFINED_PAYLOAD\"),\n                              Template.ButtonPhoneNumber(\"Call Phone Number\", \"+16505551234\")\n                          ])\n]))\n```\n\n\n##### Template : Receipt\n```python\n    element = Template.ReceiptElement(title=\"Oculus Rift\",\n                                      subtitle=\"Includes: headset, sensor, remote\",\n                                      quantity=1,\n                                      price=599.00,\n                                      currency=\"USD\",\n                                      image_url=CONFIG['SERVER_URL'] + \"/assets/riftsq.png\"\n                                      )\n\n    address = Template.ReceiptAddress(street_1=\"1 Hacker Way\",\n                                      street_2=\"\",\n                                      city=\"Menlo Park\",\n                                      postal_code=\"94025\",\n                                      state=\"CA\",\n                                      country=\"US\")\n\n    summary = Template.ReceiptSummary(subtotal=698.99,\n                                      shipping_cost=20.00,\n                                      total_tax=57.67,\n                                      total_cost=626.66)\n\n    adjustment = Template.ReceiptAdjustment(name=\"New Customer Discount\", amount=-50)\n\n    page.send(recipient_id, Template.Receipt(recipient_name='Peter Chang',\n                                            order_number='1234',\n                                            currency='USD',\n                                            payment_method='Visa 1234',\n                                            timestamp=\"1428444852\",\n                                            elements=[element],\n                                            address=address,\n                                            summary=summary,\n                                            adjustments=[adjustment]))\n```\n### Options\n\n##### notification type\nsupport notification_type as a option\n\n`NotificationType.REGULAR (default)`, `NotificationType.SILENT_PUSH`, `NotificationType.NO_PUSH`\n\n```\npage.send(recipient_id, 'hello', notification_type=NotificationType.NO_PUSH)\n```\n##### callback\nyou can set a callback function to each `page.send`\n```\ndef callback(payload, response):\n  print('response : ' + response.text)\n  \npage.send(recipient_id, 'hello', callback=callback)\n```\n\n# Thread settings\n### Greeting text\n```python\npage.greeting(\"Welcome!\")\n```\n\n### Get started button\n```python\npage.show_starting_button(\"START_PAYLOAD\")\n\n@page.callback(['START_PAYLOAD'])\ndef start_callback(payload, event):\n  print(\"Let's start!\")\n```\n\n### Persistent menu\n```python\npage.show_persistent_menu([Template.ButtonPostBack('MENU1', 'MENU_PAYLOAD/1'),\n                           Template.ButtonPostBack('MENU2', 'MENU_PAYLOAD/2')])\n\n@page.callback(['MENU_PAYLOAD/(.+)'])\ndef click_persistent_menu(payload, event):\n  click_menu = payload.split('/')[1]\n  print(\"you clicked %s menu\" % click_menu)\n```\n\n# Fetch user/page profile\n```\npage_id = page.page_id\npage_name = page.page_name\nuser_profile = page.get_user_profile(event.sender_id) # return dict\nprint(user_profile)\n\n#{\"first_name\":\"...\", \"last_name\":\"...\", \"profile_pic\":\"...\", \"locale\":\"...\", \"timezone\":9, \"gender\":\"...\"}\n```\n\n# Example\n\n1. fill example/config.py\n2. run server\n```bash\ncd example\nvirtualenv env\nsource env/bin/activate\npip install -r requirements.txt\npython server.py\n```\n\n![](./example/assets/screen2.jpg)\n![](./example/assets/screen3.jpg)\n![](./example/assets/screen4.jpg)\n![](./example/assets/screen5.jpg)\n![](./example/assets/screen6.jpg)\n![](./example/assets/screen7.jpg)\n![](./example/assets/screen8.jpg)\n![](./example/assets/screen9.jpg)\n![](./example/assets/screen10.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconbus%2Ffbmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconbus%2Ffbmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconbus%2Ffbmq/lists"}