Skip to main content

Schedule and trigger agents

Some work should happen without anyone asking: the morning briefing at eight, the sales report every Monday, a review every time a pull request is opened. A routine is an agent that is started by something other than you: a schedule, a call from another system, a GitHub event, a new email, a new Knowledge file or a changed record. This guide shows how to set each one up, how to see what is coming and how to hold a routine.

A routine is an agent with a trigger

There is nothing to create besides the agent: its Trigger decides what starts it. A scheduled or event-driven run is the same as any other run (same instructions, same tools, same approvals), and it shows up in History, on the agent's page and on the routine's Runs tab.

Prerequisites​

  • An agent with instructions: see Build an agent. Write them for a run nobody is watching, and say where the result goes and what "done" means.
  • For GitHub: admin rights on the repository, to add a webhook.
  • For API calls: an API key from Settings → API Keys (see Access Rational AI via API).
  • For new emails: an Email channel (see Connect a mailbox).
  • For new files and changed records: a Knowledge base the agent may use.

See your routines​

Open Agents → Routines.

The Routines page: five routines with their trigger (two schedules, two manual, one GitHub event), tools, last run and a Pause button each

The line under the title counts the routines, how many are enabled and how many failed their last run. Every agent is listed with its trigger, its tools, the outcome of its last run and a Pause/Resume action. Search with Search routines…, filter by trigger (Trigger: Scheduled, Trigger: Event, Trigger: API) and by status (Status: Enabled, Status: Paused, Status: Last run failed), and sort by Recently run, Name, Status or Failing first; List view and Grid view switch the layout.

Select a routine to open its panel: Run now starts it immediately, Edit opens the profile, and the Overview, Trigger, Permissions and Runs tabs show what it does, what starts it, what it may touch and how it went.

New routine opens a new agent profile with the trigger already set to Schedule.

Run it on a schedule​

Scout writes the market briefing every weekday at 08:00, Central European time.

  1. Open the agent's profile (Edit), or create it with New routine.
  2. Under Trigger & execution, set Trigger to Schedule.
  3. Under Schedule, enter the cron expression: 0 8 * * 1-5.
  4. Set the Time zone, for example Europe/Rome. Leave it empty to use your browser's time zone, which is saved with the schedule.
  5. Select Save (or Create agent for a new one).
Scout's Trigger and execution section: trigger schedule, Cron 0 8 * * 1-5, timezone Europe/Rome, cloud, autonomous

The cron expression has the usual five fields (minute, hour, day of the month, month, day of the week):

ExpressionRuns
0 8 * * 1-5At 08:00, Monday to Friday
0 7 * * 1At 07:00 every Monday
*/30 8-18 * * 1-5Every 30 minutes from 08:00 to 18:30, on weekdays
0 6 1 * *At 06:00 on the first day of every month

If a scheduled run is due while the previous one is still going, it is not stacked on top of it. When the agent has no model of its own, the platform Agents default is picked when the run starts.

See what's coming in the calendar​

Agents → Calendar (also the third view on the Tasks page) lays the upcoming scheduled runs on a week calendar next to past runs and approvals. The calendar shows your browser's time zone, whatever time zone the schedules use.

The week calendar with Scout's 08:00 briefing on each weekday

Filter narrows it by schedule (All, Recurring, One-time) and by status (All, Active, Paused, Stopped after failures, On hold). A paused routine shows once, all day today, as Paused, it will not run. The legend tells routines, tasks and approvals apart.

Run it on a GitHub event​

Rev reviews every pull request opened on acme/web-shop. Each event GitHub sends starts a run whose input is the event.

Configure the agent​

  1. In the profile, set Trigger to GitHub event.
  2. Repository: organisation/repository, for example acme/web-shop. Deliveries from any other repository are ignored.
  3. Events: a comma-separated list of GitHub event names, for example pull_request or pull_request, push. Write event.action to match a single action, for example pull_request.opened. Leave it empty to accept every event.
  4. Optionally, narrow it further with Only if and AI check (see Filter events before they start a run).
  5. Select Save.
Rev's Trigger and execution section: trigger githubEvent, repository acme/web-shop, events pull_request

Connect the repository​

The repository needs a webhook that sends its events to Rational AI, signed with a key that belongs to the agent.

  1. After you save the agent, its Trigger & execution section shows the webhook Address. Select Copy.
  2. Select Generate key and copy the key. It is shown only once: if you lose it, select Rotate key and update the webhook in GitHub.
  3. In the repository, go to Settings → Webhooks → Add webhook. Paste the address as the Payload URL and the key as the Secret, set Content type to application/json and pick the events you listed on the agent.

GitHub sends a test delivery when you save the webhook. From then on, each matching event starts a run that appears in History, started by GitHub event. Events from paused agents, or from agents over their monthly budget, start no run.

Start it from a webhook​

A webhook trigger lets another system (a form tool, a monitoring alert, a CRM automation) start a run by sending a request to the agent's own address.

  1. In the profile, set Trigger to Webhook and save the agent. Its Address appears under Trigger & execution.
  2. Select Generate key and copy the key: it is not shown again. Rotate key replaces it, and systems still sending the old key are refused.
  3. Give the address and the key to whoever sets up the other system. Every request must carry the key.

Each request starts a run whose input is what the system sent. Requests to a paused or over-budget agent start no run, and AI check can skip the ones that do not concern the agent.

Start it on a new email​

  1. In the profile, set Trigger to New email.
  2. Under Mailbox, choose an Email channel.
  3. Optionally, set Only if on From, Subject, Text, Has attachments or Attachment names, and an AI check.
  4. Select Save.

Each mail the channel receives starts a run with the sender, subject, text and attachments.

Start it on a new file or a changed record​

For New file, choose the Knowledge and, optionally, a Collection (Every file by default). Each file of the base, or of the collection, that finishes processing starts a run with the file and its records.

For Record changed, choose the Knowledge, optionally a Collection (Every record), When (Created or updated, Created or Updated), the Fields whose change counts, and an Only if filter. Each record created or changed starts a run within a minute, one run per record however many saves it took. The agent's own changes never start it; other agents' changes do, so two agents that write each other's records can start each other in turn.

When the agent's Knowledge access lists specific bases, the trigger's Knowledge must be one of them.

Filter events before they start a run​

For GitHub event and New email, Only if keeps only the events that match a filter. For those two and Webhook, AI check asks a yes-or-no question about each event, such as "Is this a purchase order?", and starts a run only when the answer is yes with at least the confidence you set (% sure).

An event that does not pass starts no run and shows as Skipped in History. The AI check uses the cheapest model of the agent's own provider and counts toward the agent's budget; when the check itself fails, the event starts its run.

Start it from another system​

Any system with a Rational AI API key can start a run of any agent, whatever its trigger, and pass it a goal and input data. See Access Rational AI via API. Setting the agent's trigger to API marks it as API-driven in Routines.

Pause an agent​

Pause (on the agent's page or its row in Routines) marks the agent as Paused: its schedule stops firing, its other triggers no longer start runs, and its upcoming runs leave the calendar. Resume clears it.

An agent can also be paused for you:

  • Budget reached: the agent used its Monthly budget. Raise or remove the budget on the agent's page to resume it.
  • Paused: unread: with Pause scheduled agents nobody reads turned on in Settings → Agents, a scheduled agent is paused when nobody opened its last 10 results over at least 14 days. Its owner is notified and can resume it.