Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Facebook Chat (Messenger) for Python

Project Description

Facebook Chat (Messenger) for Python. This project was inspired by facebook-chat-api. FBBack (pronunce F-B-Back) was forked from Taehoon Kim (/ @carpedm20)’s fbchat.

No XMPP or API key is needed. Just use your ID and PASSWORD.



$ pip install FBBack


import FBBack

client = FBBack.Client("YOUR_ID", "YOUR_PASSWORD")

Sending a Message

friends = client.getUsers("FRIEND'S NAME")  # return a list of names
friend = friends[0]
sent = client.send(friend.uid, "Your Message")
if sent:
    print("Message sent successfully!")
client.sendLocalImage(friend.uid,message='<message text>',image='<path/to/image/file>') # send local image
imgurl = ""
client.sendRemoteImage(friend.uid,message='<message text>', image=imgurl) # send image from image url

Getting user info from user id

friend1 = client.getUsers('<friend name 1>')[0]
friend2 = client.getUsers('<friend name 2>')[0]
friend1_info = client.getUserInfo(friend1.uid) # returns dict with details
both_info = client.getUserInfo(friend1.uid,friend2.uid) # query both together, returns list of dicts
friend1_name = friend1_info['name']

Getting last messages sent

last_messages = client.getThreadInfo(friend.uid,0)
last_messages.reverse()  # messages come in reversed order

for message in last_messages:

Example Echobot

import FBBack

# Subclass FBBack.Client and override required methods

class EchoBot(FBBack.Client):

    def __init__(self, email, password, debug=True, user_agent=None):
        FBBack.Client.__init__(self, email, password, debug, user_agent)

    def on_message(self, mid, author_id, author_name, message, metadata):
        self.markAsDelivered(author_id, mid) #mark delivered
        self.markAsRead(author_id) #mark read

        print("%s said: %s"%(author_id, message))

        #if you are not the author, echo
        if str(author_id) != str(self.uid):

bot = EchoBot("<email>", "<password>")


Original author: Taehoon Kim / @carpedm20 Frked by: Le Goff Vincent / @vlegoff

Release History

This version
History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(10.8 kB) Copy SHA256 Hash SHA256
Source None Jan 2, 2017

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting