waiaconnect

Pause your n8n WhatsApp bot when a human replies from the phone (Coexistence message.echo)

Short answer: with Coexistence, every message the business sends from the WhatsApp Business app reaches your webhook as a message.echo event, with message.to = the customer. In n8n, when an echo arrives, save "silenced until now + N minutes" for that customer, and before the bot answers a message.received, check it: if the silence hasn't expired, the bot stays quiet. The ready-made workflow of the n8n guide already does this (N = 120 minutes by default).

Building with AI? Connect it to your account over MCP: it checks your setup, creates webhooks and templates with your confirmation and writes the code for you. See how →

The architecture, in four pieces

  1. Signed webhook. WAIA Connect signs each delivery: X-Connect-Signature-256: sha256=HMAC_SHA256(secret, "<X-Connect-Timestamp>.<raw body>"). Reject a bad signature with 401.
  2. Anti-replay. The timestamp is inside what is signed: reject anything older than 5 minutes. Then dedupe on the event id (evt_…): WAIA Connect retries when it doesn't get a 2xx.
  3. The echo → "human" for N minutes. On message.echo (origin: "device"), store silencedUntil = now + N minutes for message.to. Each new reply from the phone extends it.
  4. The bot checks before answering, and sends with an Idempotency-Key. On message.received, if silencedUntil is in the future, do nothing. If it answers, the send carries an Idempotency-Key tied to the incoming WhatsApp id: a retry returns the same message instead of sending another.

1–2. Check the signature and the timestamp

The same function as the examples repo (Node; there are Python, PHP and Cloudflare Workers versions). Keep the raw body: the signature is over the exact bytes. Full reference: check the signature.

JavaScript

// From github.com/WAIAConnect/whatsapp-cloud-api-examples (verify-webhook-signature/node)
const crypto = require("node:crypto");
const MAX_AGE_SECONDS = 300; // reject deliveries older than 5 minutes (anti-replay)

function verifySignature(secret, timestamp, rawBody, signature, now = Date.now() / 1000) {
  if (!secret || !timestamp || !signature) return false;
  if (Math.abs(now - Number(timestamp)) > MAX_AGE_SECONDS) return false;
  const expected = "sha256=" + crypto.createHmac("sha256", secret)
    .update(String(timestamp) + ".").update(rawBody).digest("hex");
  const a = Buffer.from(String(signature)), b = Buffer.from(expected);
  return a.length === b.length && crypto.timingSafeEqual(a, b); // constant time
}

3. Mark the conversation as "human" on message.echo

In the workflow of the n8n guide this is the "Owner replied from phone" node, followed by an upsert in an n8n Data Table (one row per customer). Event reference: event types.

n8n Code node

// n8n Code node — "Owner replied from phone" (the workflow of the n8n guide)
// message.echo = a message sent FROM THE PHONE (Coexistence). message.to is the customer.
const cfg = $('Config').first().json;          // ownerReplySilenceMinutes: 120 by default
const m = ($input.first().json.body.data || {}).message || {};
return [{ json: {
  phone: String(m.to || '').replace(/\D/g, ''),
  silencedUntil: Date.now() + Number(cfg.ownerReplySilenceMinutes) * 60e3,
} }];
// Next node: upsert { phone, silencedUntil, silenceReason: "owner replied" } in a Data Table.

4. The bot checks the silence, and replies idempotently

JavaScript

// Before the bot answers a message.received:
const c = contactRow || {};                    // the row of THIS customer (by phone)
if (Number(c.silencedUntil || 0) > Date.now()) {
  return [];                                   // a human is handling it: the bot stays quiet
}

And the reply (send a message, idempotency):

The send, with Idempotency-Key

JavaScript

// The reply: one Idempotency-Key tied to the incoming WhatsApp id (wamid)
await fetch("https://api.waiaconnect.com/v1/messages", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + CONNECT_API_KEY,
    "Idempotency-Key": "reply-" + incoming.data.message.id, // same key on a retry = same message
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ connectionId: CONNECTION_ID, to: customerPhone, type: "text", text: { body: answer } })
});

What to keep in mind

  • Only Coexistence numbers produce echoes: the echo exists because the number is also in the WhatsApp Business app. Messages your bot sends through the API do not come back as message.echo.
  • The app's automatic messages (greeting, away) also leave from the phone: if they are on, they count as a human reply.
  • Messages sent from a linked device (WhatsApp Web, the computer, a tablet) also arrive as echoes; per Meta, all except WhatsApp for Windows and Wear OS. The echo does not say which device sent it.
  • To give the bot back the chat early, clear that customer's silencedUntil.

Questions

What is message.echo?

A WAIA Connect webhook event: a message the business sent from the WhatsApp Business app (Coexistence), with its content. origin is "device", message.from is the business number and message.to is the customer.

How long does the bot stay quiet?

As long as you set. The workflow of the n8n guide uses ownerReplySilenceMinutes, 120 minutes by default, and each new reply from the phone extends it.

How do I make sure the bot never answers twice?

Dedupe on the webhook event id (WAIA Connect retries when it doesn't get a 2xx) and send with an Idempotency-Key tied to the incoming WhatsApp id: a retry with the same key returns the same message instead of sending another.

Does n8n's own WhatsApp trigger receive echoes?

The n8n WhatsApp trigger does not offer the phone-echo event (smb_message_echoes) among its events, as checked in the n8n guide. With WAIA Connect the echo arrives as message.echo on your webhook.

Sources

Connect your first number today

Meta-verified technology provider. Coexistence in one click.

Get started