# Schedule an agent or attach it to Slack

> Run an agent on a repeating schedule, or attach it to a Slack channel so people can ask it there.

Source: https://docs.tulipfarm.ai/guides/schedule-an-agent/

You can start an [agent](https://docs.tulipfarm.ai/concepts/agents-skills-and-workflows/) on a schedule, or let people ask it in a Slack channel.

## Before you start

- The agent has activated instructions. See [Build an agent](https://docs.tulipfarm.ai/guides/build-an-agent/).
- To add a schedule, you are an agent manager. An agent manager has the Manage permission on the agent.
- To use Slack, a workspace member has connected [Slack](https://docs.tulipfarm.ai/integrations/slack/).

## Add a schedule

1. Select **Agents** in the sidebar.

2. Open the agent.

3. Open the **Triggers** tab.

4. Select **Add schedule**.

5. Under **What runs**, select **Run a saved prompt**.

6. In **Prompt**, type the work that the agent does on each run.

7. Under **When to run**, choose **Repeat interval** or **Calendar schedule**.

   - For **Repeat interval**, enter the **Interval in minutes**. Use a number from 60 to 10,080.
   - For **Calendar schedule**, choose the **Days**, the **Time**, and the **Time zone**.

8. Check the **Task limits for each run**.

9. Select **I sponsor this schedule using my current permissions**.

10. Select **Create prompt schedule**.

> **Note:** Scheduled runs use the access of the sponsor. The sponsor is the person who created the schedule. The runs stop if the sponsor loses that access.

How scheduled runs work:

- Each run is a private task that belongs to the sponsor.
- A prompt schedule runs at most one time each hour.
- Only one task from a schedule is open at a time.
- To stop a schedule, select **Revoke schedule**.

### Use a cron expression

Under **Advanced schedule**, you can enter a **Cron expression** instead of days and a time. A cron expression has five fields. They are the minute, the hour, the day of the month, the month, and the day of the week. For example, `0 9 * * 1` runs on Mondays at 09:00.

### Check a table on a schedule

Under **What runs**, you can select **Inspect a table** instead. The agent reads the fields of one table on each run.

- Use an interval from 1 to 10,080 minutes.
- Only one inspection runs at a time. TulipFarm skips missed intervals.
- Select **Create inspection schedule** to save it.

## Attach the agent to a Slack channel

1. Select **Agents** in the sidebar.

2. Open the agent.

3. Open the **Slack** tab.

4. Choose a channel from the list.

   If the channel is not in the list, add the TulipFarm bot to the channel in Slack. Then check again. You can also enter a channel ID. The ID starts with C or G. Copy it from the channel details in Slack.

5. Choose when the agent replies:

   - **Every channel message**
   - **When mentioned**

6. Select **Attach agent**.

To use this, you need a linked Slack account, current access to the channel, and permission to use the agent.

### Ask the agent in Slack

A person can ask the agent in its channel if both of these are true:

- They are a current member of the TulipFarm workspace.
- They linked their Slack account to TulipFarm.

The task belongs to the person who asked. To link an account, select **Sign in with Slack** when TulipFarm asks. Sign in as the same Slack user who sent the message. TulipFarm does not match accounts by email address.

## Next steps

- [Review agent tasks](https://docs.tulipfarm.ai/guides/review-agent-tasks/)
- [Use the calendar](https://docs.tulipfarm.ai/guides/use-the-calendar/) to see your scheduled runs
- [Slack](https://docs.tulipfarm.ai/integrations/slack/)
- [Approvals and agent permissions](https://docs.tulipfarm.ai/security/approvals-and-agent-permissions/)
