# Automations

Source: https://docs.usetone.ai/automations

> Call a shopper when something happens in your store — an abandoned checkout, a cash-on-delivery order — with the steps drawn on a canvas, and every call through the same compliance checks as one you place yourself.

An automation runs once for every event: each abandoned checkout, each cash-on-delivery order. It
waits, decides, calls with one of your agents, and acts on what the call returned. A
[campaign](/campaigns) is different: a list you upload and launch once.

Automations are built in the dashboard, under **Automations**. They have no public API yet, and
they are being switched on for selected organisations. Ask [support](/support) to switch them on
for yours.

An automation is not a second dialling path. Every call it places goes through the same
[pre-dial compliance gate](/compliance), the same call record, the same pricing and the same
[webhooks](/webhooks) as a call you place with `POST /v1/calls`.

## What starts a run

Every automation has one trigger.

- **Shopify.** Connect your store under **Settings → Integrations → Shopify**. A checkout with a
  phone number and no order starts `checkout_abandoned`; a new order starts `order_created`.
- **A checkout provider's webhook**, for checkouts that never reach Shopify (GoKwik, or any system
  that can POST JSON). See [the checkout webhook](#the-checkout-webhook) below.

A trigger can take events from both, so carts from Shopify and from your checkout provider run
through one automation. An automation has one live run per shopper at a time: a second cart from
someone already in a run starts nothing. By default an order from that shopper ends their run and
is credited to it.

## The steps

| Step | What it does |
|---|---|
| Wait | Pauses, for a time you set. |
| Filter | Lets only runs that pass its rules go on. A run that fails ends there, counted under the rule. |
| If / Switch | Picks the next step by rules on the run's data, for example by call outcome. |
| Split | Holds out a share of shoppers who get nothing, so Results can measure what the automation adds. |
| Call with an agent | One of your agents calls the shopper and returns what happened. |
| Chat on WhatsApp | One of your agents chats with the shopper on your WhatsApp number and returns what came of it. |
| Send a WhatsApp template | An approved template from your own number [connected to Tone](/whatsapp), then waits for the shopper's answer. |
| Send a WhatsApp | An approved template from your own WATI, AiSensy or Exotel account. |
| Look up the order | Reads an order's state in Shopify as it is now: cancelled, paid, shipped. |
| Schedule a call | Waits until the time the shopper asked to be called, then goes on. |
| Notify the team | An email to your owners and admins, or a Slack post. |
| Tag the contact | Puts tags on the shopper, or takes them off, as the Inbox shows them. |
| Add to Do-Not-Call | Stops calls and messages to this shopper. |
| Stop | Ends the run. |

Each step's output becomes data later steps can use, written `{{ cart.total }}` or
`{{ call.outcome }}`. There are no code steps and no loops: "call again" is its own step.

### Call with an agent

The call step dials with the agent's live version, from the number you choose, with the agent's
inputs filled from the run's data. Runs wait for the agent's calling hours (9 AM to 9 PM IST for
promotional calls), for a free line, and for the wallet; they never wait for tomorrow when the
day's call limit is reached, because a cart called the next day is stale.

What it returns is the call's own facts, then the agent's
[output variables](/agents) beside them:

| Field | |
|---|---|
| `outcome` | How the call ended: `answered`, `no_answer`, `busy`, `voicemail`, `failed`, `unknown` |
| `duration_s` | Seconds connected |
| `call_id` | The call, for the dashboard and `GET /v1/calls/{id}` |
| `summary` | Two lines for your team |
| `checkout_link` | The link the agent made on the call, or empty |

An answered call waits up to three minutes for its summary and outputs before the run goes on.

Where shopper memory is switched on for your organisation, the step can **give the agent the
shopper's history**: their earlier calls and WhatsApp chats with you in the last 90 days, as facts
(when, who answered, which templates went, what the agent noted) and never what anyone said or
wrote. The agent brings it up only once the shopper mentions an earlier call or chat. Switch it off
on the step and that step's calls get none.

### Chat on WhatsApp

Gives the shopper's conversation on one of your [WhatsApp numbers](/whatsapp) to an agent, with
the agent's inputs filled from the run's data, as a call does. The agent answers as its published
version, with its own tools, and the run waits while they chat.

WhatsApp takes free-form messages only within 24 hours of the shopper's last message, so the chat
begins then. Put it after a template that asks the shopper something, on that step's **replied**
way. If the shopper wrote to you earlier but more than 24 hours ago, and the agent has a restart
template (on its [WhatsApp tab](/whatsapp#the-agents-whatsapp-tab)), the chat opens with that
template and waits for their reply. It does not take a conversation someone on your team has.

It leaves by one of three ways:

- `ended`: nobody wrote for the time you set (30 minutes by default), or the 24 hours ran out.
- `handed_over`: the agent gave the conversation to your team, or someone on your team took it in
  the Inbox.
- `no_chat`: it could not begin, because the shopper had not written in 24 hours (and the agent
  has no restart template), the restart template could not be sent, or your team has the
  conversation.

What it returns is the chat's own facts, then the agent's [output variables](/agents), read from
the conversation as after a call:

| Field | |
|---|---|
| `outcome` | `ended`, `handed_over` or `no_chat` |
| `reason` | Why: `idle`, `window_closed`, `taken_over`, `no_open_window`, `team_has_it`, … |
| `shopper_messages` | Messages the shopper sent during the chat |
| `agent_replies` | Replies the agent sent |
| `opted_out` | Whether the shopper has stopped your marketing messages on WhatsApp, as the chat ends |
| `do_not_contact` | Whether the number is on your Do-Not-Call list, as the chat ends |
| `summary` | Two lines for your team |

`opted_out` and `do_not_contact` are true however the shopper asked: STOP, the
[agent](/whatsapp#when-a-shopper-asks-the-agent-to-stop), or your team adding the number. Route them
to a "Don't contact" branch with a Switch.

When the chat ends, the conversation goes back to your number's own answering agent if it has one,
otherwise to your team.

### Send a WhatsApp template

Sends one of your number's [approved templates](/whatsapp#templates) to the run's own shopper,
never to a number taken from the data. The step asks for exactly what the template needs: a value
for each variable, the link to a photo or video header, and the end of each link button. Each can
be a value or a field of the run's data, such as `{{ cart.customer.first_name }}`. A link field may
hold a whole link, such as the cart's checkout link, as long as it starts with the link Meta
approved; Tone sends Meta the part after it.

With a wait (24 hours by default, up to 72), the run then waits for the shopper and leaves by:

| Output | When |
|---|---|
| `replied` | They wrote back, or tapped a reply button such as "Call me back" |
| `stopped` | They tapped **Stop promotions**, or sent one of your number's [opt-out words](/whatsapp#opt-out-words) on its own |
| `no_reply` | The hours passed with neither |
| `failed` | It was not sent, or Meta could not deliver it |

With no wait it leaves by `sent` as soon as Meta takes the message, or by `failed`. Later steps
read `sent`, `replied`, `reply` (their words, or the button they tapped), `card` (for a carousel,
the card whose button they tapped, from 1), `stopped`, `status`, `reason`, `template` and
`category`. A test run waits 15 times less.

With **Send in the shopper's language** on, the template goes in the language the agent spoke on
the shopper's last call with you (in the last 90 days), when Meta approved the template in that
language too. A shopper never called, a language the template does not have, or a version that
needs a value the step does not fill gets the step's own language. Later steps read `language`,
the one that went.

#### Carousels

A [carousel template](/whatsapp#templates) is sent with exactly as many cards as Meta approved,
never fewer: a template of three cards needs three. For each card the step asks for a link to its
photo (or video), its values and the end of its link button, each a value or a field of the run's
data. Before the message goes, Tone fetches each card's photo and hands it to Meta, which takes
card photos that way and not by link; a photo already handed over from the same number is used
again for a week. A photo Tone cannot use (not a JPEG or PNG up to 5 MB, or an MP4 up to 16 MB for
a video) sends nothing, and the step leaves by `failed` with the card named. Meta allows
carousels for marketing messages only.

The cards can also come **from the cart**: one card per item of the shopper's cart, in its order.
Tone reads each item from your [Shopify store](#what-starts-a-run) when the message goes, for
its photo and today's price, and leaves out an item the store no longer sells, has sold out, or
has no photo for. You say once what every card shows, reading the card's item as
`{{ item.title }}`, `{{ item.variant }}`, `{{ item.quantity }}`, `{{ item.price }}` and
`{{ item.link }}` (a cart with just that item, for a link button). A cart with fewer items to show
than the template has cards sends nothing and leaves by `failed` with `too_few_products`, so a
plain template can follow it. This needs exactly one Shopify store connected to Tone.

- Nothing goes to a number on your [Do-Not-Call list](/consent-and-dnc).
- A marketing template never goes to a shopper who tapped Stop promotions or sent STOP, or who
  stopped your marketing inside WhatsApp. Order updates (utility templates) still go, and calls are
  not affected: a WhatsApp STOP is about WhatsApp. **Add to Do-Not-Call** stops both.
- By default nothing goes unless the cart or order says the shopper agreed to WhatsApp messages.
  A source that says nothing counts as no.
- A value the run does not have stops the send: nothing goes out with a blank in it.
- A send that gets no answer from Meta is never sent again, because it may have gone. It leaves by
  `failed` with `outcome_unknown`. Only Meta's rate limits, which prove nothing went, are waited out
  and tried again.

Meta bills each delivered message to your WhatsApp account, at its India rates: about ₹0.86 for
marketing and ₹0.115 for utility. Tone does not bill messages. Carousel templates cannot be sent
from an automation yet.

### Send a WhatsApp

Sends a template your provider already has approved, from a connection you made under
**Settings → Integrations**. It goes to the run's own shopper, never to a number taken from the
data, and it leaves by `sent` or `failed`.

- Nothing goes to a number on your [Do-Not-Call list](/consent-and-dnc).
- By default nothing goes unless the cart or order says the shopper agreed to WhatsApp messages.
  A source that says nothing counts as no.
- A send that gets no answer from your provider is never sent again, because it may have gone. It
  leaves by `failed` with `outcome_unknown`.

### Look up the order

Reads an order from your connected Shopify store just before it matters, so a cash-on-delivery
confirmation never calls about an order already cancelled, paid or shipped. It reads either the
order by its number (by default the run's own, `{{ order.name }}`, which must match exactly) or the
shopper's newest order, found by their phone. That second form needs the store to have let Tone read
customers. It leaves by `found` or `not_found`, and gives later steps `cancelled`, `paid`,
`shipped`, `cod`, `financial_status`, `fulfillment_status`, `delivery_status` and `total`. It never
changes the order.

If Shopify does not answer, the step is tried again. A store that has to be reconnected ends the
run at that step, and Runs says why.

### Schedule a call

Waits until a time, usually the agent's `callback_at`. Only an exact time is used: an ISO 8601
time (`2026-12-01T18:00:00+05:30`), a date and time (read as IST), or a clock time such as
`18:00` or `6 pm`. "Evening" is not a time. With none, it waits a fallback you set, or ends the
run. Every time is moved into 9 AM to 9 PM IST, and a time more than the step's limit ahead (72
hours by default) ends the run.

### Add to Do-Not-Call

Writes the same opt-out a shopper makes on a call: their consent records are withdrawn and their
number goes on your Do-Not-Call list for 90 days, after which consent may be asked for again.
Every automation and campaign then refuses to call or message them.

### Tag the contact

Puts up to 10 tags on the shopper and takes up to 10 off: fixed words, such as "Cart rescued" or
"COD confirmed". They are the same tags your team sees and filters by in the
[Inbox](/whatsapp#tags), across all your WhatsApp numbers. A shopper carries at most 20, and a tag
that would go past that is left off and shown in the run. A test run tags your test number, so
you can see it work.

## Switching it on

You publish a version, then switch the automation on. Runs already going keep the version they
started on.

Before it switches on, Tone checks what the live version needs, and refuses while anything is
missing:

- each call step's agent is published, and its number can place calls;
- for a promotional agent on a live number:
  - a **140-series** number that is not on Plivo;
  - your **DLT Principal Entity ID**;
  - your **automated-calling (A2P) declaration** to your access provider, recorded on the
    Compliance page;
- for any live call, a verified business;
- each WhatsApp step's number is connected and Meta lets it send, and its template is approved by
  Meta in that language.

The same checks run when you publish a new version while the automation is on. Nothing connected
to start runs, or a low wallet, is shown as a warning and does not stop it.

The same screen estimates what calling costs for every 100 carts (or orders). It works from your
rate, and from the share of calls answered and the length of an answered call over the last 30
days: this automation's own calls once it has 20 finished, otherwise your organisation's outbound
calls, otherwise 40% answered and two minutes a call. It follows the holdout and branches on a call's
outcome. It assumes every cart passes any other filter, and that a second call is answered as often
as a first. It lists what it assumed beside the figure. Unanswered calls are never billed.

When the automation sends WhatsApp templates from your own number, the screen also says what Meta is
likely to bill your number for every 100: each send at Meta's rate for its template's category
(₹0.8631 marketing, ₹0.115 utility), counted as delivered, and a template it cannot find counted as
marketing. That figure is Meta's, billed to your WhatsApp account, and is never added to Tone's.

## Limits

Each automation has its own limits, under **Settings**:

- calls a day (300 by default), past which carts are skipped and counted;
- calls in progress at once (20 by default), and never more than your organisation's
  [line limit](/limits);
- calls to one shopper across every automation and campaign, in a number of days. Transactional
  calls are exempt.

**Notify the team** sends at most 200 emails or Slack posts a day per automation.

## Test runs

A test run starts one run from a sample event, on the published version, and calls only your
automation's **test numbers**. Its waits run 15 times faster. Its call is a real call to your test
number, billed like any other from that number, and a test run never counts in Results. It never
adds your test number to your Do-Not-Call list.

## Runs and results

**Runs** lists every run with its path, status and result, and draws one run on the canvas, step
by step, with what its calls cost and a link to each call. **Needs a person** holds the runs that
reached a **Notify the team** step, whether or not the notice went. **Failed** holds the runs where a
step failed and something needs fixing; **Ended early** holds the runs a check blocked (the DND
register, your Do-Not-Call list) or a rule skipped (called recently, too old), which needs nothing.
Phone numbers are masked in the editor and on a run's page.

Under a run's canvas, two panels follow its shopper: **what the agent knew before the call** (the
cart, their earlier calls and WhatsApp chats exactly as the agent was given them, earlier orders and
what they agreed to) and **during and after the call** (the calls, the templates sent, their
WhatsApp messages counted, a Stop, and the order). Neither quotes a message or a transcript: those
are on the call's page and in the Inbox.

**Results** counts recovered orders: an order credited to a run within 24 hours of its first
contact, an answered call or a WhatsApp message Meta delivered from your number, whichever came
first. It says how many came after each. With a Split, it compares those orders with the held-out
shoppers. It also says how many of the recovered orders are cash on delivery, which is not money
until the order is delivered.

For each **Send a WhatsApp template** step, Results shows how many messages were sent, delivered,
read and replied to, how many shoppers tapped Stop promotions, why Meta could not deliver the rest
(for example its limit on marketing messages per person, or a number not on WhatsApp), and why
others were never sent (opted out, no opt-in). Beside Tone's cost it gives an estimate of what Meta
charges for the delivered messages, which Meta bills to your WhatsApp account. A message sent
through your own WATI, AiSensy or Exotel account does not count as a contact: Tone does not learn
whether it was delivered.

Run data is kept for 90 days by default (30 to 365, under **Settings**). After that a run keeps
its path, outcome and order, so Results still counts it, and loses the shopper's details and
cart.

## The checkout webhook

For a checkout provider, create a webhook under **Settings → Integrations → Shopify → Checkout
webhooks**. Tone gives you a URL and a secret. The secret is shown once.

```
POST https://api.usetone.ai/v1/webhooks/automations/whk_…
```

The body is your provider's own JSON. You map where the fields Tone needs sit in it — the cart's
id, the shopper's phone, and optionally the total, items, checkout link, name and WhatsApp
opt-in — when you create the webhook, and "Send a test cart" shows what Tone reads before anything
runs. A body can be one event or an array of up to 50.

### Signing a delivery

Prove each delivery with the secret, one of two ways:

- **`x-tone-signature: sha256=<hex>`**, the HMAC-SHA256 of the raw request body with the secret.
  Preferred: the secret never travels.
- **`x-tone-hook-secret: <secret>`**, for a provider that can add a header but cannot compute an
  HMAC.

Never put the secret in the URL.

```bash
BODY='{"cart_id":"c_8812","phone":"+919876543210","total":1499}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$HOOK_SECRET" | sed 's/^.* //')

curl "https://api.usetone.ai/v1/webhooks/automations/$HOOK_KEY" \
  -X POST \
  -H 'content-type: application/json' \
  -H "x-tone-signature: sha256=$SIG" \
  -d "$BODY"
```

### What it answers

`200` with what each event did:

```json
{
  "received": true,
  "events": [{ "status": "started" }]
}
```

| `status` | |
|---|---|
| `started` | A run started. |
| `duplicate` | An event with this id was already received. Redelivering is safe. |
| `stopped` | An order ended a shopper's run. |
| `credited` | An order was credited to a shopper's run that had already ended, for example after its call. |
| `ignored` | Nothing started, and `reason` says why, for example `no_phone`, `no_external_id`, `already_running` or `no_matching_automation`. |

A delivery that is not signed with the webhook's secret is `401`
[`invalid_signature`](/errors#invalid_signature). An unknown or switched-off webhook is `404`
[`not_found`](/errors#not_found).
