> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leme.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Triggers

> Run agents automatically on a schedule or from a webhook

## Overview

Triggers start an agent automatically. Use them for recurring work, like a daily briefing, or for event-driven work, like qualifying a new lead when a form is submitted.

Triggers do not replace channels or integrations. Channels are where people talk to an agent. Integrations and connections are how the agent accesses external tools. A trigger only decides when a run starts.

## Trigger types

**Schedule** runs an agent at a configured time. Use it for daily, weekly, or cron-based routines. Always review the timezone before activating a schedule.

**Webhook** runs an agent when an external system sends an authenticated event. Use it for form submissions, alerts, lifecycle events, or other external notifications.

## Before you start

You need an `Owner` or `Admin` role in the workspace to create and manage triggers.

Make sure the agent is active and has the connections or tools it needs. Trigger runs follow the same permissions, approval rules, and tool access as manual runs.

## Create a schedule trigger

1. Open the agent in the Leme dashboard.
2. Go to the **Triggers** tab.
3. Select **New trigger**.
4. Choose **Schedule**.
5. Add a clear name and instruction.
6. Pick a daily, weekly, or cron schedule.
7. Confirm the timezone.
8. Choose the session behavior.
9. Create the trigger.

Use a reused trigger session when the work benefits from continuity, such as recurring briefings. Use a new session per run when each execution should be independent.

## Create a webhook trigger

1. Open the agent in the Leme dashboard.
2. Go to the **Triggers** tab.
3. Select **New trigger**.
4. Choose **Webhook**.
5. Add a clear name and instruction.
6. Choose the session behavior.
7. Create the trigger.
8. Copy the webhook URL and secret shown by Leme.
9. Configure your external system to send a `POST` request to that URL.

<Note>
  The webhook secret is shown when the trigger is created or rotated. Store it in the external system before closing the panel.
</Note>

If the sender supports headers, prefer sending the secret as:

```text theme={null}
Authorization: Bearer <secret>
```

For duplicate protection, send a stable event identifier:

```text theme={null}
Idempotency-Key: <event-id>
```

Supported payload formats are JSON, plain text, and form URL-encoded data. Keep payloads small and include only the event data the agent needs.

Accepted events are answered immediately with `202` and a `statusUrl`:

```json theme={null}
{ "received": true, "duplicate": false, "runId": "...", "statusUrl": "/api/v1/runs/..." }
```

To follow the run from your system, poll `statusUrl` with an API token — the statuses and the response format are the same as in [Run agents via API](/api/runs#follow-the-run).

## Test a trigger

Use **Preview** to inspect the instruction that will be sent to the agent.

Use **Test** to create a real test run. Test runs can execute real tools, request approvals, and affect connected systems, depending on the agent configuration.

## Run history

Each trigger shows recent runs with status, timing, errors, and links to the related session or task when available.

Webhook payloads and secrets are not shown in full. The dashboard only shows safe summaries that help with troubleshooting.

## Troubleshooting

**No run appears:** confirm the trigger is active, the agent is active, and the schedule timezone is correct.

**Webhook is rejected:** verify the URL, secret, content type, and payload size.

**Webhook is duplicated:** send a stable `Idempotency-Key` for each external event.

**Run is waiting:** the agent may be waiting for a required human approval.

**Run fails after working before:** confirm the user who created the trigger still has access to the agent and required connections.

**Trigger is too noisy:** pause it, adjust the schedule or external sender, then reactivate it.
