Skip to content
Vendrix
← Back to blog

How to Automate Facebook Messenger Replies

To automate replies to a Facebook Page with your own software, the basic flow is: Meta sends new messages to your server through a webhook; your app applies rules or checks a trusted source; then it replies through the Messenger Platform Send API usi

Vendrix · · 7 min

How to Automate Facebook Messenger Replies

To automate replies to a Facebook Page with your own software, the basic flow is: Meta sends new messages to your server through a webhook; your app applies rules or checks a trusted source; then it replies through the Messenger Platform Send API using the person’s PSID. You need authorized Page access, Meta permissions, a webhook setup, and compliance with messaging windows.

An automated reply should be limited to what your system can verify. If the answer is missing, the request is sensitive, or the person asks for a human, route it to support instead of inventing certainty.

What the API does

The Messenger Platform API lets an authorized app receive Page events and send replies. It does not replace the Facebook app or automatically grant access to every Page. The Page must be connected to the app, the authorizing person must have the relevant messaging task, and the app must obtain the required permissions.

This guide covers private messages sent to a Facebook Page. Comment replies, Instagram API, sponsored marketing messages, and WhatsApp have separate rules and endpoints. Do not assume a Messenger flow applies to every channel.

Check Page access and permissions

For sending Messenger messages as a Page, Meta references specify:

- A Page access token issued through a person with the MESSAGING task on the Page.

- The pages_messaging permission for messaging.

- Depending on management and reading operations, other permissions Meta lists, such as pages_manage_metadata and pages_read_engagement.

- A Page webhook subscription and installation of the app on that Page.

In development mode or with Standard Access, interactions may be limited to people with an Administrator, Developer, or Tester role on the app. To serve other people, follow the app review process and obtain Advanced Access for the required permissions. Check the app dashboard for the actual review state; an internal test does not prove public access.

A Page token is a secret. Store it in a secrets manager or protected server environment. Never put it in the browser, a screenshot, logs, or Git.

Understand messaging windows

The baseline is a 24-hour standard messaging window after a relevant person-to-Page interaction. Messages inside the window must remain related to the conversation and follow Meta policies.

Messenger documentation reviewed here describes an exception for some conversations that start from Click-to-Messenger ads: the standard window may extend up to seven days from the person’s first message after clicking the ad. This does not apply to every conversation. Do not assume a person who wrote yesterday can still receive an automated reply today. Consider the conversation entry point and recheck the current rules.

Outside the standard window, a tagged message is allowed only for a documented, relevant, non-promotional use case. Rules and tags change. Meta announced that several legacy Messenger tags, including CONFIRMED_EVENT_UPDATE, ACCOUNT_UPDATE, and POST_PURCHASE_UPDATE, would return an error starting April 27, 2026. Do not copy older examples without checking current tag availability and policy.

The HUMAN_AGENT tag is for an actual business representative to manually reply to a request within seven days of the person’s last message. Before using it, request and obtain the required Human Agent permission or feature access in Meta’s app dashboard, then verify its current status. It must not extend automated conversations, send promotions, or bypass the window. A human handoff and the Human Agent tag solve different problems: one transfers conversation ownership, while the other governs an eligible manual message outside the window.

Step 1: create an app and configure a webhook

Create a Meta app for Messenger Platform, connect the Page to the use case, then configure the Page object and messages field under Webhooks. Meta says the app must also be installed on the Page for notifications to be delivered.

Your endpoint must be publicly reachable over HTTPS. For initial verification, Meta sends a GET request with mode, challenge, and verify-token parameters. Compare the received token with the value stored on your server, and return the challenge only when it matches.

For POST requests, validate X-Hub-Signature-256 using the app secret and the original body bytes. Verify the signature before interpreting the JSON. Persist the event, respond promptly, and handle repeat events and requests containing multiple entries.

A webhook is not an application’s own durable queue. In production, store the event before slow processing, deduplicate with an event or message identifier, and track errors without exposing private conversation content. Return HTTP 200 after durable persistence. Meta’s general webhook documentation says Messenger retry frequency differs from other webhooks, so do not assume a fixed retry count or schedule. If a Send API POST times out without a response, treat the result as uncertain and reconcile it before retrying: the first request may have been accepted. The documentation reviewed does not describe an idempotency key for sending, so avoid a blind retry that could create a duplicate reply.

Step 2: process a new message predictably

A message event generally contains the Page ID, sender ID, and message content or type. To reply, Messenger uses a Page-scoped ID (PSID) for that Page; an ID from a Facebook Login integration may not work.

A predictable flow can follow these rules:

1. Verify the webhook signature.

2. Ignore echo events for messages sent by the business to prevent loops.

3. Deduplicate the message ID.

4. Confirm the event belongs to the authorized Page.

5. Answer only requests that can be resolved unambiguously, such as opening hours from a current source.

6. If the answer cannot be verified or the person requests a human, create a support task and transfer control.

7. Send a reply only when messaging rules and permissions allow it.

8. Store the message ID returned by the API and later delivery status from webhooks.

Do not use a language model to invent price, stock, order status, or policy. Connect it to controlled data, flag answers that require verification, and provide an exit to a human.

Example: send a reply through the API

A basic text reply to someone who just messaged the Page uses the Page Send API, the PSID from the webhook, and a Page token stored on the server. This shows the request shape; replace the variables with authorized test values:

~~~bash

curl -X POST "https://graph.facebook.com/v27.0/$PAGE_ID/messages" \

-H "Authorization: Bearer $PAGE_ACCESS_TOKEN" \

-H "Content-Type: application/json" \

-d '{

"recipient": { "id": "'"$RECIPIENT_PSID"'" },

"messaging_type": "RESPONSE",

"message": { "text": "Hello, thanks for your message. How can we help?" }

}'

~~~

The Graph API reference reviewed here displayed version v27.0; check the current version before production. The API normally returns a message identifier if it accepts the request. That does not mean the person received or read it. Follow delivery or read webhooks where available.

The example text is illustrative, not evidence of a message being sent. In a real automation, the reply should come from a verified business rule and be associated with the original message.

Design the human handoff

Define transfer cases in advance: explicit request for an agent, complaint, payment issue, order change, uncertain answer, unavailable current data, or repeated failures. Tell the customer the request is being passed to support, but do not promise a response time the team has not confirmed.

If multiple apps or a human inbox are connected to the Page, use the conversation-control mechanism supported for the account and app. Depending on setup, Messenger Handover Protocol can pass control to another app; an app can also release control so the inbox app can take over. Check current thread ownership before sending another reply, or two systems may answer at once.

For a manual reply after the standard window, use HUMAN_AGENT only when a team member is actually composing and sending an eligible response. The tag does not turn a bot-generated message into a human reply.

Test before enabling automation

In an app and Page you are authorized to manage, test:

- An incoming text and an event with an attachment.

- Correct, missing, and invalid webhook signatures.

- Deduplication when the same message is delivered twice.

- No reply loop on sent-message echoes.

- An API-accepted response followed by an observed delivery status.

- An expired token, missing permission, and uninstalled Page app.

- A request to hand off to a human.

- Behavior outside the standard messaging window.

- No double reply when both the bot and inbox are connected.

Keep tokens and private message content out of logs. Log correlation IDs, event type, HTTP status, message ID, send result, and handoff reason instead. Set an appropriate retention period for collected data.

Conclusion

Messenger automation depends on a verifiable loop: signed webhook, deduplicated processing, a reply authorized through the Send API, and observed status. The standard window is generally 24 hours, with specific entry-point exceptions; a human may reply under HUMAN_AGENT within documented limits, but a bot must not use that mechanism. Test permissions, delivery, errors, and handoff in an authorized environment before connecting a live Page.

Official sources

- Meta — Messenger Platform: Send Messages

- Meta — Page Messages Graph API reference

- Meta — Webhooks for Pages

- Meta — Webhooks for Messenger

- Meta — Messenger Platform Quick Start

- Meta — Page Conversations permissions

- Meta — Page Release Thread Control

- Meta — Messenger and Instagram messaging changelog

- Meta — Webhook signature and verification