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

# automate-notifyer

> Automation scripts for templates, AI bots, broadcasts, analytics, and webhooks — including outgoing WhatsApp Business app messages (coexistence).

<Tip>
  `automate-notifyer` builds on `setup-notifyer`. Always run `setup-notifyer/scripts/doctor.js` before sending templates, creating broadcasts, or configuring webhooks.
</Tip>

## What this skill covers

* **Templates**: create/list/get/delete; monitor Meta approval lifecycle
* **AI bots**: create/update/delete bots; set default bot
* **Broadcasts**: create/schedule campaigns using template + recipient CSV
* **Analytics & logs**: read rates, delivery rates, message logs
* **Webhooks**: create/update/delete **dev** and **IO** webhooks; optional HMAC signatures; `--incoming` and `--outgoing` so events include messages typed in the WhatsApp Business app

## Prerequisites

<Warning>
  Some features require a Pro or Agency plan (and an OpenAI key configured in Notifyer settings for bots). If you’re not sure, check with `setup-notifyer/scripts/get-user-plan.js`.
</Warning>

## Setup

```bash theme={null}
cd skills/automate-notifyer
export NOTIFYER_API_BASE_URL="https://api.insightssystem.com"
export NOTIFYER_API_TOKEN="eyJ..."
```

## Templates

List templates:

```bash theme={null}
node scripts/list-templates.js --pretty
node scripts/list-templates.js --status approved --pretty
```

Create a template (text with variables):

```bash theme={null}
node scripts/create-template.js \
  --name order_confirmation \
  --category MARKETING \
  --body "Hello {{1}}, your order #{{2}} is confirmed." \
  --variables '{"1":"John","2":"12345"}'
```

<Tip>
  `list-templates.js` auto-syncs `PENDING` template statuses from Meta on each call — you can re-run it to observe approval changes.
</Tip>

Delete a template:

```bash theme={null}
node scripts/delete-template.js --id 987654321 --confirm
```

## AI bots

```bash theme={null}
node scripts/list-bots.js --pretty
node scripts/create-bot.js --name "Support Bot" \
  --mission "Help users resolve support issues." \
  --knowledge-base "Return policy: 30 days. Shipping: 3-5 days." \
  --tone "Friendly" --delay 3 \
  --trigger-keywords "agent,human" --notification --default
node scripts/update-bot.js --id 12 --tone "Professional" --delay 5
node scripts/set-default-bot.js --id 12 --pretty
node scripts/delete-bot.js --id 12 --confirm --pretty
```

## Broadcasts

Create and schedule a broadcast (3-step flow):

```bash theme={null}
node scripts/create-broadcast.js \
  --name "January Sale" \
  --template-id 42 \
  --test-phone "+14155550123" \
  --recipients ./recipients.csv \
  --schedule "25/01/2025 14:00" \
  --delivery-mode smart \
  --delivery-size 4
```

<Warning>
  Phone numbers in the CSV must be **integers without `+`**. The schedule format is strictly `DD/MM/YYYY HH:mm` and is timezone-sensitive.
</Warning>

## Analytics & logs

```bash theme={null}
node scripts/get-message-analytics.js --days 30 --pretty
node scripts/get-message-analytics.js --from 2025-01-01 --to 2025-01-31 --pretty
node scripts/get-message-logs.js --filter broadcast --phone 14155550123 --pretty
```

## Webhooks

List webhooks:

```bash theme={null}
node scripts/list-webhooks.js --type dev --pretty
node scripts/list-webhooks.js --type io --pretty
```

Create a dev webhook (Make/Zapier/n8n style) that receives **incoming and outgoing** messages, including replies typed in the WhatsApp Business app:

```bash theme={null}
node scripts/create-webhook.js --type dev \
  --url "https://hook.eu2.make.com/abc" \
  --incoming --outgoing --signature
```

`--outgoing` is required if an automation must react to messages sent from the phone app, the Notifyer chat inbox, or other integrations. Payload fields: `incoming_message`, `send_by`, `was_message_by_human`. Full reference: [Message webhooks](/guides/notifyer-system/api/incoming-message).

## Incoming and outgoing WhatsApp messages

Notifyer delivers **both incoming and outgoing** messages to your webhook or automation trigger — including messages typed by hand in the **WhatsApp Business app** on your phone.

This is possible because Notifyer supports [Meta WhatsApp Coexistence](/guides/notifyer-system/embedding-process#whatsapp-coexistence). You keep using WhatsApp Business on your phone; those hand-typed replies still reach an external webhook and can start an automation. They are not limited to the Notifyer web inbox.

<Frame caption="Trigger n8n (or any webhook) from WhatsApp messages — including replies typed in the WhatsApp Business app">
  <iframe className="w-full aspect-video" src="https://www.youtube.com/embed/UfW-KwS4gBI" title="Trigger n8n workflows with WhatsApp messages" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen" allowFullScreen />
</Frame>

The payload is the same whether you use [n8n](/guides/notifyer-system/n8n-overview), [Make](/guides/notifyer-system/make-overview), [Zapier](/guides/notifyer-system/zapier-overview), or a [custom webhook](/guides/notifyer-system/api/incoming-message). [Watch the walkthrough on YouTube](https://www.youtube.com/watch?v=UfW-KwS4gBI).

### Direction, sending system, and team member

Use these three fields to tell *what happened* and *who sent it*:

<ResponseField name="incoming_message" type="boolean">
  `true` when a contact sent a message **to** your business. `false` when your business sent a message **to** the contact (outgoing). Filter on this field to run logic only for one direction.
</ResponseField>

<ResponseField name="send_by" type="string">
  Which system or person sent an **outgoing** message:

  | `send_by` value                                         | Meaning                                                  |
  | ------------------------------------------------------- | -------------------------------------------------------- |
  | `WhatsApp App`                                          | Typed by hand in the WhatsApp Business app on a phone    |
  | A team member's name (for example `Axel Meta`)          | Sent from the Notifyer chat inbox by that logged-in user |
  | An automation or app name (Make, Zapier, n8n, API, bot) | Sent by that integration or bot                          |

  Empty or omitted on incoming messages.
</ResponseField>

<ResponseField name="was_message_by_human" type="boolean">
  `true` when a person sent the message (WhatsApp Business app or Notifyer chat inbox). `false` when a bot or automation sent it. Combine with `send_by` to see both *whether* a human sent it and *which teammate or system* did.
</ResponseField>

### Example payload: message typed on the phone

This is the JSON Notifyer POSTs when someone types a reply in the WhatsApp Business app. `incoming_message` is `false`, `send_by` is `"WhatsApp App"`, and `was_message_by_human` is `true`.

```json theme={null}
{
  "last_messages": "[{\"type\":\"bot\",\"content\":\"Hello n8n\",\"timestamp\":\"2026-08-15T12:24:47.000Z\",\"content_type\":\"text\"},{\"type\":\"user\",\"content\":\"hi\",\"timestamp\":\"2026-08-12T12:27:42.746Z\",\"content_type\":\"text\"}]",
  "conversation_paragraph": "Bot (12:24:47 PM): Hello n8n ; User (12:27:42 PM): hi",
  "phone_number": 14155552671,
  "recipient_name": "Alex Martinez",
  "user_id": "158c59e1-ea85-4d0b-b70c-65328ba67a8e",
  "last_message_of_user": "hi",
  "last_message_of_bot": "Hello n8n",
  "message_type": "text",
  "user_last_message_time": 1786722580,
  "bot_last_message_time": 1786797014,
  "attachment_url": null,
  "note": "email: alex\nName: Alex",
  "note_automation": "email: alex\nName: Alex",
  "labels": "n8n, webhook-test",
  "incoming_message": false,
  "send_by": "WhatsApp App",
  "was_message_by_human": true
}
```

<Note>
  `last_message_of_bot` is the last message **your business** sent — whether a human typed it in the WhatsApp Business app or the Notifyer inbox, or a bot/automation sent it. `last_messages` is a JSON **string** of the last \~20 messages (parse it before iterating). `phone_number` may arrive as a number rather than a string.
</Note>

When the same person sends from the Notifyer chat inbox instead of the phone app, the payload is identical except:

```json theme={null}
{
  "incoming_message": false,
  "send_by": "Axel Meta",
  "was_message_by_human": true
}
```

Create an IO webhook (bidirectional pipeline style):

```bash theme={null}
node scripts/create-webhook.js --type io \
  --url "https://myapp.com/webhook" \
  --signature
```

Update/delete:

```bash theme={null}
node scripts/update-webhook.js --type dev --id 5 --status false
node scripts/delete-webhook.js --type dev --id 5 --confirm
```

<Tip>
  Dev webhook `id` is an integer. IO webhook `id` is a **text UUID** — treat it as a string.
</Tip>

## Next

* Operate conversations: [`chat-notifyer`](/guides/notifyer-system/agent-skills/chat-notifyer)
* See end-to-end automation flows: [Use cases](/guides/notifyer-system/agent-skills/use-cases)
