# Routines

A routine is a prompt a bot runs on its own: on a schedule, when something changes, or when another
service calls it.

See also [Workflows](/docs/workflows/), for a job that passes between several bots and you.

## Ask for one in chat

The quickest way is to ask:

- "Every weekday at 8am, summarize my inbox."
- "Remind me in 20 minutes to call Dana."
- "Every Monday, check our competitors' pricing pages and tell me what changed."

The bot creates the routine and reports each run back in the same chat. A routine can also keep a
[page](/docs/pages/) up to date.

To get the result somewhere else, say so in the request: "every Friday, post a summary of the week
to #team in Slack" or "email it to me". The bot then uses that [connected app](/docs/integrations/)
each run, and sending still follows your [approvals](/docs/approvals/).

A routine can read the bot's past [meetings](/docs/meetings/) with you, but it can't send the bot to
one. For meetings that repeat, turn on [**Join my meetings**](/docs/meetings/#join-my-meetings).

## Create or edit one yourself

Choose the bot's name at the top of the chat and open **Routines**. Choose **Create Routine** (the
**+**), or click a routine to edit it. A bot with no routines also offers **Create a routine** on
its **Activity** tab.

1. **Name** the routine and write the **Instruction**: what it should do each time it runs.
2. Under **When to run**, choose **Add trigger**.
3. Choose **Save**.

Under **Advanced** you can give a routine its own **Model** and **Thinking** level, for example a
cheaper model for a simple daily check.

## Triggers

### On a schedule

**Every hour**, **Every day**, **Weekdays**, **Every week**, **Every month**, or an **Interval**
such as every 15 minutes. **Advanced** accepts a cron expression.

Times use the timezone you had when the routine was made, from **Settings → General**. Changing
your timezone later doesn't move existing routines; ask the bot to recreate them.

### When something changes

The bot checks something at a set interval (**Check every**, from 5 minutes to a day) and runs only
when it changed. **What to watch** can be files or folders on the computer, a command's output, or a
tool from a connected app. Turn on **Post "No changes" in chat** if you want a note every time. A
watch can't be combined with a schedule.

### When something happens in an app

In the trigger menu, pick a connected app under **Apps**, then one of its events, such as a new email
or a new Linear issue. Fill in the event's fields. Some ask for an ID, such as a Linear team ID; ask
the bot in chat if you don't know it. **Account** appears when you've connected more than one account
of that app. **Connect an app** opens [Integrations](/docs/integrations/). GitHub isn't listed under
Apps; use **Git event** instead.

Each event starts one run. The routine's prompt gets the event's details, which count as outside
content, so the run starts with the same limits as any run that has read outside content: for
example, a site the event mentions [asks first](/docs/approvals/#what-always-asks). A run shows which
event started it, and **Show everything the bot received** shows the whole event.

The trigger's status line says what it's doing: **Waiting for the first event**, **Listening · Last
event …**, **{App} disconnected** with **Reconnect**, or **Paused after 50 runs this hour** with
**Resume**. If an app trigger starts 50 runs in an hour, it pauses and you get a notification. It stays
paused until you press **Resume**.

Some apps, such as Gmail and Google Drive, are checked every couple of minutes rather than instantly.

You can also ask your bot in chat, which works on every device, including iPhone. For example: "When a
new issue comes into the Product team on Linear, triage it and ping me if it's urgent." A bot run that
read outside content, or that a teammate started, needs your approval before it can set one up.

A routine can have up to 5 app triggers. An app trigger can be combined with a schedule, but not with a
change watch. Turning a routine off stops its app triggers. **Uninstall** in Integrations removes
them, and so does disconnecting the account a trigger uses.
Workflows support app triggers too; set them up on web or desktop.

### Webhook

Gives you a URL and key. Any service that can send a POST request can start the routine.

### Git event

Gives you a URL to add as a GitHub webhook, so pushes, issues and pull requests can start the
routine.

### Slack message

Runs when the bot receives a message in Slack. It needs the bot linked to Slack in
**Settings → Messaging** (see [Chat apps](/docs/messaging-apps/#slack)), not the Slack app in
Integrations. A message that starts the routine gets no normal reply in Slack; the routine's result
shows in the bot's chat in Opisense.

> [!NOTE]
> Runs started by a webhook or an outside message follow stricter [approval](/docs/approvals/) rules,
> since outside text could steer what the bot does.

## Test, pause and review

- **Test run** runs a saved routine now.
- Turn off **Active** to pause a routine without deleting it.
- **Run history** shows each past run and its result, such as **Done**, **Failed** or **No reply**
  when a run finished without posting anything.
- A running routine shows **Running** in the list, with **Stop**.

When a run fails, you get a notification if notifications are on in the bot's settings. When a run
needs your approval, it posts the card in the chat and waits; see
[Approval cards](/docs/approvals/#approval-cards). Out of credits or beyond your plan's limits, runs
fail with the reason shown, and the routine tries again later, waiting longer each time.

Watch the first few runs of a new routine. When one goes wrong, tell the bot in the same chat what
to change, or edit the routine's **Instruction**.

## Routines from the Marketplace

When you publish a bot to the [Marketplace](/docs/marketplace/), its routines go with it and keep the schedule they
were made with. Other triggers don't carry over.

In a bot you add from the Marketplace, every routine starts **Paused**. Connect the apps it needs,
add a trigger if it has no schedule, then turn on **Active**.

## On mobile

The mobile app lists a bot's routines from its profile. You can pause, delete and review them there.
To create or change one, ask the bot in chat or use the web or desktop app.
