Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geeknam/messengerbot
Python client for Facebook Messenger Platform Bot
https://github.com/geeknam/messengerbot
facebook messenger messenger-bot python
Last synced: 3 months ago
JSON representation
Python client for Facebook Messenger Platform Bot
- Host: GitHub
- URL: https://github.com/geeknam/messengerbot
- Owner: geeknam
- Created: 2016-04-16T04:33:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-12T08:36:52.000Z (over 7 years ago)
- Last Synced: 2024-04-16T18:34:31.435Z (7 months ago)
- Topics: facebook, messenger, messenger-bot, python
- Language: Python
- Size: 31.3 KB
- Stars: 145
- Watchers: 15
- Forks: 51
- Open Issues: 6
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
- starred-awesome - messengerbot - Python client for Facebook Messenger Platform Bot (Python)
README
messengerbot
======================.. image:: https://img.shields.io/pypi/v/messengerbot.svg
:target: https://pypi.python.org/pypi/messengerbot
.. image:: https://img.shields.io/pypi/dm/messengerbot.svg
:target: https://pypi.python.org/pypi/messengerbot
.. image:: https://secure.travis-ci.org/geeknam/messengerbot.png?branch=master
:alt: Build Status
:target: http://travis-ci.org/geeknam/messengerbot
.. image:: https://landscape.io/github/geeknam/messengerbot/master/landscape.svg?style=flat
:target: https://landscape.io/github/geeknam/messengerbot/master
:alt: Code Health
.. image:: https://coveralls.io/repos/github/geeknam/messengerbot/badge.svg?branch=master
:target: https://coveralls.io/github/geeknam/messengerbot?branch=master
.. image:: https://img.shields.io/gratipay/geeknam.svg
:target: https://gratipay.com/geeknam/Python client for Messenger Platform API
Installation
-------------.. code-block:: bash
pip install messengerbot
Usage
------------Read about `Messenger Platform `__
.. code-block:: python
from messengerbot import MessengerClient, messages, attachments, templates, elements
# Manually initialize client
messenger = MessengerClient(access_token='your_token')# With env var export MESSENGER_PLATFORM_ACCESS_TOKEN=your_token
from messengerbot import messengerrecipient = messages.Recipient(recipient_id='123')
# Send text message
message = messages.Message(text='Hello World')
request = messages.MessageRequest(recipient, message)
messenger.send(request)# Send button template
web_button = elements.WebUrlButton(
title='Show website',
url='https://petersapparel.parseapp.com'
)
postback_button = elements.PostbackButton(
title='Start chatting',
payload='USER_DEFINED_PAYLOAD'
)
template = templates.ButtonTemplate(
text='What do you want to do next?',
buttons=[
web_button, postback_button
]
)
attachment = attachments.TemplateAttachment(template=template)message = messages.Message(attachment=attachment)
request = messages.MessageRequest(recipient, message)
messenger.send(request)