Need help with pymessenger?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

442 Stars 180 Forks MIT License 91 Commits 46 Opened issues


A Python Wrapper for the FB Messenger Bot API (Send/Receive API)

Services available


Need anything else?

Contributors list

pymessenger Build Status

Python Wrapper for Facebook Messenger Platform.

Disclaimer: This wrapper is NOT an official wrapper and do not attempt to represent Facebook in anyway.


This wrapper has the following functions:

  • sendtextmessage(recipient_id, message)
  • sendmessage(recipientid, message)
  • sendgenericmessage(recipient_id, elements)
  • sendbuttonmessage(recipient_id, text, buttons)
  • sendattachment(recipientid, attachmenttype, attachmentpath)
  • sendattachmenturl(recipientid, attachmenttype, attachment_url)
  • sendimage(recipientid, image_path)
  • sendimageurl(recipientid, imageurl)
  • sendaudio(recipientid, audio_path)
  • sendaudiourl(recipientid, audiourl)
  • sendvideo(recipientid, video_path)
  • sendvideourl(recipientid, videourl)
  • sendfile(recipientid, file_path)
  • sendfileurl(recipientid, fileurl)
  • sendaction(recipientid, action)
  • send_raw(payload)
  • getuserinfo(recipient_id)
  • setgetstarted(gs_obj)
  • setpersistentmenu(pm_obj)
  • removegetstarted()
  • removepersistentmenu()

You can see the code/documentation for there in

The functions return the full JSON body of the actual API call to Facebook.

Register for an Access Token

You'll need to setup a Facebook App, Facebook Page, get the Page Access Token and link the App to the Page before you can really start to use the Send/Receive service.

This quickstart guide should help


pip install pymessenger


from import Bot

bot = Bot(, [optional: app_secret]) bot.send_text_message(recipient_id, message)

Note: From Facebook regarding User IDs

These ids are page-scoped. These ids differ from those returned from Facebook Login apps which are app-scoped. You must use ids retrieved from a Messenger integration for this page in order to function properly.


is initialized, an appsecretproof will be generated and send with every request. Appsecret Proofs helps further secure your client access tokens. You can find out more on the Facebook Docs
Sending a generic template message:

Generic Template Messages allows you to add cool elements like images, text all in a single bubble.

from import Bot
bot = Bot()
elements = []
element = Element(title="test", image_url="", subtitle="subtitle", item_url="")

bot.send_generic_message(recipient_id, elements) </arsenal_logo.png>


Generic Bot Output

Sending an image/video/file using an URL:
from import Bot
bot = Bot()
image_url = "http://url/to/image.png"
bot.send_image_url(recipient_id, image_url)


  • Structured Messages
  • Receipt Messages
  • Quick Replies
  • Airlines
  • Tests!


Screenshot of Echo Facebook Bot

You can find an example of an Echo Facebook Bot in


We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.