Triggers
Chat is always on. Set a trigger when something else should start a run.
What starts a run
Chat is always one of them and cannot be removed, so most agents never set this. You set triggers when you want one of the others as well.
kind | Who starts the turn | You give it |
|---|---|---|
chat | a person | nothing |
schedule | nobody | a cron expression, in the timezone you name |
interval | itself | seconds, and optionally maxRuns |
webhook | your system | nothing. You get a URL back |
await agent.setTriggers([
{ kind: 'chat' },
{
kind: 'schedule',
cron: '0 8 * * 1',
timezone: 'America/Los_Angeles',
message: 'Summarise last week\'s failed payments over 500 dollars.',
},
]);message is what the agent is asked
A run with no human attached still has to be told something, or it wakes with nothing in front
of it. Required on schedule and interval. Optional on
webhook, where it is prepended to your payload so the agent knows what it is looking
at before it sees it.
Webhooks
Setting a webhook trigger hands back a URL to POST to:
const updated = await agent.setTriggers([
{ kind: 'chat' },
{ kind: 'webhook', message: 'A support ticket arrived. Triage it.' },
]);
updated.triggers.find((t) => t.kind === 'webhook')?.url;Every firing is a turn
An interval of 10 seconds with no maxRuns is a bill that does not
stop. Set maxRuns unless you mean it to run forever.
Triggers are not versioned. Changing one takes effect immediately, because a trigger starts a new run and is never read by a conversation already in progress.