MessengerFlow

Webhooks

Receive real-time HTTP notifications when events occur in MessengerFlow.

Webhooks

Webhooks are available on the Momentum plan and above.

Webhooks deliver real-time HTTP POST requests to your server whenever something happens in MessengerFlow — a message is sent, a lead replies, a campaign finishes, or an account status changes.

How It Works

  1. You register an HTTPS endpoint and choose which events to subscribe to
  2. When a subscribed event occurs, MessengerFlow sends a signed HTTP POST to your endpoint
  3. Your server verifies the signature, processes the payload, and returns a 2xx response
  4. If delivery fails, the system tries again with growing delays, up to 5 attempts in total

Setting Up

Register an endpoint

  1. Go to Settings > Developers > Webhooks
  2. Click Add Endpoint
  3. Enter your HTTPS URL
  4. Select the events you want to receive
  5. Click Create
  6. Copy the signing secret. It is shown only once and cannot be retrieved later

If you lose the secret, open the endpoint and click Rotate secret to get a new one. Deliveries are signed with the new secret straight away, so update your receiver at the same time.

You can also register endpoints programmatically via the API.

Endpoint requirements

Your endpoint must:

  • Be accessible over HTTPS (HTTP is not accepted)
  • Accept POST requests with a JSON body
  • Return a 2xx status code within 10 seconds
  • Be idempotent — the same event may be delivered more than once in rare cases

Events

Message events

EventTrigger
message.sentA campaign's opening message was sent to a lead
message.failedA campaign's opening message could not be sent

These two events cover the text messages of a campaign's opening sequence. Follow-ups, voice and video messages, and replies you send from the inbox do not emit them.

Conversation events

EventTrigger
conversation.createdA new conversation was detected during inbox sync
conversation.replyA lead's message is the newest in a conversation at inbox sync
conversation.bookedA conversation was marked as booked in the app or via API

A lead's first reply emits both conversation.created and conversation.reply. Subscribe to conversation.reply to receive every reply with its text.

Replies are detected when an account's inbox is synced, not the moment they arrive on Facebook. During the day syncs run roughly every 20 minutes to 3 hours, depending on how active the account is. They pause overnight.

Account events

EventTrigger
account.status_changedAn account status flag changed (suspended, rate limited, invalid credentials, flagged, etc.)

Campaign events

EventTrigger
campaign.completedAll leads in a campaign have been processed

Payload Format

Every webhook delivery is a JSON POST with this structure:

{
  "event": "event.type",
  "timestamp": "2026-02-10T14:30:00.000Z",
  "data": { }
}
FieldTypeDescription
eventstringThe event type that triggered this delivery
timestampstringISO 8601 timestamp of when the event occurred
dataobjectEvent-specific payload (see below)

message.sent

{
  "event": "message.sent",
  "timestamp": "2026-02-10T14:30:00.000Z",
  "data": {
    "campaign_id": "a1b2c3d4-...",
    "lead_id": "e5f6a7b8-...",
    "account_id": "c9d0e1f2-...",
    "message": "Hey John, I noticed your page and wanted to reach out..."
  }
}

message.failed

{
  "event": "message.failed",
  "timestamp": "2026-02-10T14:30:00.000Z",
  "data": {
    "campaign_id": "a1b2c3d4-...",
    "lead_id": "e5f6a7b8-...",
    "account_id": "c9d0e1f2-...",
    "error": "Account rate limited by Facebook"
  }
}

conversation.created

{
  "event": "conversation.created",
  "timestamp": "2026-02-10T14:30:00.000Z",
  "data": {
    "conversation_id": "6f1c2d3e-...",
    "account_id": "c9d0e1f2-...",
    "recipient_id": "100001234567890"
  }
}

conversation.reply

{
  "event": "conversation.reply",
  "timestamp": "2026-02-10T14:30:00.000Z",
  "data": {
    "conversation_id": "6f1c2d3e-...",
    "account_id": "c9d0e1f2-...",
    "recipient_id": "100001234567890",
    "message": "Hi! Yes, I'd love to learn more."
  }
}

conversation.booked

{
  "event": "conversation.booked",
  "timestamp": "2026-02-10T14:30:00.000Z",
  "data": {
    "conversation_id": "uuid",
    "booked_at": "2026-02-15T10:00:00.000Z"
  }
}

account.status_changed

Fired when any account status flag is modified, either by the automation worker or manually through the app.

{
  "event": "account.status_changed",
  "timestamp": "2026-02-10T14:30:00.000Z",
  "data": {
    "account_id": "c9d0e1f2-...",
    "email": "[email protected]",
    "field": "banned",
    "value": true
  }
}

The field indicates which status changed. Possible values:

FieldMeaning
bannedAccount suspended by Facebook
rate_limited_untilRate limit applied. value is the length of the pause in seconds
invalid_credentialsPassword no longer valid
invalid_2fa2FA secret incorrect
errorGeneric error flag
unsupported_auth_flowFacebook asked for a sign-in step we cannot do
identity_requiredFacebook is asking the account to confirm its identity
wrong_languageThe account's Facebook language is not English
flaggedThe account was paused after repeated send failures
requires_pinAccount needs PIN verification
enabledAccount enabled or disabled by user

For every field except rate_limited_until, value is true when the flag is set and false when it is cleared.

campaign.completed

{
  "event": "campaign.completed",
  "timestamp": "2026-02-10T14:30:00.000Z",
  "data": {
    "campaign_id": "a1b2c3d4-...",
    "name": "Q1 Outreach"
  }
}

Signature Verification

Every delivery includes headers that let you verify the request is genuinely from MessengerFlow:

HeaderDescription
X-MessengerFlow-EventEvent type (e.g. message.sent)
X-MessengerFlow-SignatureHMAC signature: sha256=<hex>
X-MessengerFlow-DeliveryUnique delivery ID (use for idempotency)
X-MessengerFlow-TimestampUnix timestamp of the request

The signature is computed as:

HMAC-SHA256(signing_secret, timestamp + "." + raw_request_body)

Verify against the raw bytes of the request body, exactly as received. Do not parse the JSON and serialize it again: spacing, key order and escaping of non-English characters will differ from what was signed, and the check will fail. Parse the body only after the signature matches.

Node.js example

const crypto = require('crypto');
const express = require('express');

const app = express();

function verifySignature(secret, timestamp, rawBody, signature) {
  const expected = 'sha256=' + crypto
    .createHmac('sha256', secret)
    .update(`${timestamp}.`)
    .update(rawBody)
    .digest('hex');
  const a = Buffer.from(expected);
  const b = Buffer.from(signature || '');
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

app.post(
  '/webhooks/messengerflow',
  express.raw({ type: 'application/json' }),
  (req, res) => {
    const signature = req.headers['x-messengerflow-signature'];
    const timestamp = req.headers['x-messengerflow-timestamp'];
    const rawBody = req.body;

    if (!verifySignature(process.env.WEBHOOK_SECRET, timestamp, rawBody, signature)) {
      return res.status(401).send('Invalid signature');
    }

    const { event, data } = JSON.parse(rawBody.toString('utf8'));

    switch (event) {
      case 'message.sent':
        console.log(`Message delivered to lead ${data.lead_id}`);
        break;
      case 'conversation.reply':
        console.log(`New reply from ${data.recipient_id}: ${data.message}`);
        break;
      case 'conversation.booked':
        // Push to your CRM
        break;
    }

    res.status(200).send('OK');
  }
);

express.raw keeps the body as a Buffer for this route. If your app uses express.json() globally, register this route before it, or the body will already be parsed.

Python example

import hmac
import hashlib
from flask import Flask, request, abort

app = Flask(__name__)
WEBHOOK_SECRET = "your_signing_secret"

def verify_signature(secret, timestamp, raw_body, signature):
    expected = hmac.new(
        secret.encode(),
        timestamp.encode() + b"." + raw_body,
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(signature, f"sha256={expected}")

@app.route("/webhooks/messengerflow", methods=["POST"])
def handle_webhook():
    signature = request.headers.get("X-MessengerFlow-Signature", "")
    timestamp = request.headers.get("X-MessengerFlow-Timestamp", "")
    raw_body = request.get_data()

    if not verify_signature(WEBHOOK_SECRET, timestamp, raw_body, signature):
        abort(401)

    payload = request.get_json()
    event = payload["event"]
    data = payload["data"]

    if event == "conversation.reply":
        print(f"New reply from {data['recipient_id']}")
    elif event == "conversation.booked":
        # Push to your CRM
        pass

    return "OK", 200

Retry Logic

When a delivery fails (non-2xx response or timeout), the system tries again with increasing delays. A delivery gets up to 5 attempts:

AttemptWhen
1At once
21 minute after the first failure
35 minutes after the second
430 minutes after the third
52 hours after the fourth

If the fifth attempt fails, about 2 hours and 36 minutes after the first, the delivery is marked as failed and the endpoint's failure counter goes up by one. Any successful delivery resets the counter.

Auto-disable: If 5 deliveries in a row fail on every attempt, the endpoint is switched off. You get an email and a notification in the app. Events that happen while the endpoint is off are not queued and are not sent later. After fixing the issue, switch the endpoint back on from its page in Settings > Developers > Webhooks.

The endpoint's page lists recent deliveries with the response code, the number of attempts and, for a failed delivery, the start of your server's response or the connection error.

Testing

Every endpoint has a Send Test button that delivers a ping event with a valid HMAC signature. Use it to confirm:

  • Your endpoint is publicly reachable
  • HTTPS is working correctly
  • Signature verification passes
  • Your server returns a 2xx response

You can also send a test via the API.

Best Practices

  1. Return 200 immediately — acknowledge receipt before doing any heavy processing. Queue the payload for async handling in your application.
  2. Verify every signature — always validate the HMAC to confirm the request is from MessengerFlow, not a malicious third party.
  3. Use the delivery ID for idempotency — in rare cases, the same event may be delivered more than once. Use the X-MessengerFlow-Delivery header to deduplicate.
  4. Monitor your endpoint health — check the delivery history in Settings > Developers > Webhooks to catch failures early. Repeated failures will auto-disable your endpoint.
  5. Keep your endpoint fast — responses must arrive within 10 seconds. If processing takes longer, store the payload and handle it asynchronously.
  6. Log raw payloads — during development, log the full request body and headers for debugging. This helps diagnose signature verification issues.

Troubleshooting

Endpoint not receiving events

  • Verify the URL is publicly accessible (not localhost or behind a firewall)
  • Confirm HTTPS is configured correctly with a valid certificate
  • Check that the endpoint is enabled and not auto-disabled
  • Ensure you're subscribed to the correct events

Signature verification failing

  • Make sure you're hashing the raw request body bytes, not a parsed and re-serialized version. Send Test can pass with re-serialized JSON while real events fail, because real payloads are serialized differently
  • Verify the signing secret matches what was shown at endpoint creation or at the last rotation
  • Check that the timestamp header is included in the HMAC computation
  • Ensure you're comparing the full sha256=<hex> prefix

Endpoint auto-disabled

Five deliveries in a row failed on every attempt. You were sent an email and a notification when this happened. To recover:

  1. Check your server logs for the root cause
  2. Fix the issue (server error, timeout, certificate problem, etc.)
  3. Go to Settings > Developers > Webhooks
  4. Click into the endpoint and re-enable it
  5. Use Send Test to confirm it's working before live events resume

Events arriving late

  • Worker-originated events (messages, conversations) are delivered on a 10-second polling cycle
  • If previous deliveries are in retry backoff, new events queue behind them
  • Check the delivery history to see if earlier failures are causing delays