← All projectsCase study · Social Media & Customer Service

AI Facebook Comment & Messenger Responder

Replies to every Facebook comment and Messenger message with natural Egyptian-Arabic AI responses — with signed-webhook verification, PostgreSQL de-duplication and WhatsApp error alerts.

n8nMeta Graph APIMeta WebhooksGroqPostgreSQLEvolution APIJavaScriptDocker
2
channels: comments + Messenger
0
duplicate replies (DB unique key)
HMAC
SHA-256 verified webhooks
24
workflow nodes
How it works
triggerailogicdataaction
  1. 01 · TriggerMeta webhook
  2. 02 · LogicVerify signature
  3. 03 · LogicRoute event
  4. 04 · DataStore & dedupe
  5. 05 · AIAI agent (Groq)
  6. 06 · ActionReply + private DM
The actual workflow↓ Download JSON

Click to interact · zoom, pan and inspect each node. Credentials removed.

The problem

Busy Facebook pages get dozens of comments (“price?”, “available?”) and Messenger messages every day. Answering them manually is slow, replies come hours late, and the same comment sometimes gets answered twice — or not at all.

The solution

An n8n system connected to Meta Webhooks that handles both channels:

Messenger

Incoming messages are extracted and sent to an AI agent running on Groq, which writes a friendly, natural reply in Egyptian Arabic and sends it back through the Graph API.

Post comments

New comments are parsed (comment, post, commenter, permalink), stored in PostgreSQL, and — only if they’re new — the system replies publicly and sends the commenter a private message. Comments made by the page itself are ignored.

Technical details

Security first

  • Handles Meta’s webhook verification handshake.
  • Validates every event’s HMAC-SHA256 signature with the app secret and rejects anything invalid with the right HTTP status.

Exactly-once replies

Comments are inserted with a unique constraint on (page_id, comment_id). Meta can deliver the same event more than once; the database guarantees it’s only answered once. Original payloads are kept as JSONB for analytics.

Monitoring

An Error Trigger workflow catches any failed execution and sends a WhatsApp alert (via Evolution API) with the workflow name, failing node, error message and a link to the execution.

The result

Every customer gets an instant, human-sounding reply on the channel they used, the page never double-replies, and any failure is reported on WhatsApp before customers notice.