Hi everyone,
I’m building an automation in n8n using Evolution API v2.3.7 to handle lead qualification for a law firm. I have a logic that silences the AI Agent for 30 minutes if the lawyer intervenes manually (sending a message from her phone or WhatsApp Web).
The Setup:
-
Trigger: Webhook listening to
messages.upsert. -
Database: Google Sheets/Postgres tracks the
last_human_interactiontimestamp. -
Logic: If
fromMeistrue, I update the timestamp. If a new message arrives and the last interaction was < 30 mins ago, the bot remains silent.
The Issue: The Evolution API sends a webhook for every message, including the ones sent by the n8n bot itself via the API.
-
Bot messages (via API) arrive as:
fromMe: trueandsource: web. -
Manual messages (Lawyer via WhatsApp Web) arrive as:
fromMe: trueandsource: web.
Because both have the exact same source, the bot records its own responses as “Human Interactions,” triggering its own silence logic and effectively “suiciding” after the first reply.
The Question: Is there a reliable way in the messages.upsert payload to distinguish between a message sent specifically via the API and a message sent manually from the WhatsApp Web interface when the source field is identical?
I’ve tried filtering by source, but since the lawyer uses WhatsApp Web, it’s not a unique identifier.
Environment:
-
Evolution API Version: 2.3.7
-
n8n Version: 2.14.2
-
Instance Type: Typebot/n8n integration.
I have disabled the nodes related to the solution because they were creating problems.
Has anyone found a specific metadata field or a header that identifies API-originated messages?
Thanks in advance!
