My Facebook AI agent is missing some messages. For certain messages, the AI does not reply, but when the same user sends another message later, the AI replies.
In my current flow:
After the Webhook, I have IF Node 1:
{{ !!$json.body.entry[0].messaging[0].message && !$json.body.entry[0].messaging[0].message?.is_echo }}
If this is true, it goes to IF Node 2.
In IF Node 2, I check:
{{ $json.body.entry[0].messaging[0].message.attachments?.[0]?.type || ‘’ }}
If it is equal to “image” or “audio”, then it goes to AI Agent 2 for a response.
If false, it goes to IF Node 3.
In IF Node 3, I check:
{{ ($json.body.entry[0].messaging[0].message.text || ‘’)
.toLowerCase()
.match(/image|pic|chobi|ছবি/) ? true : false }}
If true, it goes to AI Agent 2.
If false, it goes to AI Agent 3.
The most likely issue is your workflow only looks at the first event item: entry[0].messaging[0]
If Meta sends a payload with more than one entry, or the first event is not the exact message you expect, your IF logic will miss it.
Meta’s Messenger webhooks can include different event types such as: messages, postbacks,
Quick replies, and message events can also contain attachments like image or audio instead of plain text.
A better approach is to flatten the webhook payload first and then process each messaging event one by one. In n8n terms, that usually means using a Code node Doc. or split step to iterate through body.entry[].messaging[], rather than hardcoding [0].
This matters because expressions like first() or “first item only” logic always refer to the first element, which can cause missed events when multiple items are present.
Your webhook is probably receiving batched messages or Facebook is sending duplicate events, and your IF nodes are only checking the first message in the array. When multiple messages come in the same webhook payload, you’re only processing entry[0].messaging[0] and ignoring the rest.
Also double-check your webhook subscription in Facebook—make sure you’re subscribed to the right events and that your token hasn’t expired. Sometimes Facebook stops sending certain message types if permissions drift.
@AbidulHaqueShohel — IF Node 2/3 use smart curly quotes (‘’) in || ‘’, not straight quotes. n8n’s expression parser silently returns undefined, so no-attachment messages hit neither branch. Retype with '. Also handle messaging[0].postback — quick replies/buttons land there, not .message.
Cleaner: drop the || and use one IF with optional chaining + OR:
{{ $json.body.entry[0].messaging[0].message.attachments?.[0]?.type }} equals "image" OR "audio"
Hi @AbidulHaqueShohel, you need use redis to queue every message. you must have 2 workflow
the 1st workflow for the queue and the 2nd is for the workers.