Skip to main content

Python/Django Wrapper for Facebook Messenger Bot Platform.

Project description

FBBOTW: A Facebook Bot Wrapper

Python Wrapper for Facebook Messenger Bot Platform.

MIT licensed PyPI Documentation Status Build Status

This bot makes it simpler to user the Facebook messenger bot platform wrapping the endpoints as functions.

For example, this would be the normal way you probably would call the Send API to send a text:
(Using requests and json)
fbid = "<user fb id>"
message = "Hello World"
url = 'https://graph.facebook.com/v2.6/me/messages?access_token='
url += PAGE_ACCESS_TOKEN
header = {"Content-Type": "application/json"}
payload = {}
payload['recipient'] = {'id': fbid}
payload['message'] = {'text': message} # Limit 320 chars
data = json.dumps(payload)
status = requests.post(url, headers=header, data=data)

Using fbbotw you would easily write

from fbbotw import fbbotw
# ...


fbid = "<user fb id>"
message = "Hello World"

fbbotw.post_text_message(fbid, message)

Install

pip install fbbotw

Using with Django

1 - In your global settings define the variable PAGE_ACCESS_TOKEN that is
your access token generated on the app configuration from facebook.
#settings.py
PAGE_ACCESS_TOKEN = "<your access token>"

or create environment variable with the same name:

export PAGE_ACCESS_TOKEN='<your access token>'

2 - To use the functions of this wrapper do:

from fbbotw import fbbotw

fbbotw.typing(fbid, "typing_on")

If you want to use this package without Django

  1. Download the .zip of this directory.

  2. Copy the fbbotw directory to your project root.

  3. Define a variable called PAGE_ACCESS_TOKEN as the page access token you got from facebook

  4. Import the package in your module.

from fbbotw import fbbotw

fbbotw.typing(fbid, "typing_on")

Documentation

Current wrapper covering for the Menssenger Platform (78%)

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

fbbotw-1.0.0.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distribution

fbbotw-1.0.0-py2.py3-none-any.whl (10.3 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page