# Create an Automation

An Automation delivers work to a Session or a Lead when a trigger fires. Start with a specific task and a narrow trigger so you can tell whether the first run did what you intended.

## How do I set it up?

1. In **Automations**, choose **New automation**.
2. Give it a name and write the task. Describe the result you want and the conditions under which it should ask for help.
3. Choose the Project. Then choose whether the Automation starts a Session or sends the work to a Lead.
4. Choose a trigger below, save the Automation and check its run history after the first delivery.

## Which trigger should I use?

- **Schedule.** Pick a one-time or repeating schedule and its time zone. Use a custom cron schedule when the presets don't fit.
- **Webhook.** Add a webhook trigger and choose how the sender authenticates. Save the Automation. Reopen the trigger, copy its URL and choose **Generate secret**. Copy the secret to the calling service's Secret store and configure the sender to use the method you chose.
- **Slack.** Use a Slack trigger when the workspace connection and trigger are available. For a one-off task from a thread, see [working from Slack](/guides/coding-agents-from-slack).

## How do I add a GitHub trigger?

Create and save the Automation. Set `id` to its ID and `repo` to the numeric GitHub ID of a repository in its Project. Run the first command to find the current revision, then set `rev` before running the second.

```sh
hmux automation show "$id" \
  --json
hmux automation github add \
  "$id" --revision "$rev" \
  --repository "$repo" \
  --event pull_request.opened
```

Use `hmux automation github --help` for filters and trigger options. Check the run history after a matching event.

See [GitHub events, webhooks and schedules](/guides/trigger-coding-agents-from-github-webhooks-and-schedules) for examples of when to use each.
