Skip to content
Python client for Facebook Messenger Platform Bot
Branch: master
Clone or download
geeknam Merge pull request #17 from navyad/navyad/patch-2
Attachment cannot be instantiated
Latest commit 56c8715 Jan 12, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
messengerbot Merge pull request #17 from navyad/navyad/patch-2 Jan 12, 2017
tests Merge pull request #17 from navyad/navyad/patch-2 Jan 12, 2017
.gitignore Updated gitignore to exclude pycharm files Nov 29, 2016
.travis.yml Only cover messengerbot package May 1, 2016
README.rst typo fix Aug 18, 2016
setup.py Bump to 0.1.4 May 1, 2016

README.rst

messengerbot

Build Status Code Health https://coveralls.io/repos/github/geeknam/messengerbot/badge.svg?branch=master

Python client for Messenger Platform API

Installation

pip install messengerbot

Usage

Read about Messenger Platform

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 messenger

recipient = 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)
You can’t perform that action at this time.