> Every page of the Heythere docs is listed in https://heythere.io/docs/llms.txt: fetch it to find a page instead of guessing its URL.

# Triggers: start a WhatsApp automation at the right moment

> Start an automation when a customer writes, when your software changes one of their fields, when a date of theirs comes, or when another service sends an event.

Camille's repair shop writes to her at three moments: when she messages its WhatsApp number, when its software marks her bike ready, and a year after her last service. Each moment is a trigger, an entry point of an [automation](https://heythere.io/docs/concepts/automations)'s graph that starts a [run](https://heythere.io/docs/concepts/runs) at the step it leads to. Its triggers listen to the WhatsApp number the automation answers, and publishing a [version](https://heythere.io/docs/concepts/versions) activates them. None starts a run while an active run, a [live chat](https://heythere.io/docs/concepts/live-chats), or a handover holds the conversation.

A `message.received` trigger starts a run when a contact writes to that number in its conversation. Since the contact just wrote, the run starts inside the conversation's [reply window](https://heythere.io/docs/concepts/conversations#when-does-a-conversation-s-reply-window-close-), and can answer freely. A voice note starts it at once, and its transcript is the trigger's text.

## How does a change of a contact start a run?

An `attribute.changed` trigger starts a run when `updateContact` changes the field it listens to: a declared [attribute](https://heythere.io/docs/concepts/attributes), the contact's `language`, or a consent. When the shop's software sets Camille's `repair_status` to `ready`, she gets "your bike is ready". Its optional `when` holds conditions on `trigger.before`, `trigger.after`, and `contact.<field>`, such as `trigger.after` equals `ready`, so only that change starts a run.

The run starts in the contact's conversation with the automation's number, opened if the contact never wrote to it. It is likely outside the reply window, so its steps send only [templates](https://heythere.io/docs/concepts/message-templates), each one the contact's [consent](https://heythere.io/docs/concepts/contacts#what-does-a-contact-consent-to-) allows. An import, a new contact, or a value a run writes starts no run. The automation reads `contact.<field>` later, when it needs it.

## When does a date start a run?

A `date.reached` trigger watches a date of the contact, a `date` [attribute](https://heythere.io/docs/concepts/attributes) or `createdAt` and `lastInboundAt`, and fires some days from it at a time of day in a time zone, or some minutes from an instant. A year after Camille's last service, at 10am Paris time, she gets the service offer.

The firing moves when the date changes, and a moment already past starts no run. As for a change, the run starts in the contact's conversation with the automation's number, opened if needed, and sends only templates.

## How does another service start a run?

A `webhook.received` trigger starts a run when a [webhook source](https://heythere.io/docs/concepts/webhook-sources) receives a matching request, such as your site reporting an unfinished booking, for the known contact whose phone number it holds. Its `fields` become `trigger.<name>`. Like an `attribute.changed` run, it opens the conversation if needed and sends only templates.

## Which automation answers a number?

Its own. Each number the workspace connects gets one automation, created empty with it, which never moves to another number. A number connected again finds its automation as it left it. `getWorkspaceMap` lists every number with its automation's ID and graph.

Until that automation publishes a version, the number starts no run, and its messages wait in the inbox for the members.

## How does an automation tell contacts apart?

Every message that starts a run starts the same trigger, so the steps after it sort the contacts. A [`condition` step](https://heythere.io/docs/concepts/steps) reads the contact's attributes or the message's text, such as a keyword, and a `classify` step lets [AI](https://heythere.io/docs/concepts/ai) tell what the contact wants, such as booking a repair or checking on a bike.

The [workspace log](https://heythere.io/docs/concepts/workspace-log) says why a message started no run, such as `automation_unpublished` when its number's automation has no published version yet, and why a change started none, such as `active_run`.
