> For the complete documentation index, see [llms.txt](https://docs.contextual.io/documentation-and-resources/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.contextual.io/documentation-and-resources/components-and-data/object-types/object-type-details/triggers.md).

# Triggers

Triggers send events containing record data from an [Object Type](https://docs.contextual.io/documentation-and-resources/components-and-data/object-types.md) to an [event Worker](https://docs.contextual.io/documentation-and-resources/components-and-data/contextual-workers/connect-to-contextual.md#events-and-schedules) or an event-processing [Agent](https://docs.contextual.io/documentation-and-resources/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/documentation-and-resources/components-and-data/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/documentation-and-resources/components-and-data/contextual-workers/contextual-cli.md#read-logs). If processing doesn't start, see [Logs or Event Processing Are Missing](https://docs.contextual.io/documentation-and-resources/components-and-data/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/documentation-and-resources/components-and-data/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/documentation-and-resources/components-and-data/contextual-workers/managed-workers/templates-and-options.md#what-your-handler-receives) for the invocation contract.

For Flow examples using the Node-RED `msg` object, see [Message Payload Content - Triggers and Actions](https://docs.contextual.io/documentation-and-resources/patterns/working-with-data/message-payload-content-triggers-and-actions.md#flow-examples).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.contextual.io/documentation-and-resources/components-and-data/object-types/object-type-details/triggers.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
