# App triggers: start a workflow from an app

An app trigger starts a workflow when something happens in an app you connected: an invoice is paid, an order is placed, a call is booked. You do not send anything yourself. send.io watches the app for you.

## Add an app trigger

First [connect the app](https://app.send.io/docs/apps). Then, in the automation builder, open the trigger step. It has two sources: **Custom event** and **App**. The **App** source shows once an app is connected.

1. **Choose the source.** Click **App**.
2. **Pick the app.** Open the list that starts with **Choose an app** and pick one of your connected apps. With one connected app, it is picked for you.
3. **Pick what starts the workflow.** Open **Choose what starts the workflow** and pick one, for example "Invoice paid or payment failed". Each one has a short description under it.
4. **Fill in its settings.** Some triggers have settings, such as which status to watch. A setting you leave empty means any. Required ones say **(required)**.
5. **Start the workflow.** Click **Start**. Starting is what makes send.io watch the app.

Triggers marked **(not supported yet)** need a setting the builder cannot show yet, so you cannot choose them. A trigger can also show this when an earlier trigger of the same app already watches the same kind of record. Choose that earlier one instead.

## Start, stop and delete

- **Start** subscribes to the app. From then on, matching changes in the app start the workflow.
- **Stop** pauses the subscription. Nothing new starts the workflow. Runs already in progress follow the choice you make when you stop.
- **Delete** removes the workflow and its subscription.

The app must be **Connected** when you start. If it says **Reconnect needed**, reconnect it first on the Apps page.

> **Note:** Only team admins can start a workflow with an app trigger. A member can start again a workflow that an admin already started and has not changed since.

## Start a template from an app

Some automation templates describe something that happens in an app: a payment fails, an order is placed, a cart is left behind. With the right app connected, the template starts from that app and you write no code. In setup, the **Events** step lists the apps the template can start from, for example "Stripe: Invoice payment failed".

- **The app is connected.** It is chosen for you. Create the automation, open the trigger step to check it, and click **Start**.
- **The app is not connected.** Setup says so and links to the Apps page. Connect the app and come back: it then shows as connected. Until then the template starts from an event your own app sends, as before.
- **You would rather send the event yourself.** Choose **An event my app sends**.

> **Note:** Only the event that starts the workflow can come from an app. An event that ends a wait, such as "payment succeeded" in the failed payment template, still comes from your app. If your app does not send it, each wait runs to its end and the next email goes out.

## When an app trigger stops

A workflow that an app starts can only start while the app is connected and watched. When that is not the case, the Automations list marks the workflow and shows a notice above the list, and the builder shows the same notice at the top of the workflow. Each says what happened and what to do.

- **App disconnected.** The app was disconnected on the Apps page. Connect it again there. For most apps the workflow then starts again by itself within ten minutes. For an app where you pasted an address, read the next part.
- **App not working.** The app does not accept the connection's key or sign-in (the Apps page shows it as Not working). Reconnect it on the Apps page.
- **Trigger not watched.** The app is connected, but nothing is watching for the trigger right now. send.io sets it up again within ten minutes. If the notice stays, stop the workflow and start it again.
- **Address changed.** For an app where you pasted an address: the trigger was set up again and its address is a new one. See below.

Changes that happened in the app while the trigger was stopped are not replayed. Before you disconnect an app, the Apps page tells you how many switched on automations start from it.

## After reconnecting an app where you pasted an address

For Stripe and Loops, reconnecting is not the whole fix. Disconnecting the app removes the trigger's webhook address for good. When the app is connected again, the trigger gets a **new** address, and the app still sends to the old one. Nothing starts the workflow until you paste the new address into the app.

1. **Open the automation.** The notice at the top says **Address changed** and has a **Show the address** button. A live automation's trigger step is closed, so the address is shown in the notice.
2. **Replace the address in the app.** Copy the new address and put it in place of the old webhook endpoint in the app. Delete the old endpoint.
3. **Wait for the next event.** The notice clears when the first event arrives on the new address. Until then send.io cannot know that you pasted it, so the notice stays.

> **Note:** send.io can only show this notice for a trigger that has received at least one event before. If you reconnect an app before its trigger ever received one, nothing can tell the old address from the new one: open the trigger step, press **Show the address** and check that it is the address in the app.

## Apps where you paste an address

Most apps let send.io register for their events. Some do not: Stripe and Loops cannot be subscribed for you. For those, the builder shows a card, **Finish in (app)**, with a webhook address to paste into the app.

1. **Show the address.** Click **Show the address**. Only team admins can. A member sees "Ask a team admin to show the address."
2. **Copy it.** Click **Copy**. If the app's webhook page is known, **Open the webhook page in (app)** takes you there.
3. **Paste it into the app.** Add it as a webhook endpoint in the app. Choose the events that match your trigger.
4. **Start the workflow.** Events from the app start the workflow once it is started.

> **Warning:** The address changes when the trigger's settings change. If you change a setting, show the address again and update it in the app. An address that no longer matches stops the workflow from firing.

The address stays the same while you stop and start the workflow with the same settings.

## Which contact a run is for

Every run is for a contact, and the record's email address decides which one. send.io reads the address from the record: the first of `email`, `customer_email`, `user_email`, `receipt_email`, `customer.email`, `customer_details.email`, `billing_details.email`, `billing.email`, `billing_address.email`, `payer.email_address`, `subscriber.email_address`, `person_properties.email`, `attendees.email`, `emails.email` and `answers.email` that holds a valid address. Where a field is a list, the first entry that has an address is used.

- If the address belongs to a contact you already have, the run is for that contact.
- If it is new, send.io creates the contact.
- If the record has no email address, no run starts. The workflow's run history shows it as skipped.

The workflow's own settings still apply to each run. For example, a workflow set to run once per contact skips a contact it already ran for, and a marketing workflow skips contacts who unsubscribed.

## The record's fields in later steps

Each changed record becomes an event, and its fields are the event variables of the run. Use them in any later step, in a condition or in a field of an [App action](https://app.send.io/docs/app-actions). Write `{{event.field}}` for a field, and `{{event.parent.field}}` for a field inside another (for example `{{event.customer.name}}`).

| Variable | What it holds |
| --- | --- |
| `{{event.status}}` | A field of the record. The names are the app's own, so the variable list in the builder is the best place to look. |
| `{{event.customer.email}}` | A field inside the record. |
| `{{event._action}}` | What happened to the record, as the app reports it, such as `updated`. |
| `{{contact.email}}` | The contact the run is for. |

A very large record (over 100 fields or 64 KB) is kept with its top-level text, number and yes/no fields only. A record the event limits still refuse is skipped.

## Repeats and order

Apps can send the same change more than once, and not always in the order it happened. send.io handles both: a repeat of a change never starts a second run. Do not rely on the order of runs, and design steps so a late, older change does not undo a newer one.

## If a trigger does not fire

- The app shows **Connected** on the Apps page. If it says **Reconnect needed**, reconnect it.
- The workflow is started, not stopped.
- For an app where you paste an address: the address in the app is the one the builder shows now.
- The record has an email address. Without one, the run history shows a skipped run.
- You are under the limit of 50 workflows with an app trigger switched on. See [Limits](https://app.send.io/docs/apps#limits).

More in [Apps: troubleshooting](https://app.send.io/docs/apps#troubleshooting).
