> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pilotstatus.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Integrating Pilot Status end to end? Follow https://docs.pilotstatus.com.br/guides/integrate-with-ai.md (pt-BR: https://docs.pilotstatus.com.br/pt-BR/guides/integrate-with-ai.md). No step requires contacting support: every credential is shown in the dashboard or in an API response, and a lost one is regenerated, not recovered.
> Webhook signing secret: shown ONCE in the Signing secret window right after creating the webhook on /webhooks, and in the `secret` field of the POST /v1/webhooks response (MCP: webhooks_create). Lost it: Edit Webhook → Generate a new secret, POST /v1/webhooks/{id}/rotate-secret, or webhooks_rotate_secret (the old one stops working at once). Verify `x-pilot-status-signature` = hex HMAC-SHA256 of the raw request body keyed with that secret.
> Meta verify token (number connected with the user's own Meta app credentials): Meta Number Created! window after connecting, then the number's card on Numbers (workspace Owner), or webhook.verifyToken in the POST /v1/numbers/meta response. It is not the webhook signing secret.
> REST auth: `x-api-key: ps_...` header, never Authorization: Bearer. MCP: https://mcp.pilotstatus.com.br/mcp (148 tools, OAuth 2.1 or x-api-key); Code Mode: https://mcp.pilotstatus.com.br/code. Destructive MCP tools return a preview and a confirm_token: show the preview and call again only after the user's explicit yes. Over OAuth, revealing or creating ps_ API keys is workspace Owner only.

# n8n

> Automate WhatsApp in n8n with the official Pilot Status community node: install it, receive events with the Trigger node, and import ready-made workflows for every kind of number.

The official community node `n8n-nodes-pilot-status` brings two nodes to n8n:

* **Pilot Status** — calls the public `/v1` API: send messages and templates, list logs, manage numbers, templates, Flows, groups and more.
* **Pilot Status Trigger** — receives your webhook events and starts a workflow.

This page shows how to set both up and gives workflows you can import and adapt: one to start with each kind of number (Pilot Status API, Evolution GO layer, Evolution v2 layer, official Meta) and five recipes. Every workflow was imported into n8n and checked against the node definitions, and its routing logic was run with sample payloads of every webhook format.

## Install the node

**1. Install the community node**

In n8n, open **Settings → Community Nodes → Install**, type `n8n-nodes-pilot-status` and confirm. This needs a self-hosted n8n (community nodes are on by default there). On n8n Cloud, n8n decides which community nodes can be installed; if this one is not offered, use a self-hosted instance.

**2. Create the credential**

Add a **Pilot Status API** credential and paste your `ps_` API key from the dashboard.

Which other fields to fill in depends on the kind of key: see [Choose the API key](#choose-the-api-key) below. Leave **Base URL** at its default (`https://pilotstatus.com.br`).

**3. Add a Pilot Status node**

Pick a **Resource** (for example **Message**) and an **Operation** (for example **Send**). The **Template ID** dropdown loads the templates of the credential's number.

## Choose the API key

Pilot Status has three kinds of key ([details](https://docs.pilotstatus.com.br/concepts/key-types.md)). The credential has two optional fields, **WhatsApp Number ID** and **Workspace ID**, sent as the `x-whatsapp-number-id` and `x-workspace-id` headers. Fill them in according to the key:

| Key | Prefix | Where to create it | WhatsApp Number ID | Workspace ID |
| - | - | - | - | - |
| **Number** | `ps_number_` | **API Keys** page | Leave empty: the key already carries its number | Leave empty |
| **Workspace** | `ps_workspace_` | **Workspace keys** | Required to send, read logs or act on one number | Leave empty |
| **Account** | `ps_account_` | **Profile → API** | Required to send, read logs or act on one number | **Required**: the workspace the key acts on |

* **One workflow, one number:** use a **number key**. It can only reach that number, which keeps the damage small if the key leaks.
* **Several numbers:** use a **workspace key**, and create one credential per number, each with its own **WhatsApp Number ID** (the `id` from **Number → Get Many**). Managing numbers (create, connect, remove) also needs a workspace key.
* **Account key:** only when one person automates several workspaces. Without **Workspace ID**, every call answers `400 WORKSPACE_ID_REQUIRED`, and the person behind the key must be an **Owner** or **Admin** to manage webhooks.
* **Trigger with Automatic registration** works with any of the three. The webhook is created on the credential's number, so a workspace or account key without **WhatsApp Number ID** fails activation with `400 NUMBER_REQUIRED`.

> [!WARNING]
>
> **A green credential test does not prove that sending works.** For an account key without **Workspace ID**, n8n tests the credential on `/v1/workspaces`, which needs no workspace, so the test passes and the first **Send** fails. A workspace key without **WhatsApp Number ID** also passes the test and then answers `403 TENANT_SCOPE_NOT_ALLOWED` on **Send**.

## Receive events with the Trigger

**1. Add the Pilot Status Trigger**

Keep **Registration** on **Manual** and **Event** on **All Events** (see the warning below for why).

**2. Register the URL**

Copy the **Production URL** from the Trigger and add it as a webhook of the number on the **Webhooks** page of the Pilot Status dashboard. Use the **Test URL** instead while you click **Listen for test event** in the editor.

**3. Sign the deliveries**

Paste the webhook's signing secret into **Signing Secret**. The Trigger then answers `401` to any request whose `x-pilot-status-signature` does not match. Without it, anyone who learns the URL can start your workflow.

**4. Activate the workflow**

The **Production URL** only receives events while the workflow is active.

The Trigger passes the delivered body through untouched: `$json` is exactly what Pilot Status sent.

### Two webhook formats

What arrives depends on how the number was connected ([details](https://docs.pilotstatus.com.br/api/webhooks/events.md)):

| Number | Body the Trigger receives | Inbound text in |
| - | - | - |
| **Pilot Status API (unofficial, QR code)** | Pilot Status events: `message.received`, `message.reply`, … | `$json.data.content` |
| **Evolution GO layer (unofficial)** | Evolution GO events: `Message`, `SendMessage`, `Receipt`, … | `$json.data.Message.conversation` |
| **Evolution v2 layer (unofficial)** | Evolution v2 events: `messages.upsert`, `messages.update`, … | `$json.data.message.conversation` |
| **Meta Cloud API (official)** | Meta's native envelope: `{ object, entry }` | `$json.entry[0].changes[0].value.messages[0].text.body` |

> [!WARNING]
>
> **On an official number, pick All Events.** Meta's envelope has no `event` field, so a Trigger set to a specific event such as **Message Reply** answers `200 Ignored event` to every message and the workflow never runs. For the same reason, do not use **Automatic** registration with a `message.*` event on an official number: Pilot Status drops event names the number cannot emit, so the webhook is created with an empty list and delivers nothing.

> [!WARNING]
>
> **A reply arrives as `message.reply`, not `message.received`.** On a QR-code number, a message that quotes another one, including a tap on a template button, fires `message.reply` only. A Trigger set to **Message Received** never sees button taps.

To avoid writing every workflow four times, the workflows below start with a **Normalize** Code node. It turns all four formats into the same flat item:

| Field | Meaning |
| - | - |
| `source` | `pilot-status`, `evolution-go`, `evolution-v2` or `meta` |
| `isInbound` | `true` only for a message the contact sent. Statuses, and the echo of your own sends, are `false` |
| `from` | the contact's number in E.164 (`+5511999999999`) |
| `name` | the contact's WhatsApp name, when known |
| `text` | message text, or the label of the tapped button or list row |
| `buttonId` | id or payload of the tapped button or list row, when WhatsApp reports one |
| `quotedMessageId` | the message being replied to, when there is one |

```javascript Normalize (Code node) theme={null}
// Turns every webhook format into the same flat item:
// - Pilot Status API (QR code) numbers send { event, data }
// - Evolution GO layer numbers send Evolution GO events ("Message", "SendMessage", ...)
// - Evolution v2 layer numbers send Evolution v2 events ("messages.upsert", ...)
// - Meta Cloud API (official) numbers send Meta's native envelope { object, entry }
const phoneOf = (jid) =>
  typeof jid === 'string' && jid.endsWith('@s.whatsapp.net') ? '+' + jid.split('@')[0].split(':')[0] : '';

// Evolution GO and v2 carry the same WhatsApp message object
const readWaMessage = (m = {}) => ({
  text:
    m.conversation ??
    m.extendedTextMessage?.text ??
    m.buttonsResponseMessage?.selectedDisplayText ??
    m.templateButtonReplyMessage?.selectedDisplayText ??
    m.listResponseMessage?.title ??
    m.imageMessage?.caption ??
    m.videoMessage?.caption ??
    '',
  buttonId:
    m.buttonsResponseMessage?.selectedButtonId ??
    m.templateButtonReplyMessage?.selectedId ??
    m.listResponseMessage?.singleSelectReply?.selectedRowId ??
    '',
  quotedMessageId:
    m.extendedTextMessage?.contextInfo?.stanzaId ??
    m.buttonsResponseMessage?.contextInfo?.stanzaId ??
    m.templateButtonReplyMessage?.contextInfo?.stanzaId ??
    m.listResponseMessage?.contextInfo?.stanzaId ??
    '',
});

return $input.all().map(({ json }) => {
  // Meta Cloud API (official)
  if (json.entry) {
    const value = json.entry[0]?.changes?.[0]?.value ?? {};
    const msg = value.messages?.[0];
    return {
      json: {
        source: 'meta',
        isInbound: Boolean(msg),
        from: msg ? '+' + msg.from : '',
        name: value.contacts?.[0]?.profile?.name ?? '',
        text:
          msg?.text?.body ??
          msg?.button?.text ??
          msg?.interactive?.button_reply?.title ??
          msg?.interactive?.list_reply?.title ??
          '',
        buttonId:
          msg?.button?.payload ??
          msg?.interactive?.button_reply?.id ??
          msg?.interactive?.list_reply?.id ??
          '',
        quotedMessageId: msg?.context?.id ?? '',
      },
    };
  }

  // Evolution v2 layer
  if (json.event === 'messages.upsert') {
    const d = json.data ?? {};
    const jid = d.key?.remoteJidAlt || d.key?.remoteJid;
    const from = phoneOf(jid);
    return {
      json: {
        source: 'evolution-v2',
        isInbound: Boolean(from) && !d.key?.fromMe,
        from,
        name: d.pushName ?? '',
        ...readWaMessage(d.message),
      },
    };
  }

  // Evolution GO layer
  if (json.event === 'Message' || json.event === 'MESSAGES_UPSERT') {
    const info = json.data?.Info ?? {};
    const from = phoneOf(info.Chat) || phoneOf(info.SenderAlt);
    return {
      json: {
        source: 'evolution-go',
        isInbound: Boolean(from) && !info.IsFromMe && !info.IsGroup,
        from,
        name: info.PushName ?? '',
        ...readWaMessage(json.data?.Message),
      },
    };
  }

  // Pilot Status API (QR code)
  const data = json.data ?? {};
  return {
    json: {
      source: 'pilot-status',
      isInbound: ['message.received', 'message.reply'].includes(json.event) && !data.fromMe,
      from: data.from ?? '',
      name: data.participantName ?? '',
      text: data.content ?? '',
      buttonId: data.buttonId ?? '',
      quotedMessageId: data.quotedMessageId ?? '',
    },
  };
});
```

## Import a workflow

1. Copy the JSON of a recipe.
2. In n8n, open an empty workflow and press **Ctrl+V** (**Cmd+V** on macOS) on the canvas. You can also save the JSON to a file and use **⋯ → Import from File**.
3. Open each Pilot Status, Google Sheets, OpenAI and e-mail node and select your credential.
4. Replace the example values: template names, phone numbers, spreadsheet id, e-mail addresses.

> [!NOTE]
>
> The workflow replies **from the number of the credential**. Register the Trigger URL on that same number: if the webhook belongs to number A and the credential to number B, the contact writes to A and gets the answer from B.

## Start with your number type

Each workflow below answers every text a contact sends with `We got your message: <their text>`. Import the one for your number to see events arrive, then move on to the recipes. All four use the same **Pilot Status Trigger → Normalize → Inbound text?** start; only the reply differs.

> [tab] Pilot Status API
>
> A number connected by QR code in the dashboard. The reply goes through the **Pilot Status** node (`POST /v1/messages/send`), with a `ps_` key in the credential.
>
> > [accordion] Workflow JSON — Pilot Status API
> >
> > ```json theme={null}
> > {
> >   "name": "Pilot Status - Quick start: Pilot Status API number",
> >   "nodes": [
> >     {
> >       "parameters": {
> >         "event": "*"
> >       },
> >       "id": "bbf851e6-d274-449f-a447-c26c4c9120d9",
> >       "name": "Pilot Status Trigger",
> >       "type": "n8n-nodes-pilot-status.pilotStatusTrigger",
> >       "typeVersion": 1,
> >       "position": [
> >         0,
> >         0
> >       ],
> >       "webhookId": "651f10f4-cea7-48dd-bc13-a8b0a01c7fea"
> >     },
> >     {
> >       "parameters": {
> >         "jsCode": "// Turns every webhook format into the same flat item:\n// - Pilot Status API (QR code) numbers send { event, data }\n// - Evolution GO layer numbers send Evolution GO events (\"Message\", \"SendMessage\", ...)\n// - Evolution v2 layer numbers send Evolution v2 events (\"messages.upsert\", ...)\n// - Meta Cloud API (official) numbers send Meta's native envelope { object, entry }\nconst phoneOf = (jid) =>\n  typeof jid === 'string' && jid.endsWith('@s.whatsapp.net') ? '+' + jid.split('@')[0].split(':')[0] : '';\n\n// Evolution GO and v2 carry the same WhatsApp message object\nconst readWaMessage = (m = {}) => ({\n  text:\n    m.conversation ??\n    m.extendedTextMessage?.text ??\n    m.buttonsResponseMessage?.selectedDisplayText ??\n    m.templateButtonReplyMessage?.selectedDisplayText ??\n    m.listResponseMessage?.title ??\n    m.imageMessage?.caption ??\n    m.videoMessage?.caption ??\n    '',\n  buttonId:\n    m.buttonsResponseMessage?.selectedButtonId ??\n    m.templateButtonReplyMessage?.selectedId ??\n    m.listResponseMessage?.singleSelectReply?.selectedRowId ??\n    '',\n  quotedMessageId:\n    m.extendedTextMessage?.contextInfo?.stanzaId ??\n    m.buttonsResponseMessage?.contextInfo?.stanzaId ??\n    m.templateButtonReplyMessage?.contextInfo?.stanzaId ??\n    m.listResponseMessage?.contextInfo?.stanzaId ??\n    '',\n});\n\nreturn $input.all().map(({ json }) => {\n  // Meta Cloud API (official)\n  if (json.entry) {\n    const value = json.entry[0]?.changes?.[0]?.value ?? {};\n    const msg = value.messages?.[0];\n    return {\n      json: {\n        source: 'meta',\n        isInbound: Boolean(msg),\n        from: msg ? '+' + msg.from : '',\n        name: value.contacts?.[0]?.profile?.name ?? '',\n        text:\n          msg?.text?.body ??\n          msg?.button?.text ??\n          msg?.interactive?.button_reply?.title ??\n          msg?.interactive?.list_reply?.title ??\n          '',\n        buttonId:\n          msg?.button?.payload ??\n          msg?.interactive?.button_reply?.id ??\n          msg?.interactive?.list_reply?.id ??\n          '',\n        quotedMessageId: msg?.context?.id ?? '',\n      },\n    };\n  }\n\n  // Evolution v2 layer\n  if (json.event === 'messages.upsert') {\n    const d = json.data ?? {};\n    const jid = d.key?.remoteJidAlt || d.key?.remoteJid;\n    const from = phoneOf(jid);\n    return {\n      json: {\n        source: 'evolution-v2',\n        isInbound: Boolean(from) && !d.key?.fromMe,\n        from,\n        name: d.pushName ?? '',\n        ...readWaMessage(d.message),\n      },\n    };\n  }\n\n  // Evolution GO layer\n  if (json.event === 'Message' || json.event === 'MESSAGES_UPSERT') {\n    const info = json.data?.Info ?? {};\n    const from = phoneOf(info.Chat) || phoneOf(info.SenderAlt);\n    return {\n      json: {\n        source: 'evolution-go',\n        isInbound: Boolean(from) && !info.IsFromMe && !info.IsGroup,\n        from,\n        name: info.PushName ?? '',\n        ...readWaMessage(json.data?.Message),\n      },\n    };\n  }\n\n  // Pilot Status API (QR code)\n  const data = json.data ?? {};\n  return {\n    json: {\n      source: 'pilot-status',\n      isInbound: ['message.received', 'message.reply'].includes(json.event) && !data.fromMe,\n      from: data.from ?? '',\n      name: data.participantName ?? '',\n      text: data.content ?? '',\n      buttonId: data.buttonId ?? '',\n      quotedMessageId: data.quotedMessageId ?? '',\n    },\n  };\n});"
> >       },
> >       "id": "bbff8aba-9b87-4190-8b6b-7ac64eb2ebb4",
> >       "name": "Normalize",
> >       "type": "n8n-nodes-base.code",
> >       "typeVersion": 2,
> >       "position": [
> >         220,
> >         0
> >       ]
> >     },
> >     {
> >       "parameters": {
> >         "conditions": {
> >           "options": {
> >             "caseSensitive": true,
> >             "leftValue": "",
> >             "typeValidation": "loose",
> >             "version": 2
> >           },
> >           "conditions": [
> >             {
> >               "id": "2561f39f-e0b0-4152-b87e-39c89c0ad7e8",
> >               "leftValue": "={{ $json.isInbound }}",
> >               "rightValue": "",
> >               "operator": {
> >                 "type": "boolean",
> >                 "operation": "true",
> >                 "singleValue": true
> >               }
> >             },
> >             {
> >               "id": "a434d6af-1b39-4ea0-8819-1c451aa390b1",
> >               "leftValue": "={{ $json.text }}",
> >               "rightValue": "",
> >               "operator": {
> >                 "type": "string",
> >                 "operation": "notEmpty",
> >                 "singleValue": true
> >               }
> >             }
> >           ],
> >           "combinator": "and"
> >         },
> >         "options": {}
> >       },
> >       "id": "88c73a16-d7a5-482e-8d73-b987992107ca",
> >       "name": "Inbound text?",
> >       "type": "n8n-nodes-base.if",
> >       "typeVersion": 2.2,
> >       "position": [
> >         440,
> >         0
> >       ]
> >     },
> >     {
> >       "parameters": {
> >         "resource": "message",
> >         "operation": "send",
> >         "destinationNumber": "={{ $json.from }}",
> >         "additionalFields": {
> >           "text": "=We got your message: {{ $json.text }}"
> >         }
> >       },
> >       "id": "7354d3f5-4758-49ab-912e-174fa891b716",
> >       "name": "Reply",
> >       "type": "n8n-nodes-pilot-status.pilotStatus",
> >       "typeVersion": 1,
> >       "position": [
> >         660,
> >         0
> >       ]
> >     }
> >   ],
> >   "connections": {
> >     "Pilot Status Trigger": {
> >       "main": [
> >         [
> >           {
> >             "node": "Normalize",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     },
> >     "Normalize": {
> >       "main": [
> >         [
> >           {
> >             "node": "Inbound text?",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     },
> >     "Inbound text?": {
> >       "main": [
> >         [
> >           {
> >             "node": "Reply",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     }
> >   },
> >   "pinData": {},
> >   "settings": {
> >     "executionOrder": "v1"
> >   }
> > }
> > ```

> [tab] Evolution GO layer
>
> A number migrated from Evolution GO. Events arrive in Evolution GO's own format, and the reply uses the layer exactly as your Evolution GO code does: `POST /send/text` on `https://pilotstatus.com.br/api/layer/evolution-go/`, with the **instance token** in the `apikey` header (not a `ps_` key). See the [Evolution GO layer](https://docs.pilotstatus.com.br/api/layer/evolution-go.md).
>
> What to change: `YOUR_INSTANCE_TOKEN` in **Reply through the layer**. To keep the token out of the workflow, move it to an n8n **Header Auth** credential named `apikey`. You can also reply with the **Pilot Status** node instead, like on a Pilot Status API number.
>
> > [accordion] Workflow JSON — Evolution GO layer
> >
> > ```json theme={null}
> > {
> >   "name": "Pilot Status - Quick start: Evolution GO layer number",
> >   "nodes": [
> >     {
> >       "parameters": {
> >         "event": "*"
> >       },
> >       "id": "ba9ea569-d05e-435c-b100-897eae75b90f",
> >       "name": "Pilot Status Trigger",
> >       "type": "n8n-nodes-pilot-status.pilotStatusTrigger",
> >       "typeVersion": 1,
> >       "position": [
> >         0,
> >         0
> >       ],
> >       "webhookId": "35758ba7-6860-4a7b-a5f4-180196d67916"
> >     },
> >     {
> >       "parameters": {
> >         "jsCode": "// Turns every webhook format into the same flat item:\n// - Pilot Status API (QR code) numbers send { event, data }\n// - Evolution GO layer numbers send Evolution GO events (\"Message\", \"SendMessage\", ...)\n// - Evolution v2 layer numbers send Evolution v2 events (\"messages.upsert\", ...)\n// - Meta Cloud API (official) numbers send Meta's native envelope { object, entry }\nconst phoneOf = (jid) =>\n  typeof jid === 'string' && jid.endsWith('@s.whatsapp.net') ? '+' + jid.split('@')[0].split(':')[0] : '';\n\n// Evolution GO and v2 carry the same WhatsApp message object\nconst readWaMessage = (m = {}) => ({\n  text:\n    m.conversation ??\n    m.extendedTextMessage?.text ??\n    m.buttonsResponseMessage?.selectedDisplayText ??\n    m.templateButtonReplyMessage?.selectedDisplayText ??\n    m.listResponseMessage?.title ??\n    m.imageMessage?.caption ??\n    m.videoMessage?.caption ??\n    '',\n  buttonId:\n    m.buttonsResponseMessage?.selectedButtonId ??\n    m.templateButtonReplyMessage?.selectedId ??\n    m.listResponseMessage?.singleSelectReply?.selectedRowId ??\n    '',\n  quotedMessageId:\n    m.extendedTextMessage?.contextInfo?.stanzaId ??\n    m.buttonsResponseMessage?.contextInfo?.stanzaId ??\n    m.templateButtonReplyMessage?.contextInfo?.stanzaId ??\n    m.listResponseMessage?.contextInfo?.stanzaId ??\n    '',\n});\n\nreturn $input.all().map(({ json }) => {\n  // Meta Cloud API (official)\n  if (json.entry) {\n    const value = json.entry[0]?.changes?.[0]?.value ?? {};\n    const msg = value.messages?.[0];\n    return {\n      json: {\n        source: 'meta',\n        isInbound: Boolean(msg),\n        from: msg ? '+' + msg.from : '',\n        name: value.contacts?.[0]?.profile?.name ?? '',\n        text:\n          msg?.text?.body ??\n          msg?.button?.text ??\n          msg?.interactive?.button_reply?.title ??\n          msg?.interactive?.list_reply?.title ??\n          '',\n        buttonId:\n          msg?.button?.payload ??\n          msg?.interactive?.button_reply?.id ??\n          msg?.interactive?.list_reply?.id ??\n          '',\n        quotedMessageId: msg?.context?.id ?? '',\n      },\n    };\n  }\n\n  // Evolution v2 layer\n  if (json.event === 'messages.upsert') {\n    const d = json.data ?? {};\n    const jid = d.key?.remoteJidAlt || d.key?.remoteJid;\n    const from = phoneOf(jid);\n    return {\n      json: {\n        source: 'evolution-v2',\n        isInbound: Boolean(from) && !d.key?.fromMe,\n        from,\n        name: d.pushName ?? '',\n        ...readWaMessage(d.message),\n      },\n    };\n  }\n\n  // Evolution GO layer\n  if (json.event === 'Message' || json.event === 'MESSAGES_UPSERT') {\n    const info = json.data?.Info ?? {};\n    const from = phoneOf(info.Chat) || phoneOf(info.SenderAlt);\n    return {\n      json: {\n        source: 'evolution-go',\n        isInbound: Boolean(from) && !info.IsFromMe && !info.IsGroup,\n        from,\n        name: info.PushName ?? '',\n        ...readWaMessage(json.data?.Message),\n      },\n    };\n  }\n\n  // Pilot Status API (QR code)\n  const data = json.data ?? {};\n  return {\n    json: {\n      source: 'pilot-status',\n      isInbound: ['message.received', 'message.reply'].includes(json.event) && !data.fromMe,\n      from: data.from ?? '',\n      name: data.participantName ?? '',\n      text: data.content ?? '',\n      buttonId: data.buttonId ?? '',\n      quotedMessageId: data.quotedMessageId ?? '',\n    },\n  };\n});"
> >       },
> >       "id": "1ef3896b-578a-4399-ab5c-93a910cdf628",
> >       "name": "Normalize",
> >       "type": "n8n-nodes-base.code",
> >       "typeVersion": 2,
> >       "position": [
> >         220,
> >         0
> >       ]
> >     },
> >     {
> >       "parameters": {
> >         "conditions": {
> >           "options": {
> >             "caseSensitive": true,
> >             "leftValue": "",
> >             "typeValidation": "loose",
> >             "version": 2
> >           },
> >           "conditions": [
> >             {
> >               "id": "9bf1c4b6-c3ad-4856-a5b9-ae5996057540",
> >               "leftValue": "={{ $json.isInbound }}",
> >               "rightValue": "",
> >               "operator": {
> >                 "type": "boolean",
> >                 "operation": "true",
> >                 "singleValue": true
> >               }
> >             },
> >             {
> >               "id": "707f2338-eba7-42c9-a937-1452c78311d1",
> >               "leftValue": "={{ $json.text }}",
> >               "rightValue": "",
> >               "operator": {
> >                 "type": "string",
> >                 "operation": "notEmpty",
> >                 "singleValue": true
> >               }
> >             }
> >           ],
> >           "combinator": "and"
> >         },
> >         "options": {}
> >       },
> >       "id": "1675fa18-3f8b-4633-8c8b-3db5da1f306e",
> >       "name": "Inbound text?",
> >       "type": "n8n-nodes-base.if",
> >       "typeVersion": 2.2,
> >       "position": [
> >         440,
> >         0
> >       ]
> >     },
> >     {
> >       "parameters": {
> >         "method": "POST",
> >         "url": "https://pilotstatus.com.br/api/layer/evolution-go/send/text",
> >         "sendHeaders": true,
> >         "headerParameters": {
> >           "parameters": [
> >             {
> >               "name": "apikey",
> >               "value": "YOUR_INSTANCE_TOKEN"
> >             }
> >           ]
> >         },
> >         "sendBody": true,
> >         "specifyBody": "json",
> >         "jsonBody": "={{ JSON.stringify({ number: $json.from.replace('+', ''), text: \"We got your message: \" + $json.text }) }}",
> >         "options": {}
> >       },
> >       "id": "7d004fcc-d6e2-4897-a5a1-6d957310dac8",
> >       "name": "Reply through the layer",
> >       "type": "n8n-nodes-base.httpRequest",
> >       "typeVersion": 4.2,
> >       "position": [
> >         660,
> >         0
> >       ]
> >     }
> >   ],
> >   "connections": {
> >     "Pilot Status Trigger": {
> >       "main": [
> >         [
> >           {
> >             "node": "Normalize",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     },
> >     "Normalize": {
> >       "main": [
> >         [
> >           {
> >             "node": "Inbound text?",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     },
> >     "Inbound text?": {
> >       "main": [
> >         [
> >           {
> >             "node": "Reply through the layer",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     }
> >   },
> >   "pinData": {},
> >   "settings": {
> >     "executionOrder": "v1"
> >   }
> > }
> > ```

> [tab] Evolution v2 layer
>
> A number migrated from Evolution API v2. Events arrive in Evolution v2's own format (`messages.upsert`), and the reply calls `POST /message/sendText/{instance}` on `https://pilotstatus.com.br/api/layer/evolution-v2/`, with the instance token in `apikey`. See the [Evolution V2 layer](https://docs.pilotstatus.com.br/api/layer/evolution-v2.md#instance-name-mapping) for which instance name to use.
>
> What to change: `YOUR_INSTANCE_NAME` in the URL and `YOUR_INSTANCE_TOKEN` in the header of **Reply through the layer**.
>
> > [accordion] Workflow JSON — Evolution v2 layer
> >
> > ```json theme={null}
> > {
> >   "name": "Pilot Status - Quick start: Evolution v2 layer number",
> >   "nodes": [
> >     {
> >       "parameters": {
> >         "event": "*"
> >       },
> >       "id": "3bbfef96-babf-4394-9bc1-196450794899",
> >       "name": "Pilot Status Trigger",
> >       "type": "n8n-nodes-pilot-status.pilotStatusTrigger",
> >       "typeVersion": 1,
> >       "position": [
> >         0,
> >         0
> >       ],
> >       "webhookId": "12c66ad1-8f27-4569-bace-05ec864ae605"
> >     },
> >     {
> >       "parameters": {
> >         "jsCode": "// Turns every webhook format into the same flat item:\n// - Pilot Status API (QR code) numbers send { event, data }\n// - Evolution GO layer numbers send Evolution GO events (\"Message\", \"SendMessage\", ...)\n// - Evolution v2 layer numbers send Evolution v2 events (\"messages.upsert\", ...)\n// - Meta Cloud API (official) numbers send Meta's native envelope { object, entry }\nconst phoneOf = (jid) =>\n  typeof jid === 'string' && jid.endsWith('@s.whatsapp.net') ? '+' + jid.split('@')[0].split(':')[0] : '';\n\n// Evolution GO and v2 carry the same WhatsApp message object\nconst readWaMessage = (m = {}) => ({\n  text:\n    m.conversation ??\n    m.extendedTextMessage?.text ??\n    m.buttonsResponseMessage?.selectedDisplayText ??\n    m.templateButtonReplyMessage?.selectedDisplayText ??\n    m.listResponseMessage?.title ??\n    m.imageMessage?.caption ??\n    m.videoMessage?.caption ??\n    '',\n  buttonId:\n    m.buttonsResponseMessage?.selectedButtonId ??\n    m.templateButtonReplyMessage?.selectedId ??\n    m.listResponseMessage?.singleSelectReply?.selectedRowId ??\n    '',\n  quotedMessageId:\n    m.extendedTextMessage?.contextInfo?.stanzaId ??\n    m.buttonsResponseMessage?.contextInfo?.stanzaId ??\n    m.templateButtonReplyMessage?.contextInfo?.stanzaId ??\n    m.listResponseMessage?.contextInfo?.stanzaId ??\n    '',\n});\n\nreturn $input.all().map(({ json }) => {\n  // Meta Cloud API (official)\n  if (json.entry) {\n    const value = json.entry[0]?.changes?.[0]?.value ?? {};\n    const msg = value.messages?.[0];\n    return {\n      json: {\n        source: 'meta',\n        isInbound: Boolean(msg),\n        from: msg ? '+' + msg.from : '',\n        name: value.contacts?.[0]?.profile?.name ?? '',\n        text:\n          msg?.text?.body ??\n          msg?.button?.text ??\n          msg?.interactive?.button_reply?.title ??\n          msg?.interactive?.list_reply?.title ??\n          '',\n        buttonId:\n          msg?.button?.payload ??\n          msg?.interactive?.button_reply?.id ??\n          msg?.interactive?.list_reply?.id ??\n          '',\n        quotedMessageId: msg?.context?.id ?? '',\n      },\n    };\n  }\n\n  // Evolution v2 layer\n  if (json.event === 'messages.upsert') {\n    const d = json.data ?? {};\n    const jid = d.key?.remoteJidAlt || d.key?.remoteJid;\n    const from = phoneOf(jid);\n    return {\n      json: {\n        source: 'evolution-v2',\n        isInbound: Boolean(from) && !d.key?.fromMe,\n        from,\n        name: d.pushName ?? '',\n        ...readWaMessage(d.message),\n      },\n    };\n  }\n\n  // Evolution GO layer\n  if (json.event === 'Message' || json.event === 'MESSAGES_UPSERT') {\n    const info = json.data?.Info ?? {};\n    const from = phoneOf(info.Chat) || phoneOf(info.SenderAlt);\n    return {\n      json: {\n        source: 'evolution-go',\n        isInbound: Boolean(from) && !info.IsFromMe && !info.IsGroup,\n        from,\n        name: info.PushName ?? '',\n        ...readWaMessage(json.data?.Message),\n      },\n    };\n  }\n\n  // Pilot Status API (QR code)\n  const data = json.data ?? {};\n  return {\n    json: {\n      source: 'pilot-status',\n      isInbound: ['message.received', 'message.reply'].includes(json.event) && !data.fromMe,\n      from: data.from ?? '',\n      name: data.participantName ?? '',\n      text: data.content ?? '',\n      buttonId: data.buttonId ?? '',\n      quotedMessageId: data.quotedMessageId ?? '',\n    },\n  };\n});"
> >       },
> >       "id": "ccf0aee4-d463-4fa0-b884-2725c002bb23",
> >       "name": "Normalize",
> >       "type": "n8n-nodes-base.code",
> >       "typeVersion": 2,
> >       "position": [
> >         220,
> >         0
> >       ]
> >     },
> >     {
> >       "parameters": {
> >         "conditions": {
> >           "options": {
> >             "caseSensitive": true,
> >             "leftValue": "",
> >             "typeValidation": "loose",
> >             "version": 2
> >           },
> >           "conditions": [
> >             {
> >               "id": "9ddcdd83-712b-4066-bb84-8de8932f61c8",
> >               "leftValue": "={{ $json.isInbound }}",
> >               "rightValue": "",
> >               "operator": {
> >                 "type": "boolean",
> >                 "operation": "true",
> >                 "singleValue": true
> >               }
> >             },
> >             {
> >               "id": "8dce8e53-85e0-4f17-a5bf-c89e08100263",
> >               "leftValue": "={{ $json.text }}",
> >               "rightValue": "",
> >               "operator": {
> >                 "type": "string",
> >                 "operation": "notEmpty",
> >                 "singleValue": true
> >               }
> >             }
> >           ],
> >           "combinator": "and"
> >         },
> >         "options": {}
> >       },
> >       "id": "7ddc9026-ea7c-4bf1-a309-8b8a2c8f5754",
> >       "name": "Inbound text?",
> >       "type": "n8n-nodes-base.if",
> >       "typeVersion": 2.2,
> >       "position": [
> >         440,
> >         0
> >       ]
> >     },
> >     {
> >       "parameters": {
> >         "method": "POST",
> >         "url": "https://pilotstatus.com.br/api/layer/evolution-v2/message/sendText/YOUR_INSTANCE_NAME",
> >         "sendHeaders": true,
> >         "headerParameters": {
> >           "parameters": [
> >             {
> >               "name": "apikey",
> >               "value": "YOUR_INSTANCE_TOKEN"
> >             }
> >           ]
> >         },
> >         "sendBody": true,
> >         "specifyBody": "json",
> >         "jsonBody": "={{ JSON.stringify({ number: $json.from.replace('+', ''), text: \"We got your message: \" + $json.text }) }}",
> >         "options": {}
> >       },
> >       "id": "fcad5239-0cdb-4224-a9a5-387c8b41f4ec",
> >       "name": "Reply through the layer",
> >       "type": "n8n-nodes-base.httpRequest",
> >       "typeVersion": 4.2,
> >       "position": [
> >         660,
> >         0
> >       ]
> >     }
> >   ],
> >   "connections": {
> >     "Pilot Status Trigger": {
> >       "main": [
> >         [
> >           {
> >             "node": "Normalize",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     },
> >     "Normalize": {
> >       "main": [
> >         [
> >           {
> >             "node": "Inbound text?",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     },
> >     "Inbound text?": {
> >       "main": [
> >         [
> >           {
> >             "node": "Reply through the layer",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     }
> >   },
> >   "pinData": {},
> >   "settings": {
> >     "executionOrder": "v1"
> >   }
> > }
> > ```

> [tab] Official (Meta)
>
> A number connected through Embedded Signup or Meta credentials. Events arrive as Meta's native envelope, and the reply goes through the **Pilot Status** node. A free-text reply is allowed because the contact's message opened the 24-hour service window; outside it, send an approved template.
>
> > [accordion] Workflow JSON — official (Meta)
> >
> > ```json theme={null}
> > {
> >   "name": "Pilot Status - Quick start: official (Meta) number",
> >   "nodes": [
> >     {
> >       "parameters": {
> >         "event": "*"
> >       },
> >       "id": "c420f53b-b3b3-4740-a287-d88373033b08",
> >       "name": "Pilot Status Trigger",
> >       "type": "n8n-nodes-pilot-status.pilotStatusTrigger",
> >       "typeVersion": 1,
> >       "position": [
> >         0,
> >         0
> >       ],
> >       "webhookId": "2f61f900-c195-46a2-8d6b-f113cf57619d"
> >     },
> >     {
> >       "parameters": {
> >         "jsCode": "// Turns every webhook format into the same flat item:\n// - Pilot Status API (QR code) numbers send { event, data }\n// - Evolution GO layer numbers send Evolution GO events (\"Message\", \"SendMessage\", ...)\n// - Evolution v2 layer numbers send Evolution v2 events (\"messages.upsert\", ...)\n// - Meta Cloud API (official) numbers send Meta's native envelope { object, entry }\nconst phoneOf = (jid) =>\n  typeof jid === 'string' && jid.endsWith('@s.whatsapp.net') ? '+' + jid.split('@')[0].split(':')[0] : '';\n\n// Evolution GO and v2 carry the same WhatsApp message object\nconst readWaMessage = (m = {}) => ({\n  text:\n    m.conversation ??\n    m.extendedTextMessage?.text ??\n    m.buttonsResponseMessage?.selectedDisplayText ??\n    m.templateButtonReplyMessage?.selectedDisplayText ??\n    m.listResponseMessage?.title ??\n    m.imageMessage?.caption ??\n    m.videoMessage?.caption ??\n    '',\n  buttonId:\n    m.buttonsResponseMessage?.selectedButtonId ??\n    m.templateButtonReplyMessage?.selectedId ??\n    m.listResponseMessage?.singleSelectReply?.selectedRowId ??\n    '',\n  quotedMessageId:\n    m.extendedTextMessage?.contextInfo?.stanzaId ??\n    m.buttonsResponseMessage?.contextInfo?.stanzaId ??\n    m.templateButtonReplyMessage?.contextInfo?.stanzaId ??\n    m.listResponseMessage?.contextInfo?.stanzaId ??\n    '',\n});\n\nreturn $input.all().map(({ json }) => {\n  // Meta Cloud API (official)\n  if (json.entry) {\n    const value = json.entry[0]?.changes?.[0]?.value ?? {};\n    const msg = value.messages?.[0];\n    return {\n      json: {\n        source: 'meta',\n        isInbound: Boolean(msg),\n        from: msg ? '+' + msg.from : '',\n        name: value.contacts?.[0]?.profile?.name ?? '',\n        text:\n          msg?.text?.body ??\n          msg?.button?.text ??\n          msg?.interactive?.button_reply?.title ??\n          msg?.interactive?.list_reply?.title ??\n          '',\n        buttonId:\n          msg?.button?.payload ??\n          msg?.interactive?.button_reply?.id ??\n          msg?.interactive?.list_reply?.id ??\n          '',\n        quotedMessageId: msg?.context?.id ?? '',\n      },\n    };\n  }\n\n  // Evolution v2 layer\n  if (json.event === 'messages.upsert') {\n    const d = json.data ?? {};\n    const jid = d.key?.remoteJidAlt || d.key?.remoteJid;\n    const from = phoneOf(jid);\n    return {\n      json: {\n        source: 'evolution-v2',\n        isInbound: Boolean(from) && !d.key?.fromMe,\n        from,\n        name: d.pushName ?? '',\n        ...readWaMessage(d.message),\n      },\n    };\n  }\n\n  // Evolution GO layer\n  if (json.event === 'Message' || json.event === 'MESSAGES_UPSERT') {\n    const info = json.data?.Info ?? {};\n    const from = phoneOf(info.Chat) || phoneOf(info.SenderAlt);\n    return {\n      json: {\n        source: 'evolution-go',\n        isInbound: Boolean(from) && !info.IsFromMe && !info.IsGroup,\n        from,\n        name: info.PushName ?? '',\n        ...readWaMessage(json.data?.Message),\n      },\n    };\n  }\n\n  // Pilot Status API (QR code)\n  const data = json.data ?? {};\n  return {\n    json: {\n      source: 'pilot-status',\n      isInbound: ['message.received', 'message.reply'].includes(json.event) && !data.fromMe,\n      from: data.from ?? '',\n      name: data.participantName ?? '',\n      text: data.content ?? '',\n      buttonId: data.buttonId ?? '',\n      quotedMessageId: data.quotedMessageId ?? '',\n    },\n  };\n});"
> >       },
> >       "id": "09ebf7e8-ed5c-474d-917d-d8095c30bffc",
> >       "name": "Normalize",
> >       "type": "n8n-nodes-base.code",
> >       "typeVersion": 2,
> >       "position": [
> >         220,
> >         0
> >       ]
> >     },
> >     {
> >       "parameters": {
> >         "conditions": {
> >           "options": {
> >             "caseSensitive": true,
> >             "leftValue": "",
> >             "typeValidation": "loose",
> >             "version": 2
> >           },
> >           "conditions": [
> >             {
> >               "id": "24b97a3f-6337-4831-997d-64534d9dfbf5",
> >               "leftValue": "={{ $json.isInbound }}",
> >               "rightValue": "",
> >               "operator": {
> >                 "type": "boolean",
> >                 "operation": "true",
> >                 "singleValue": true
> >               }
> >             },
> >             {
> >               "id": "d3df575f-c6e5-4212-b506-67f005a85bc7",
> >               "leftValue": "={{ $json.text }}",
> >               "rightValue": "",
> >               "operator": {
> >                 "type": "string",
> >                 "operation": "notEmpty",
> >                 "singleValue": true
> >               }
> >             }
> >           ],
> >           "combinator": "and"
> >         },
> >         "options": {}
> >       },
> >       "id": "18a42c9b-a357-4ca5-8248-ef36b85b04b1",
> >       "name": "Inbound text?",
> >       "type": "n8n-nodes-base.if",
> >       "typeVersion": 2.2,
> >       "position": [
> >         440,
> >         0
> >       ]
> >     },
> >     {
> >       "parameters": {
> >         "resource": "message",
> >         "operation": "send",
> >         "destinationNumber": "={{ $json.from }}",
> >         "additionalFields": {
> >           "text": "=We got your message: {{ $json.text }}"
> >         }
> >       },
> >       "id": "62f78bb2-ce51-414e-a398-e48c1e7d4473",
> >       "name": "Reply",
> >       "type": "n8n-nodes-pilot-status.pilotStatus",
> >       "typeVersion": 1,
> >       "position": [
> >         660,
> >         0
> >       ]
> >     }
> >   ],
> >   "connections": {
> >     "Pilot Status Trigger": {
> >       "main": [
> >         [
> >           {
> >             "node": "Normalize",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     },
> >     "Normalize": {
> >       "main": [
> >         [
> >           {
> >             "node": "Inbound text?",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     },
> >     "Inbound text?": {
> >       "main": [
> >         [
> >           {
> >             "node": "Reply",
> >             "type": "main",
> >             "index": 0
> >           }
> >         ]
> >       ]
> >     }
> >   },
> >   "pinData": {},
> >   "settings": {
> >     "executionOrder": "v1"
> >   }
> > }
> > ```

> [!TIP]
>
> Not sure which kind your number is? [`GET /v1/numbers`](https://docs.pilotstatus.com.br/api/numbers/list) returns its `provider`, and the number's card in the dashboard says how it was connected.

## Recipe 1: template with buttons, reply on tap

You send an approved template with two quick-reply buttons, **Confirm** and **Reschedule**. When the contact taps one, the workflow answers with a different message for each button.

* **Start → Send template** sends the template. Swap the Manual Trigger for whatever starts your flow (a form, a CRM, a schedule).
* **Pilot Status Trigger → Normalize → Which button?** routes the tap by the button's **label**. The label works on every kind of number; `buttonId` is not always reported for template buttons.
* **Reply: …** answers with free text. The tap opens WhatsApp's 24-hour service window, so a free-text reply is allowed even on an official number.

What to change: `templateId` (`appointment_confirmation`), the destination number, the variables, and the two labels in **Which button?**, which must match the template's buttons exactly (case is ignored).

> [accordion] Workflow JSON — recipe 1
>
> ```json theme={null}
> {
>   "name": "Pilot Status - Template with buttons, reply on tap",
>   "nodes": [
>     {
>       "parameters": {},
>       "id": "d9405db4-2168-4e47-860b-ebc100ca112f",
>       "name": "Start",
>       "type": "n8n-nodes-base.manualTrigger",
>       "typeVersion": 1,
>       "position": [
>         0,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "resource": "message",
>         "operation": "send",
>         "templateId": "appointment_confirmation",
>         "destinationNumber": "+5511999999999",
>         "variablesMode": "json",
>         "variablesJson": "{ \"name\": \"Maria\" }"
>       },
>       "id": "2e927538-6048-444c-af1d-cfb60bd10c87",
>       "name": "Send template",
>       "type": "n8n-nodes-pilot-status.pilotStatus",
>       "typeVersion": 1,
>       "position": [
>         220,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "event": "*"
>       },
>       "id": "be6fd184-a920-4181-99ea-9b286718e4ad",
>       "name": "Pilot Status Trigger",
>       "type": "n8n-nodes-pilot-status.pilotStatusTrigger",
>       "typeVersion": 1,
>       "position": [
>         0,
>         220
>       ],
>       "webhookId": "93d7eac1-d572-4bc1-8380-6f396b99b989"
>     },
>     {
>       "parameters": {
>         "jsCode": "// Turns every webhook format into the same flat item:\n// - Pilot Status API (QR code) numbers send { event, data }\n// - Evolution GO layer numbers send Evolution GO events (\"Message\", \"SendMessage\", ...)\n// - Evolution v2 layer numbers send Evolution v2 events (\"messages.upsert\", ...)\n// - Meta Cloud API (official) numbers send Meta's native envelope { object, entry }\nconst phoneOf = (jid) =>\n  typeof jid === 'string' && jid.endsWith('@s.whatsapp.net') ? '+' + jid.split('@')[0].split(':')[0] : '';\n\n// Evolution GO and v2 carry the same WhatsApp message object\nconst readWaMessage = (m = {}) => ({\n  text:\n    m.conversation ??\n    m.extendedTextMessage?.text ??\n    m.buttonsResponseMessage?.selectedDisplayText ??\n    m.templateButtonReplyMessage?.selectedDisplayText ??\n    m.listResponseMessage?.title ??\n    m.imageMessage?.caption ??\n    m.videoMessage?.caption ??\n    '',\n  buttonId:\n    m.buttonsResponseMessage?.selectedButtonId ??\n    m.templateButtonReplyMessage?.selectedId ??\n    m.listResponseMessage?.singleSelectReply?.selectedRowId ??\n    '',\n  quotedMessageId:\n    m.extendedTextMessage?.contextInfo?.stanzaId ??\n    m.buttonsResponseMessage?.contextInfo?.stanzaId ??\n    m.templateButtonReplyMessage?.contextInfo?.stanzaId ??\n    m.listResponseMessage?.contextInfo?.stanzaId ??\n    '',\n});\n\nreturn $input.all().map(({ json }) => {\n  // Meta Cloud API (official)\n  if (json.entry) {\n    const value = json.entry[0]?.changes?.[0]?.value ?? {};\n    const msg = value.messages?.[0];\n    return {\n      json: {\n        source: 'meta',\n        isInbound: Boolean(msg),\n        from: msg ? '+' + msg.from : '',\n        name: value.contacts?.[0]?.profile?.name ?? '',\n        text:\n          msg?.text?.body ??\n          msg?.button?.text ??\n          msg?.interactive?.button_reply?.title ??\n          msg?.interactive?.list_reply?.title ??\n          '',\n        buttonId:\n          msg?.button?.payload ??\n          msg?.interactive?.button_reply?.id ??\n          msg?.interactive?.list_reply?.id ??\n          '',\n        quotedMessageId: msg?.context?.id ?? '',\n      },\n    };\n  }\n\n  // Evolution v2 layer\n  if (json.event === 'messages.upsert') {\n    const d = json.data ?? {};\n    const jid = d.key?.remoteJidAlt || d.key?.remoteJid;\n    const from = phoneOf(jid);\n    return {\n      json: {\n        source: 'evolution-v2',\n        isInbound: Boolean(from) && !d.key?.fromMe,\n        from,\n        name: d.pushName ?? '',\n        ...readWaMessage(d.message),\n      },\n    };\n  }\n\n  // Evolution GO layer\n  if (json.event === 'Message' || json.event === 'MESSAGES_UPSERT') {\n    const info = json.data?.Info ?? {};\n    const from = phoneOf(info.Chat) || phoneOf(info.SenderAlt);\n    return {\n      json: {\n        source: 'evolution-go',\n        isInbound: Boolean(from) && !info.IsFromMe && !info.IsGroup,\n        from,\n        name: info.PushName ?? '',\n        ...readWaMessage(json.data?.Message),\n      },\n    };\n  }\n\n  // Pilot Status API (QR code)\n  const data = json.data ?? {};\n  return {\n    json: {\n      source: 'pilot-status',\n      isInbound: ['message.received', 'message.reply'].includes(json.event) && !data.fromMe,\n      from: data.from ?? '',\n      name: data.participantName ?? '',\n      text: data.content ?? '',\n      buttonId: data.buttonId ?? '',\n      quotedMessageId: data.quotedMessageId ?? '',\n    },\n  };\n});"
>       },
>       "id": "9297877d-24eb-4f49-a8ec-17c2fbd18af0",
>       "name": "Normalize",
>       "type": "n8n-nodes-base.code",
>       "typeVersion": 2,
>       "position": [
>         220,
>         220
>       ]
>     },
>     {
>       "parameters": {
>         "rules": {
>           "values": [
>             {
>               "conditions": {
>                 "options": {
>                   "caseSensitive": false,
>                   "leftValue": "",
>                   "typeValidation": "loose",
>                   "version": 2
>                 },
>                 "conditions": [
>                   {
>                     "id": "8e20f736-4a65-4b93-b967-f04702394e31",
>                     "leftValue": "={{ $json.isInbound }}",
>                     "rightValue": "",
>                     "operator": {
>                       "type": "boolean",
>                       "operation": "true",
>                       "singleValue": true
>                     }
>                   },
>                   {
>                     "id": "781fd0a4-ec38-4988-966d-7630be6e0b42",
>                     "leftValue": "={{ $json.text }}",
>                     "rightValue": "Confirm",
>                     "operator": {
>                       "type": "string",
>                       "operation": "equals"
>                     }
>                   }
>                 ],
>                 "combinator": "and"
>               },
>               "renameOutput": true,
>               "outputKey": "Confirm"
>             },
>             {
>               "conditions": {
>                 "options": {
>                   "caseSensitive": false,
>                   "leftValue": "",
>                   "typeValidation": "loose",
>                   "version": 2
>                 },
>                 "conditions": [
>                   {
>                     "id": "e16c2b86-1e39-4bfd-9429-f94383c8498e",
>                     "leftValue": "={{ $json.isInbound }}",
>                     "rightValue": "",
>                     "operator": {
>                       "type": "boolean",
>                       "operation": "true",
>                       "singleValue": true
>                     }
>                   },
>                   {
>                     "id": "c26de18c-39c6-496a-9ea5-7c247f39ecd3",
>                     "leftValue": "={{ $json.text }}",
>                     "rightValue": "Reschedule",
>                     "operator": {
>                       "type": "string",
>                       "operation": "equals"
>                     }
>                   }
>                 ],
>                 "combinator": "and"
>               },
>               "renameOutput": true,
>               "outputKey": "Reschedule"
>             }
>           ]
>         },
>         "options": {}
>       },
>       "id": "a8b82978-f031-4cdc-a8bc-0df2ec27dbf3",
>       "name": "Which button?",
>       "type": "n8n-nodes-base.switch",
>       "typeVersion": 3.2,
>       "position": [
>         440,
>         220
>       ]
>     },
>     {
>       "parameters": {
>         "resource": "message",
>         "operation": "send",
>         "destinationNumber": "={{ $json.from }}",
>         "additionalFields": {
>           "text": "Great, your appointment is confirmed. See you there!"
>         }
>       },
>       "id": "c3e070fd-e173-48ea-9744-8c08e02789e1",
>       "name": "Reply: confirmed",
>       "type": "n8n-nodes-pilot-status.pilotStatus",
>       "typeVersion": 1,
>       "position": [
>         660,
>         140
>       ]
>     },
>     {
>       "parameters": {
>         "resource": "message",
>         "operation": "send",
>         "destinationNumber": "={{ $json.from }}",
>         "additionalFields": {
>           "text": "No problem. Reply with the day and time that work best for you."
>         }
>       },
>       "id": "9e63a14f-84cb-42eb-91f9-3e30be64e4c3",
>       "name": "Reply: reschedule",
>       "type": "n8n-nodes-pilot-status.pilotStatus",
>       "typeVersion": 1,
>       "position": [
>         660,
>         300
>       ]
>     }
>   ],
>   "connections": {
>     "Start": {
>       "main": [
>         [
>           {
>             "node": "Send template",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Pilot Status Trigger": {
>       "main": [
>         [
>           {
>             "node": "Normalize",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Normalize": {
>       "main": [
>         [
>           {
>             "node": "Which button?",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Which button?": {
>       "main": [
>         [
>           {
>             "node": "Reply: confirmed",
>             "type": "main",
>             "index": 0
>           }
>         ],
>         [
>           {
>             "node": "Reply: reschedule",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     }
>   },
>   "pinData": {},
>   "settings": {
>     "executionOrder": "v1"
>   }
> }
> ```

## Recipe 2: AI agent answers inbound messages

Every text a contact sends goes to an n8n AI Agent with a per-contact memory, and the answer goes back on WhatsApp.

* **Inbound text?** lets through only messages the contact sent. Without it, the echo of the agent's own answer would start the workflow again.
* **Memory per contact** uses the contact's number as the session key, so each conversation has its own history.
* **Send answer** sends `$json.output`, the agent's reply, as free text. It is a reply inside the 24-hour window the contact just opened.

What to change: the system message of **AI Agent**, the model, and the OpenAI credential (or replace the model node with any other chat model).

> [!TIP]
>
> Group messages arrive as `message.group` and are not handled here, so the agent does not answer in groups.

> [accordion] Workflow JSON — recipe 2
>
> ```json theme={null}
> {
>   "name": "Pilot Status - AI agent answers inbound messages",
>   "nodes": [
>     {
>       "parameters": {
>         "event": "*"
>       },
>       "id": "da435aa2-aab1-4f04-a9a0-70e5e2884152",
>       "name": "Pilot Status Trigger",
>       "type": "n8n-nodes-pilot-status.pilotStatusTrigger",
>       "typeVersion": 1,
>       "position": [
>         0,
>         0
>       ],
>       "webhookId": "440e3062-2018-4f1b-8503-f139f42394b9"
>     },
>     {
>       "parameters": {
>         "jsCode": "// Turns every webhook format into the same flat item:\n// - Pilot Status API (QR code) numbers send { event, data }\n// - Evolution GO layer numbers send Evolution GO events (\"Message\", \"SendMessage\", ...)\n// - Evolution v2 layer numbers send Evolution v2 events (\"messages.upsert\", ...)\n// - Meta Cloud API (official) numbers send Meta's native envelope { object, entry }\nconst phoneOf = (jid) =>\n  typeof jid === 'string' && jid.endsWith('@s.whatsapp.net') ? '+' + jid.split('@')[0].split(':')[0] : '';\n\n// Evolution GO and v2 carry the same WhatsApp message object\nconst readWaMessage = (m = {}) => ({\n  text:\n    m.conversation ??\n    m.extendedTextMessage?.text ??\n    m.buttonsResponseMessage?.selectedDisplayText ??\n    m.templateButtonReplyMessage?.selectedDisplayText ??\n    m.listResponseMessage?.title ??\n    m.imageMessage?.caption ??\n    m.videoMessage?.caption ??\n    '',\n  buttonId:\n    m.buttonsResponseMessage?.selectedButtonId ??\n    m.templateButtonReplyMessage?.selectedId ??\n    m.listResponseMessage?.singleSelectReply?.selectedRowId ??\n    '',\n  quotedMessageId:\n    m.extendedTextMessage?.contextInfo?.stanzaId ??\n    m.buttonsResponseMessage?.contextInfo?.stanzaId ??\n    m.templateButtonReplyMessage?.contextInfo?.stanzaId ??\n    m.listResponseMessage?.contextInfo?.stanzaId ??\n    '',\n});\n\nreturn $input.all().map(({ json }) => {\n  // Meta Cloud API (official)\n  if (json.entry) {\n    const value = json.entry[0]?.changes?.[0]?.value ?? {};\n    const msg = value.messages?.[0];\n    return {\n      json: {\n        source: 'meta',\n        isInbound: Boolean(msg),\n        from: msg ? '+' + msg.from : '',\n        name: value.contacts?.[0]?.profile?.name ?? '',\n        text:\n          msg?.text?.body ??\n          msg?.button?.text ??\n          msg?.interactive?.button_reply?.title ??\n          msg?.interactive?.list_reply?.title ??\n          '',\n        buttonId:\n          msg?.button?.payload ??\n          msg?.interactive?.button_reply?.id ??\n          msg?.interactive?.list_reply?.id ??\n          '',\n        quotedMessageId: msg?.context?.id ?? '',\n      },\n    };\n  }\n\n  // Evolution v2 layer\n  if (json.event === 'messages.upsert') {\n    const d = json.data ?? {};\n    const jid = d.key?.remoteJidAlt || d.key?.remoteJid;\n    const from = phoneOf(jid);\n    return {\n      json: {\n        source: 'evolution-v2',\n        isInbound: Boolean(from) && !d.key?.fromMe,\n        from,\n        name: d.pushName ?? '',\n        ...readWaMessage(d.message),\n      },\n    };\n  }\n\n  // Evolution GO layer\n  if (json.event === 'Message' || json.event === 'MESSAGES_UPSERT') {\n    const info = json.data?.Info ?? {};\n    const from = phoneOf(info.Chat) || phoneOf(info.SenderAlt);\n    return {\n      json: {\n        source: 'evolution-go',\n        isInbound: Boolean(from) && !info.IsFromMe && !info.IsGroup,\n        from,\n        name: info.PushName ?? '',\n        ...readWaMessage(json.data?.Message),\n      },\n    };\n  }\n\n  // Pilot Status API (QR code)\n  const data = json.data ?? {};\n  return {\n    json: {\n      source: 'pilot-status',\n      isInbound: ['message.received', 'message.reply'].includes(json.event) && !data.fromMe,\n      from: data.from ?? '',\n      name: data.participantName ?? '',\n      text: data.content ?? '',\n      buttonId: data.buttonId ?? '',\n      quotedMessageId: data.quotedMessageId ?? '',\n    },\n  };\n});"
>       },
>       "id": "9ba05ad6-ad02-4044-8d34-ed4bb80c1cbe",
>       "name": "Normalize",
>       "type": "n8n-nodes-base.code",
>       "typeVersion": 2,
>       "position": [
>         220,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "conditions": {
>           "options": {
>             "caseSensitive": true,
>             "leftValue": "",
>             "typeValidation": "loose",
>             "version": 2
>           },
>           "conditions": [
>             {
>               "id": "a6a20783-8999-40db-b4de-054e4238d28b",
>               "leftValue": "={{ $json.isInbound }}",
>               "rightValue": "",
>               "operator": {
>                 "type": "boolean",
>                 "operation": "true",
>                 "singleValue": true
>               }
>             },
>             {
>               "id": "49bb0415-af44-4ca9-9fc9-0955eaeae834",
>               "leftValue": "={{ $json.text }}",
>               "rightValue": "",
>               "operator": {
>                 "type": "string",
>                 "operation": "notEmpty",
>                 "singleValue": true
>               }
>             }
>           ],
>           "combinator": "and"
>         },
>         "options": {}
>       },
>       "id": "1088567a-6a9e-4166-bcce-94b4cda20d2c",
>       "name": "Inbound text?",
>       "type": "n8n-nodes-base.if",
>       "typeVersion": 2.2,
>       "position": [
>         440,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "promptType": "define",
>         "text": "={{ $json.text }}",
>         "options": {
>           "systemMessage": "You are the WhatsApp assistant of our store. Answer in the customer's language, in at most 3 short sentences. If you do not know the answer, say a human will reply soon."
>         }
>       },
>       "id": "f66a3f64-d3af-41a4-80d2-378acae89d04",
>       "name": "AI Agent",
>       "type": "@n8n/n8n-nodes-langchain.agent",
>       "typeVersion": 1.7,
>       "position": [
>         660,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "model": {
>           "__rl": true,
>           "mode": "list",
>           "value": "gpt-4o-mini"
>         },
>         "options": {}
>       },
>       "id": "16d13999-4d4a-48fb-8eed-3f6b033ae995",
>       "name": "OpenAI Chat Model",
>       "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
>       "typeVersion": 1.2,
>       "position": [
>         600,
>         220
>       ]
>     },
>     {
>       "parameters": {
>         "sessionIdType": "customKey",
>         "sessionKey": "={{ $('Normalize').item.json.from }}",
>         "contextWindowLength": 10
>       },
>       "id": "5878622d-477f-46e5-b99f-8dbbcf6f8cbf",
>       "name": "Memory per contact",
>       "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
>       "typeVersion": 1.3,
>       "position": [
>         760,
>         220
>       ]
>     },
>     {
>       "parameters": {
>         "resource": "message",
>         "operation": "send",
>         "destinationNumber": "={{ $('Normalize').item.json.from }}",
>         "additionalFields": {
>           "text": "={{ $json.output }}"
>         }
>       },
>       "id": "21e8ca9a-a2b6-4ca9-a7cc-bba8aff47991",
>       "name": "Send answer",
>       "type": "n8n-nodes-pilot-status.pilotStatus",
>       "typeVersion": 1,
>       "position": [
>         960,
>         0
>       ]
>     }
>   ],
>   "connections": {
>     "Pilot Status Trigger": {
>       "main": [
>         [
>           {
>             "node": "Normalize",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Normalize": {
>       "main": [
>         [
>           {
>             "node": "Inbound text?",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Inbound text?": {
>       "main": [
>         [
>           {
>             "node": "AI Agent",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "AI Agent": {
>       "main": [
>         [
>           {
>             "node": "Send answer",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "OpenAI Chat Model": {
>       "ai_languageModel": [
>         [
>           {
>             "node": "AI Agent",
>             "type": "ai_languageModel",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Memory per contact": {
>       "ai_memory": [
>         [
>           {
>             "node": "AI Agent",
>             "type": "ai_memory",
>             "index": 0
>           }
>         ]
>       ]
>     }
>   },
>   "pinData": {},
>   "settings": {
>     "executionOrder": "v1"
>   }
> }
> ```

## Recipe 3: send a template to every row of a sheet

Every day at 9:00, the workflow reads a Google Sheet, sends a template to each row that was not sent yet, and writes the time of the send back to the row.

Create a tab named **Contacts** with these columns:

| `phone` | `name` | `orderId` | `sent` |
| - | - | - | - |
| `+5511999999999` | Ana | `A-1001` | |

* **Not sent yet?** skips rows whose `sent` column is filled in.
* **Send template** passes `name` and `orderId` as template variables. The keys of the JSON must match the template's variable names.
* **Idempotency Key** is `orderId-phone`. When n8n retries the node (it is set to try 3 times), or the workflow runs again before the sheet is updated, the API returns the first response instead of sending twice. See [Idempotency](https://docs.pilotstatus.com.br/api/messages/send.md#idempotency).
* **Mark row as sent** finds the row by `orderId` and fills in `sent`.

What to change: `YOUR_SPREADSHEET_ID` (the id in the sheet's URL), the template, and the variables.

> [accordion] Workflow JSON — recipe 3
>
> ```json theme={null}
> {
>   "name": "Pilot Status - Send a template to every pending row of a Google Sheet",
>   "nodes": [
>     {
>       "parameters": {
>         "rule": {
>           "interval": [
>             {
>               "triggerAtHour": 9
>             }
>           ]
>         }
>       },
>       "id": "0861ae0b-2f35-478c-a7bb-84f458bbad2b",
>       "name": "Every day at 9:00",
>       "type": "n8n-nodes-base.scheduleTrigger",
>       "typeVersion": 1.2,
>       "position": [
>         0,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "operation": "read",
>         "documentId": {
>           "__rl": true,
>           "mode": "id",
>           "value": "YOUR_SPREADSHEET_ID"
>         },
>         "sheetName": {
>           "__rl": true,
>           "mode": "name",
>           "value": "Contacts"
>         },
>         "options": {}
>       },
>       "id": "87502aeb-76ec-4ed1-9b3d-2f8a9eefd900",
>       "name": "Read contacts",
>       "type": "n8n-nodes-base.googleSheets",
>       "typeVersion": 4.5,
>       "position": [
>         220,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "conditions": {
>           "options": {
>             "caseSensitive": true,
>             "leftValue": "",
>             "typeValidation": "loose",
>             "version": 2
>           },
>           "conditions": [
>             {
>               "id": "1cb1b289-29b8-4a5e-9bf5-4e2e2159a5e8",
>               "leftValue": "={{ $json.sent }}",
>               "rightValue": "",
>               "operator": {
>                 "type": "string",
>                 "operation": "empty",
>                 "singleValue": true
>               }
>             }
>           ],
>           "combinator": "and"
>         },
>         "options": {}
>       },
>       "id": "38e9d0c6-b9e0-4314-9f1e-249b73458630",
>       "name": "Not sent yet?",
>       "type": "n8n-nodes-base.if",
>       "typeVersion": 2.2,
>       "position": [
>         440,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "resource": "message",
>         "operation": "send",
>         "templateId": "order_shipped",
>         "destinationNumber": "={{ $json.phone }}",
>         "variablesMode": "json",
>         "variablesJson": "={{ JSON.stringify({ name: $json.name, order: $json.orderId }) }}",
>         "additionalFields": {
>           "idempotencyKey": "={{ $json.orderId }}-{{ $json.phone }}"
>         }
>       },
>       "id": "7ea2e35f-5e56-48c0-909b-234746477b3a",
>       "name": "Send template",
>       "type": "n8n-nodes-pilot-status.pilotStatus",
>       "typeVersion": 1,
>       "position": [
>         660,
>         0
>       ],
>       "retryOnFail": true,
>       "maxTries": 3,
>       "waitBetweenTries": 5000
>     },
>     {
>       "parameters": {
>         "operation": "update",
>         "documentId": {
>           "__rl": true,
>           "mode": "id",
>           "value": "YOUR_SPREADSHEET_ID"
>         },
>         "sheetName": {
>           "__rl": true,
>           "mode": "name",
>           "value": "Contacts"
>         },
>         "columns": {
>           "mappingMode": "defineBelow",
>           "value": {
>             "orderId": "={{ $('Not sent yet?').item.json.orderId }}",
>             "sent": "={{ $now.toISO() }}"
>           },
>           "matchingColumns": [
>             "orderId"
>           ],
>           "schema": [
>             {
>               "id": "orderId",
>               "displayName": "orderId",
>               "required": false,
>               "defaultMatch": false,
>               "display": true,
>               "type": "string",
>               "canBeUsedToMatch": true
>             },
>             {
>               "id": "sent",
>               "displayName": "sent",
>               "required": false,
>               "defaultMatch": false,
>               "display": true,
>               "type": "string",
>               "canBeUsedToMatch": true
>             }
>           ]
>         },
>         "options": {}
>       },
>       "id": "d5b5ae54-cddb-40e3-b1bc-abbbb41b994d",
>       "name": "Mark row as sent",
>       "type": "n8n-nodes-base.googleSheets",
>       "typeVersion": 4.5,
>       "position": [
>         880,
>         0
>       ]
>     }
>   ],
>   "connections": {
>     "Every day at 9:00": {
>       "main": [
>         [
>           {
>             "node": "Read contacts",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Read contacts": {
>       "main": [
>         [
>           {
>             "node": "Not sent yet?",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Not sent yet?": {
>       "main": [
>         [
>           {
>             "node": "Send template",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Send template": {
>       "main": [
>         [
>           {
>             "node": "Mark row as sent",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     }
>   },
>   "pinData": {},
>   "settings": {
>     "executionOrder": "v1"
>   }
> }
> ```

## Recipe 4: e-mail alert for failed messages

Every 15 minutes, the workflow lists the last 100 failed outbound messages and e-mails the team about each one it has not seen before.

It polls [`GET /v1/messages`](https://docs.pilotstatus.com.br/api/messages/list) instead of listening to `message.failed`, because the webhook does not cover every case: an official number never sends `message.failed` (failures arrive inside Meta's `statuses[]`), and some failures reach no webhook at all. The log has every failure, on every kind of number.

* **One item per message** splits the API's `data` list into one item per message.
* **Only new failures** remembers the message ids it has already seen across executions, so each failure is reported once.
* The e-mail shows the `errorCode` and the reason. The [error code catalog](https://docs.pilotstatus.com.br/api/messages/log-error-codes.md) explains each code.

What to change: the SMTP credential and the two e-mail addresses. To alert on Slack or Telegram instead, replace the last node.

> [!NOTE]
>
> On the first run every failure in the list is new, so you get up to 100 e-mails. Run it once by hand with the e-mail node disabled to fill the memory first.

> [accordion] Workflow JSON — recipe 4
>
> ```json theme={null}
> {
>   "name": "Pilot Status - E-mail alert for failed messages",
>   "nodes": [
>     {
>       "parameters": {
>         "rule": {
>           "interval": [
>             {
>               "field": "minutes",
>               "minutesInterval": 15
>             }
>           ]
>         }
>       },
>       "id": "480631e3-492a-44c4-ab04-f5821a878769",
>       "name": "Every 15 minutes",
>       "type": "n8n-nodes-base.scheduleTrigger",
>       "typeVersion": 1.2,
>       "position": [
>         0,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "resource": "message",
>         "operation": "getAll",
>         "listPageSize": 100,
>         "listDirection": "out",
>         "listStatus": "FAILED"
>       },
>       "id": "1a4fa869-08fc-4518-8f2c-6913055c1221",
>       "name": "List failed messages",
>       "type": "n8n-nodes-pilot-status.pilotStatus",
>       "typeVersion": 1,
>       "position": [
>         220,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "fieldToSplitOut": "data",
>         "options": {}
>       },
>       "id": "77b9d749-73b4-41ef-a1b7-f744e003e378",
>       "name": "One item per message",
>       "type": "n8n-nodes-base.splitOut",
>       "typeVersion": 1,
>       "position": [
>         440,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "operation": "removeItemsSeenInPreviousExecutions",
>         "dedupeValue": "={{ $json.id }}",
>         "options": {}
>       },
>       "id": "d087df39-fa3b-45ed-aabe-8b251ba1b910",
>       "name": "Only new failures",
>       "type": "n8n-nodes-base.removeDuplicates",
>       "typeVersion": 2,
>       "position": [
>         660,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "fromEmail": "alerts@example.com",
>         "toEmail": "team@example.com",
>         "subject": "=WhatsApp message failed: {{ $json.errorCode }} to {{ $json.to }}",
>         "emailFormat": "text",
>         "text": "=To: {{ $json.to }}\nTemplate: {{ $json.template }}\nError code: {{ $json.errorCode }}\nReason: {{ $json.errorMessage }}\nCreated at: {{ $json.createdAt }}\nMessage id: {{ $json.id }}",
>         "options": {}
>       },
>       "id": "bc3a4e74-46bd-4f80-a83a-809b42f07fee",
>       "name": "E-mail the team",
>       "type": "n8n-nodes-base.emailSend",
>       "typeVersion": 2.1,
>       "position": [
>         880,
>         0
>       ]
>     }
>   ],
>   "connections": {
>     "Every 15 minutes": {
>       "main": [
>         [
>           {
>             "node": "List failed messages",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "List failed messages": {
>       "main": [
>         [
>           {
>             "node": "One item per message",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "One item per message": {
>       "main": [
>         [
>           {
>             "node": "Only new failures",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Only new failures": {
>       "main": [
>         [
>           {
>             "node": "E-mail the team",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     }
>   },
>   "pinData": {},
>   "settings": {
>     "executionOrder": "v1"
>   }
> }
> ```

## Recipe 5: save WhatsApp Flow answers to a sheet

Each time someone submits a [WhatsApp Flow](https://docs.pilotstatus.com.br/guides/flow-responses.md), the answers become a new row of a Google Sheet.

`flow.response_received` keeps the Pilot Status `{ event, data }` format even on official numbers, so here the Trigger can listen to that one event and no Normalize node is needed.

* **Answers to columns** keeps the time, the contact's number, the Flow id, and the answers as JSON text. On a Flow with a data endpoint, what the person typed is in `submitted`, one entry per screen; otherwise it is in `response`.
* **Append to sheet** writes one row per submission. Create a tab named **Flow answers** with the columns `receivedAt`, `phone`, `flowId` and `answers`.

What to change: `YOUR_SPREADSHEET_ID`. To get one column per question, replace the `answers` field with one field per answer, for example `{{ $json.data.response.nota }}`.

> [accordion] Workflow JSON — recipe 5
>
> ```json theme={null}
> {
>   "name": "Pilot Status - Save WhatsApp Flow answers to Google Sheets",
>   "nodes": [
>     {
>       "parameters": {
>         "event": "flow.response_received"
>       },
>       "id": "a0a5acf6-9e23-46ad-9dfb-c148fc87874a",
>       "name": "Pilot Status Trigger",
>       "type": "n8n-nodes-pilot-status.pilotStatusTrigger",
>       "typeVersion": 1,
>       "position": [
>         0,
>         0
>       ],
>       "webhookId": "92d6463a-af61-4c63-88ce-eda05a9663f0"
>     },
>     {
>       "parameters": {
>         "assignments": {
>           "assignments": [
>             {
>               "id": "9a308cdc-92e9-4c35-b31d-ef6b93aae7e9",
>               "name": "receivedAt",
>               "value": "={{ $json.data.receivedAt }}",
>               "type": "string"
>             },
>             {
>               "id": "562df8d4-235e-4645-ba8c-10b9e360c857",
>               "name": "phone",
>               "value": "={{ $json.data.from }}",
>               "type": "string"
>             },
>             {
>               "id": "9aa14f89-3dd6-4fcb-a3a3-a4431ef219f4",
>               "name": "flowId",
>               "value": "={{ $json.data.flowId }}",
>               "type": "string"
>             },
>             {
>               "id": "a140efdd-024d-4662-aeb5-67eb975bfc79",
>               "name": "answers",
>               "value": "={{ JSON.stringify($json.data.submitted ? $json.data.submitted.map(s => s.data) : $json.data.response) }}",
>               "type": "string"
>             }
>           ]
>         },
>         "options": {}
>       },
>       "id": "366408ee-b059-4bee-9fe9-3e702150ebb3",
>       "name": "Answers to columns",
>       "type": "n8n-nodes-base.set",
>       "typeVersion": 3.4,
>       "position": [
>         220,
>         0
>       ]
>     },
>     {
>       "parameters": {
>         "operation": "append",
>         "documentId": {
>           "__rl": true,
>           "mode": "id",
>           "value": "YOUR_SPREADSHEET_ID"
>         },
>         "sheetName": {
>           "__rl": true,
>           "mode": "name",
>           "value": "Flow answers"
>         },
>         "columns": {
>           "mappingMode": "autoMapInputData",
>           "value": {},
>           "matchingColumns": [],
>           "schema": []
>         },
>         "options": {}
>       },
>       "id": "5ae1e8e6-9a49-40fa-9f5a-ceb9e49276f6",
>       "name": "Append to sheet",
>       "type": "n8n-nodes-base.googleSheets",
>       "typeVersion": 4.5,
>       "position": [
>         440,
>         0
>       ]
>     }
>   ],
>   "connections": {
>     "Pilot Status Trigger": {
>       "main": [
>         [
>           {
>             "node": "Answers to columns",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     },
>     "Answers to columns": {
>       "main": [
>         [
>           {
>             "node": "Append to sheet",
>             "type": "main",
>             "index": 0
>           }
>         ]
>       ]
>     }
>   },
>   "pinData": {},
>   "settings": {
>     "executionOrder": "v1"
>   }
> }
> ```

## Troubleshooting

| Symptom | Cause | Fix |
| - | - | - |
| The Trigger never fires | The workflow is inactive (Production URL), or the webhook was registered with the Test URL | Activate the workflow and register the **Production URL** |
| The Trigger answers `200 Ignored event` | **Event** is set to a specific event, and the delivered body is a different event or Meta's envelope | Use **All Events** and filter in the workflow |
| Button taps do nothing on a QR-code number | The Trigger listens to **Message Received** | Taps arrive as `message.reply`: use **All Events** |
| `$json.data` is `undefined` | The number is official, and the body is Meta's envelope | Add the **Normalize** node |
| `401 Invalid signature` | The **Signing Secret** does not match the webhook | Paste the current secret, or rotate it and paste the new one |
| `403 TENANT_SCOPE_NOT_ALLOWED` | Workspace or account key without a number | Fill in **WhatsApp Number ID** in the credential |
| `400 WORKSPACE_ID_REQUIRED` | Account key (`ps_account_`) without a workspace | Fill in **Workspace ID** in the credential |
| Automatic registration fails with `400 NUMBER_REQUIRED` | Workspace or account key without a number | Fill in **WhatsApp Number ID** in the credential |
| The answer comes from another number | The webhook and the credential belong to different numbers | Use the same number in both |

## Related

* [Webhook events](https://docs.pilotstatus.com.br/api/webhooks/events.md)
* [Send a message](https://docs.pilotstatus.com.br/api/messages/send.md)
* [SDKs](https://docs.pilotstatus.com.br/integrations/sdks.md)
* [MCP Server](https://docs.pilotstatus.com.br/integrations/mcp-server.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.