# Triggers

These instructions apply to the current Admin Console.

Triggers send events containing record data from an [Object Type](https://docs.contextual.io/build/object-types.md) to an [event Worker](https://docs.contextual.io/build/contextual-workers/connect-to-contextual.md#events-and-schedules) or an event-processing [Agent (Legacy)](https://docs.contextual.io/legacy/components-and-data/agents.md) for further processing. The event payload depends on the record operation:

* **Post-insert:** sends the new record after creation.
* **Post-update:** sends both the old and new versions of the record after an update.
* **Post-delete:** sends the final content of the record after deletion.

The receiving Worker or Agent can process the event, update other records, or enrich application data.

## Send a Trigger to a Worker

You can use the **Send to agent** system action to send events containing record data to event Workers. Workers must be enabled for your tenant; see [Contextual Workers](https://docs.contextual.io/build/contextual-workers.md) for access requirements.

1. Under **Build > Object Types**, open the Object Type and select **Triggers**.
2. In the **Post-insert**, **Post-update**, or **Post-delete** section, select **New trigger > System**.
3. Enter a **Name** and set **System action** to **Send to agent**.
4. In **Agent**, search for your event Worker by name or ID and select the matching entry. Worker entries have a **Worker** badge.
5. Leave **Enabled** on and select **Create trigger**.
6. Create, update, or delete a test record for the selected trigger. Check the expected output or the [Worker's logs](https://docs.contextual.io/build/contextual-workers/contextual-cli.md#read-logs). If processing doesn't start, see [Logs or Event Processing Are Missing](https://docs.contextual.io/build/contextual-workers/troubleshooting.md#logs-or-event-processing-are-missing).

For example, a **Post-insert** trigger on an `order` Object Type can send each new record to an `order-enrichment` event Worker.

The picker lists Workers configured to scale on their event backlog. If your Worker is missing, check that the Worker is configured for event processing with a `managed-event-worker` template or a custom Compose service with `messaging` and `keda`. See [Events and Schedules](https://docs.contextual.io/build/contextual-workers/connect-to-contextual.md#events-and-schedules) for Worker setup and event consumption.

## Trigger Payloads

Managed event Workers receive record data in the invocation's `payload` (`event.payload` in TypeScript and Python). For **Post-update** triggers, the payload contains `old` and `new` properties with the two record versions. See [What Your Handler Receives](https://docs.contextual.io/build/contextual-workers/managed-workers/templates-and-options.md#what-your-handler-receives) for the invocation contract.

In Legacy Flows, downstream nodes read the trigger payload from `msg.event` after [Event Start](https://docs.contextual.io/legacy/components-and-data/flows/node-reference/event/event-start.md#output).
