Fbchat V2

About Facebook Chat (Messenger) for Python / Message Listening for E2EE (end-to-end)

Last verified:

Visit Fbchat V2

What is Fbchat V2?

Fbchat V2 is an open-source Python library for automating Facebook Messenger conversations, managing group threads, and listening to real-time Messenger events without requiring the Graph API. Unlike the official Graph API which is limited to fanpages, Fbchat V2 integrates deeply via personal user accounts, enabling full control over Messenger functionality.

Key features include built-in end-to-end encryption (E2EE) support for Secret Conversations since March 2026 via a Go bridge based on Signal Protocol, allowing users to read and send both 1-on-1 and group E2EE messages. The library supports sending text and attachments, reacting to messages, unsending messages, MQTT WebSocket real-time listening, blocking/unblocking users, searching users, managing group chat settings (nicknames, emojis, admin roles), and fetching notifications and user info.

The project follows a three-layer architecture (_core for session/auth, _features for profile/thread operations, _messaging for message transport) for maintainability. Authentication can be done via cookies (recommended) or username/password with 2FA support. It requires Python 3.10 or newer and Go 1.24+ for the E2EE bridge.

Fbchat V2 is designed for developers building chatbots, automation tools, and Messenger message listeners who need E2EE capabilities. It is particularly useful for those who need to work around Facebook's API limitations and want来控制 personal account messaging programmatically.

Fbchat V2 pricing

Pricing model: Freemium

Free and open-source. No paid tiers. The library is completely free to use with no subscription required. Users only need their own Facebook account and to install Python 3.10+ and Go 1.24+ for E2EE support.

Fbchat V2 pros

  • Open-source and free to use
  • No Graph API required
  • Deep integration via personal user accounts
  • Built-in end-to-end encryption support for Secret Conversations
  • Supports both 1-on-1 and group E2EE messages
  • Real-time MQTT WebSocket event listening
  • Three-layer architecture for easy maintenance
  • Supports cookie and username/password authentication with 2FA
  • Can send text and attachments (images, files)
  • Group management features (nicknames, emojis, admin roles)
  • User blocking and unblocking functionality
  • Message reaction and unsend support
  • Fetches notifications and user info by ID
  • Bridge crash doesn't crash main Python process
  • Active development with 4+ years of history

Fbchat V2 cons

  • Requires Go 1.24+ to build E2EE bridge binary
  • E2EE pairing must be repeated on each run unless device_path is set
  • Username/password auth is checkpoint-prone on Facebook
  • Not pure Python - relies on Go bridge for crypto
  • Binary must be built manually before first E2EE use
  • Unofficial API - risk of Facebook account ban
  • Steep learning curve for E2EE setup
  • Documentation primarily in Vietnamese with some English

Frequently asked questions about Fbchat V2

Why is fbchat-v2 not pure Python?

The crypto stack for E2EE includes approximately 100k lines of Go code covering Signal Protocol, Noise XX handshake, and ~80 Meta-specific protobuf message types. Python equivalents like python-axolotl and dissononce have been unmaintained since 2019. Re-implementing them in Python would create security and maintenance risks whenever Meta changes the protocol.

What happens if the E2EE bridge crashes?

Because the bridge runs as a subprocess, a bridge crash will not cause the Python process to crash. You simply need to respawn it using Popen. You can also override the binary path using the FBCHAT_E2EE_BIN environment variable.

How do I authenticate with Facebook?

You can use cookies (recommended) or username/password. For cookies, set the c_user, xs, fr, and datr values and pass them to dataGetHome(). For username/password, use loginFacebook() which supports 2FA codes, but be aware this method is more prone to Facebook checkpoints.

What is the three-layer architecture?

The project is split into three layers: _core handles session, payload, and authentication (no end-user messaging logic); _features handles profile and thread business operations like avatar changes, blocking, group setup; _messaging handles message transport, MQTT, and attachments.

How do I persist E2EE keys across sessions?

By default e2ee_memory_only=True means pairing is repeated each run. To persist session keys, pass device_path='./device.json' and set e2ee_memory_only=False when creating the listeningE2EEEvent listener.

What events does the E2EE bridge emit?

The bridge emits: ready (socket ready), e2eeConnected (E2EE paired), message (regular MQTT message), e2eeMessage (decrypted E2EE message), reaction/e2eeReaction (emoji add/remove), messageEdit/messageUnsend (edit/unsend), typing/readReceipt (typing indicator/read receipt), and disconnected/error (bridge dropped or error).

Can I send attachments with fbchat-v2?

Yes. Use _attachments.func() to upload a file and get an attachment ID, then pass that ID along with typeAttachment='image' (or other types) to the send() function in _messaging._send.api().

What Python version is required?

Python 3.10 or newer is required to run fbchat-v2.

How do I listen to messages in real-time?

Use listeningEvent() from _messaging._listening for regular messages or listeningE2EEEvent() from _messaging._listening_e2ee for E2EE messages. Call get_last_seq_id() then connect_mqtt(). Run MQTT in a dedicated thread using paho-mqtt to avoid blocking.

What group management features are available?

fbchat-v2 supports changing group emoji (_changeEmoji), setting member nicknames (_changeNickname), renaming group chats (_changeNameThread), granting or revoking admin roles (_addAdmin), and fetching metadata from recent threads (_all_thread_data).

Categories

Use cases

Browse all AI tools on NeedAnAI