Skip to main content

A clean Python Wrapper for Facebook Messenger Platform

Project description

Morrison |Build Status|

Python Wrapper for `Facebook Messenger
Platform <>`__.

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


This wrapper has the following functions:

- ``send_text_message(recipient_id, message)``
- ``send_message(recipient_id, message)``
- ``send_generic_message(recipient_id, elements)``
- ``send_button_message(recipient_id, text, buttons)``
- ``send_attachment(recipient_id, attachment_type, attachment_path)``
- ``send_attachment_url(recipient_id, attachment_type, attachment_url)``
- ``send_quick_reply(recipient_id, text, buttons) ``
- ``send_image(recipient_id, image_path)``
- ``send_image_url(recipient_id, image_url)``
- ``send_audio(recipient_id, audio_path)``
- ``send_audio_url(recipient_id, audio_url)``
- ``send_video(recipient_id, video_path)``
- ``send_video_url(recipient_id, video_url)``
- ``send_file(recipient_id, file_path)``
- ``send_file_url(recipient_id, file_url)``
- ``send_action(recipient_id, action)``
- ``send_raw(payload)``
- ``get_user_info(recipient_id)``
- ``send_quick_reply(recipient_id, text, buttons)``

You can see the code/documentation for there in
` <Morrison/>`__.

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

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 <>`__


.. code:: bash

pip install Morrison
pip3 install Morrison


.. code:: python

from import Bot

bot = Bot(<access_token>, [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

If ``app_secret`` is initialized, an app\_secret\_proof 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

.. code:: python

from import Bot
from Morrison import Element
bot = Bot(<access_token>)
elements = []
element = Element(title="test", image_url="<arsenal_logo.png>", subtitle="subtitle", item_url="")

bot.send_generic_message(recipient_id, elements)


.. figure::
:alt: Generic Bot Output

Generic Bot Output

Sending an image/video/file using an URL:

.. code:: python

from import Bot
bot = Bot(<access_token>)
image_url = "http://url/to/image.png"
bot.send_image_url(recipient_id, image_url)


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


.. figure::
:alt: Screenshot of Echo Facebook Bot

Screenshot of Echo Facebook Bot

You can find an example of an Echo Facebook Bot in ``examples/``

.. |Build Status| image::

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Morrison, version 0.9.51
Filename, size File type Python version Upload date Hashes
Filename, size Morrison-0.9.51.tar.gz (7.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page