← Open Source
enginebai

PyMessager

Python API to develop chatbot on Facebook Messenger Platform.

AI EngineeringBring agent to usersPython
Open on GitHub
Momentum
+0stars in 24 hours0.0%
606
Stars
125
Forks
+0
This week
5
Contributors
Created 2016-05-14 · Updated 2026-10-02 · #16202 today
Top developers
enginebaiNatLeemattclegg

enginebai/PyMessager is ranked 16,202 with 606 stars.

Same-category comparison

enginebai/PyMessager is ranked 16,202 among these 8 peers; huchenxucs/ChatDB is ranked 16,203.

Same-category comparison
NameRankMetrics
maze-agent/Maze16,177
Language:
Python
Stars:
608
Forks:
26
Description:
A distributed framework for LLM agents.
Pravko-Solutions/FlashLearn16,188
Language:
Python
Stars:
607
Forks:
40
Description:
Integrate LLM in any pipeline - fit/predict pattern, JSON driven flows, and built in concurency support.
anombyte93/prd-taskmaster16,190
Language:
Python
Stars:
607
Forks:
59
Description:
Zero-config goal-to-tasks engine for Claude Code (the Atlas engine). Graded PRD validation, dependency-ordered task graph, evidence-gated execution.
binggandata/bggg-skills16,200
Language:
Python
Stars:
606
Forks:
95
Description:
Open-source Codex skills from BGGG.
huchenxucs/ChatDB16,203
Language:
Python
Stars:
606
Forks:
52
Description:
The official repository of "ChatDB: Augmenting LLMs with Databases as Their Symbolic Memory".
win4r/GraphRAG4OpenWebUI16,212
Language:
Python
Stars:
606
Forks:
123
Description:
GraphRAG4OpenWebUI integrates Microsoft's GraphRAG technology into Open WebUI, providing a versatile information retrieval API. It combines local, global, and web searches for advanced Q&A systems and search engines. This tool simplifies graph-based retrieval integration in open web environments.
craigsc/cmux16,217
Language:
Shell
Stars:
605
Forks:
34
Description:
cmux: tmux for Claude Code.
google-gemini/deprecated-generative-ai-dart16,220
Language:
Dart
Stars:
605
Forks:
140
Description:
This SDK is now deprecated, use the unified Firebase SDK.
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguagePython
CategoryAI Engineering
SubcategoryBring agent to users
KeywordsClient integration
Stars606
Forks125
Contributors5
Created date2016-05-14
Updated date2026-10-02
Stars in 1 day0
Stars in 7 days0
Rank16,202
Previous rank15,992
Rank change-210
7-day stars rank15,401
Previous 7-day stars rank15,409
7-day stars rank change8
Total stars rank16,662
Previous total stars rank16,635
Total stars rank change-27
CountryTaiwan
README summary

PyMessager PyMessager is a Python API for Facebook Messenger and a sample project to demonstrate how to develop a chatbot on Facebook Messenger. Complete tutorials are on Develop a Facebook Bot Using Python and Chatbot: From 0 To 1 where you can find more detailed information to setup and develop. Create a developer application on Facebook for Developers. Start a python project, and install the required packages and modules: Flask, Requests. Use Let's Encrypt to apply SSL certification for your

domain name. Install To install PyMessager, simply run: or install from the repository: Get Started Import Initialization You can initialize a messager client via a Facebook Access Token from the developer console: Receiver APIs The following code is used to build a message receiver, there are three main steps to prepare for your bot: 1. Start the server with https Sender APIs There are several types of message: , , , or . API provides different classes to generate the message template. Sending a

text and image Send a simple text or an image to a recipient, just make sure that image URL is a valid link. Quick Replies The class defines a present buttons to the user in response to a message. To subscribe a page, just call it: Set the welcome message and get-started button The greeting text will show at the first time you open this chatbot on mobile only. The payload is the trigger when the users click "Get

Started" button. Issues Feel free to submit bug reports or feature requests and make sure you read the contribution guideline before opening any issue. Check the open/close issues or open a fresh issue for feature request or bug report with different labels ( / ). Fork this repository on GitHub to start customizing on master or new branch. Write a test which shows that the feature works as expected or the bug was fixed. Send a pull request and wait for code

review.

Frequently asked questions

How many stars and forks are recorded?

enginebai/PyMessager has 606 stars and 125 forks.

What is the repository rank?

enginebai/PyMessager is ranked 16,202.

What language and category are recorded?

enginebai/PyMessager has 606 stars, uses Python and belongs to AI Engineering.

Which repository is closest in rank?

enginebai/PyMessager is compared with huchenxucs/ChatDB, ranked 16,203 with 606 stars.

README

PyMessager

PyMessager is a Python API for Facebook Messenger and a sample project to demonstrate how to develop a chatbot on Facebook Messenger.

Complete tutorials are on Develop a Facebook Bot Using Python and Chatbot: From 0 To 1 where you can find more detailed information to setup and develop.

Before Starting

  1. Prepare a Facebook Page. (to create if you don't have one)
  2. Create a developer application on Facebook for Developers.
  3. Start a python project, and install the required packages and modules: Flask, Requests.
  4. Use Let's Encrypt to apply SSL certification for your domain name.

Install

To install PyMessager, simply run:

$ pip install pymessager

or install from the repository:

$ git clone git@github.com:enginebai/PyMessager.git
$ cd PyMessager
$ pip install -r requirements.txt

Get Started

Import

from pymessager.message import Messager, ... # something else you need

Initialization

You can initialize a messager client via a Facebook Access Token from the developer console:

from pymessager.message import Messager
client = Messager(config.facebook_access_token)

Receiver APIs

The following code is used to build a message receiver, there are three main steps to prepare for your bot:

  1. Setup the Webhook
@app.route(API_ROOT + FB_WEBHOOK, methods=["GET"])
def fb_webhook():
    verification_code = 'I_AM_VERIFICIATION_CODE'
    verify_token = request.args.get('hub.verify_token')
    if verification_code == verify_token:
        return request.args.get('hub.challenge')
  1. Receive the message
@app.route(API_ROOT + FB_WEBHOOK, methods=['POST'])
def fb_receive_message():
    message_entries = json.loads(request.data.decode('utf8'))['entry']
    for entry in message_entries:
        for message in entry['messaging']:
            if message.get('message'):
                print("{sender[id]} says {message[text]}".format(**message))
    return "Hi"
  1. Start the server with https
if __name__ == '__main__':
    context = ('ssl/fullchain.pem', 'ssl/privkey.pem')
    app.run(host='0.0.0.0', debug=True, ssl_context=context)

Sender APIs

There are several types of message: text, image, quick replies, button template or generic template. API provides different classes to generate the message template.

Sending a text and image

Send a simple text or an image to a recipient, just make sure that image URL is a valid link.

client.send_text(user_id, "Hello, I'm enginebai.")
client.send_image(user_id, "http://image-url.jpg")

Quick Replies

The QuickReply(title, payload, image_url, content_type) class defines a present buttons to the user in response to a message.

Parameter Description Required
title The button title Y
payload The click payload string Y
image_url The icon image URL N
content_type TEXT or LOCATION Y
client.send_quick_replies(user_id, "Help", [
         QuickReply("Projects", Intent.PROJECT),
         QuickReply("Blog", Intent.BLOG),
         QuickReply("Contact Me", Intent.CONTACT_ME)
     ])

Button Template

The ActionButton(button_type, title, url, payload) class defines button template which contains a text and buttons attachment to request input from the user.

Parameter Description Required
button_type WEB_URL or POSTBACK Y
title The button title Y
url The link Only if button_type is url
payload The click payload string Only if button_type is POSTBACK
client.send_buttons(user_id, "You can find me with below", [
    ActionButton(ButtonType.WEB_URL, "Blog", "http://blog.enginebai.com"),
	ActionButton(ButtonType.POSTBACK, "Email", Intent.EMAIL)
])

Generic Template

The GenericElement(title, subtitle, image_url, buttons) class defines a horizontal scrollable carousel of items, each composed of an image attachment, short description and buttons to request input from the user.

Parameter Description Required
title_text The message main title Y
subtitle_text The message subtitle, leave it empty if you don't need it N
button_list The list of ActionButton Y
project_list = []
for project_id, project in projects.items():
    project_list.append(GenericElement(
        project["title"],
        project["description"],
        config.api_root + project["image_url"], [
            ActionButton(ButtonType.POSTBACK,
                         self._get_string("button_more"),
                         # Payload use Intent for the beginning
                         payload=Intent.PROJECTS.name + project_id)
        ]))
client.send_generic(user_id, project_list)

Utility APIs

Subscribe the pages

Before your chatbot starts to receive messages, you have to subscribe the application to your chatbot page. To subscribe a page, just call it:

client.subscribe_to_page()

Set the welcome message and get-started button

The greeting text will show at the first time you open this chatbot on mobile only. The payload is the trigger when the users click "Get Started" button.

client.set_greeting_text("Hi, this is Engine Bai. Nice to meet you!")
client.set_get_started_button_payload("HELP")  # Specify a payload string.

Issues

Feel free to submit bug reports or feature requests and make sure you read the contribution guideline before opening any issue.

Contributing

  1. Check the open/close issues or open a fresh issue for feature request or bug report with different labels (feature/bug).
  2. Fork this repository on GitHub to start customizing on master or new branch.
  3. Write a test which shows that the feature works as expected or the bug was fixed.
  4. Send a pull request and wait for code review.

Read more on contributing.

License

The MIT License (MIT)

Copyright © 2017 Engine Bai.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Nearby in the ranking
Similar items