Python/Django Wrapper for Facebook Messenger Bot Platform.
Project description
FBBOTW: A Facebook Messenger Platform API Wrapper
This wrapper makes it simpler to user the Facebook Messenger platform wrapping the endpoints as functions.
For exemple, to send a text message to the user you can easily do:
from fbbotw import fbbotw
# ...
user_fbid = "<user fb id>"
my_message = "Hello World"
fbbotw.post_text_message(fbid=user_fbid, message=my_message)
# The user with the specified fbid will receive the text 'Hello World'
This is much less code than the traditional way to call the Send API and send a text. Using requests and json you probably would do like this:
fbid = "<user psid>"
message = "Hello World"
url = 'https://graph.facebook.com/v2.6/me/messages?access_token={0}'
url = url.format(PAGE_ACCESS_TOKEN)
header = {"Content-Type": "application/json"}
payload = {}
payload['recipient'] = {'id': fbid}
payload['message'] = {'text': message}
data = json.dumps(payload)
response = requests.post(url=url, headers=header, data=data)
Learn more about the fbbotw methods by reading the DOCS
Get Started
1- Install
pip install fbbotw
2 - Configure it
The only configuration needed is to set the PAGE_ACCESS_TOKEN with
the value you got from the facebook app dashboard. If you are using Django, create the variable in your settings.py. If not, define the variable in your enviroment:
2.1 - Django
1 - In your settings.py define the variable PAGE_ACCESS_TOKEN that was
generated on the app configuration from facebook.
#settings.py
PAGE_ACCESS_TOKEN = "<your access token>"
2.2 - Not Django
Create an os environment variable called PAGE_ACCESS_TOKEN:
export PAGE_ACCESS_TOKEN='<your access token>'
3 - Import and Use it
After setting the access token, just import and use fbbotw methods:
from fbbotw import fbbotw
fbbotw.post_sender_action(fbid="<user psid>", sender_action="typing_on")
See the documentation to learn about the methods provided by the package.
Documentation
Current wrapper covering for the Menssenger Platform 2.0
- Send API
- Content Types
- Quick Replies
- Sender Actions
- Attachment Upload API
- Templates
- Button Template
- Generic Template
- List Template
- Receipt Template
- Media Template
- Open Graph Template
- Airline Boarding Pass Template
- Airline Checkin Template
- Airline Itinerary Template
- Airline Flight Update Template
- Buttons: Check documentation to format your buttons in your templates
- Miscellaneous
- User profile
- Messenger Profile API
- Plugin Reference
- Messenger Code API
- Messaging Insights API
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fbbotw-2.2.1.tar.gz.
File metadata
- Download URL: fbbotw-2.2.1.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.11.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92650c9caa256a51014537b3d96e07dd15f7c07d6a53c6330bf11fc7997d40f0
|
|
| MD5 |
a351ee4c46ec51b69f26fb81eca52561
|
|
| BLAKE2b-256 |
0fbfdf4a0a1de6d8a5d6779ce6fd6cbe4e78a1e7b8563e90786251b7d9fd75df
|
File details
Details for the file fbbotw-2.2.1-py2.py3-none-any.whl.
File metadata
- Download URL: fbbotw-2.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.11.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0a89ee56e3e08842dad26f939c1c4fdb154154fc6e2ad1c036f85d0b608b192
|
|
| MD5 |
1cb3e1449be4bda7e497968375dd6363
|
|
| BLAKE2b-256 |
32e901d71f1c2321dda2f9a516fe3722425c526469d3aa8d1cd4229d827a9766
|