AgentNava · Build

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.

kindWho starts the turnYou give it
chata personnothing
schedulenobodya cron expression, in the timezone you name
intervalitselfseconds, and optionally maxRuns
webhookyour systemnothing. You get a URL back
eventa change in a connected app: your app decides (with url), or the agent runs on itthe app and which changes; for your app, its url and secret
knowledgea change to a person's records in the agent's knowledge space: the agent runs for that personthe space, and optionally which kinds and a message
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. Paste it into the system that sends the events: Stripe, Shopify, Zapier, or your own code.

const updated = await agent.setTriggers([
  { kind: 'chat' },
  { kind: 'webhook', message: 'A support ticket arrived. Triage it.' },
]);

const url = updated.data?.triggers.find((t) => t.kind === 'webhook')?.url;

The URL stays the same across every later setTriggers() and update(), so a sender you set up once keeps working. An agent has one webhook.

The secret part of the URL is the only check on who may call it, so treat the URL like a password. If it leaks, replace it. The old URL stops working at once:

const newUrl = await agent.rotateWebhookUrl();

Check who sent it

Stripe, GitHub, Shopify and Slack sign every delivery with a secret they show you when you add the URL there. Give the webhook that secret, and a delivery whose signature does not match is refused before the agent runs. Tools that do not sign (Zapier, Make, n8n, your own code) can add a header instead.

await agent.setTriggers([
  { kind: 'chat' },
  { kind: 'webhook', message: 'A payment arrived.', verify: { kind: 'stripe', secret: 'whsec_...' } },
]);

// Or a header your own sender adds:
// verify: { kind: 'header', header: 'X-Webhook-Secret', secret: '...' }
verify.kindChecks
stripethe Stripe-Signature header
githubthe X-Hub-Signature-256 header
shopifythe X-Shopify-Hmac-Sha256 header
slackthe X-Slack-Signature header, and answers Slack's one-time URL check
standardthe webhook-signature header of the Standard Webhooks spec
headera header you name, holding the secret you set
nonenothing: the URL is the only lock

The secret is stored encrypted and never read back. Leaving verify out keeps what the webhook has; { kind: 'none' } turns the check off.

Retries run once

Senders retry when they are not sure a delivery arrived. A delivery with the same id as one already accepted (Stripe's event id, GitHub's X-GitHub-Delivery, the webhook-id header, or an Idempotency-Key header you send) answers 200 and does not run the agent again. See what arrived with await agent.webhookDeliveries(), and try the webhook with await agent.sendTestWebhook(), which runs the agent on a sample event and is charged as a turn.

App events

An event trigger reacts to a person's changes in a connected app (new mail, a calendar event created, changed or cancelled, a Slack message), with no polling on your side. A person's changes are grouped for windowSeconds (default 30, at most 600), then each group goes one of two ways:

with url and secretwithout url
where it goesa signed POST to your appone run of the agent
who decidesyour app: now, later or never, and it starts the agent itselfthe agent, in that run
costno model run on our sideone turn per group, at most one a minute and 30 an hour per person
await agent.connections.add(Connection.endUserAccount(App.GMAIL));
await agent.setTriggers([
  { kind: 'chat' },
  {
    kind: 'event',
    app: 'gmail',
    on: ['new_message'],
    url: 'https://example.com/agent-events',
    secret: process.env.EVENTS_SECRET,
    windowSeconds: 60,
  },
  // Or let the agent run on each group itself:
  // { kind: 'event', app: 'gmail', on: ['new_message'], message: 'Draft a reply to anything from a customer.' },
]);
apponHow fast
gmailnew_messagechecked every minute
google-calendarevent_created, event_updated, event_cancelledchecked every minute
slackdirect_message, mention, channel_messageas it happens

Slack

Where Slack signs in through AgentNava's own Slack app, we know who each person is. Today that app serves AgentNava's own Slack workspace only, while Slack reviews it for every workspace; elsewhere a Slack trigger sends to your app (url), and mention and runs are refused, saying so. Their own messages (an agent's posts as them included) and every bot's or app's are dropped before anything, so a run never wakes itself. direct_message is a direct message to them, mention a channel message that names them or replies in a thread they started, and channel_message any message in a channel they are in, mentions included. Each line is the first 100 characters of the message, with its channel, ts, thread and the writer's user id.

await agent.connections.add(Connection.endUserAccount(App.SLACK));
await agent.setTriggers([
  { kind: 'chat' },
  { kind: 'event', app: 'slack', on: ['direct_message', 'mention'], message: 'Note what they are asked to do, and by when.' },
]);

A Slack account a person connected before AgentNava had its own Slack app only delivers to your app (url); signing in again moves it.

Whose account

The agent's connection for that app says, as it does for every turn. A connection to each end user's own account watches every end user who connected it: each delivery names the end user (endUserId), and each run is a new conversation of theirs. A connection to one of your accounts watches that account: a delivery names it (account), and a run goes where userId or conversationId say, as a webhook's does. Add the connection first: an event trigger whose app has no connection is refused. Name the connection with connection when the agent has two of one app.

What the agent reads (without url)

One message per group: one line per change with the ids to look it up, and no body. message replaces its first paragraph.

What your app receives (with url)

A person's changes are grouped for windowSeconds (default 30, at most 600) and arrive as one POST: one line per change with the ids to look it up, and no body (a mail's sender and subject, never its text). Each change has a key that never changes.

{ "type": "app_events", "agentId": "pulse", "endUserId": "ananya", "app": "gmail", "more": 0,
  "events": [ { "key": "gmail:message:18c4f", "on": "new_message", "at": "2026-11-16T15:42:00Z",
                "line": "from Ananya <ananya@example.com>, \"Q3 numbers\"", "ids": { "message": "18c4f", "thread": "18c4e" } } ] }

Check it came from us

Every delivery is signed the Standard Webhooks way with your secret (16 characters or more, sent once and never read back). Check it with verifyAppEvents and the body exactly as it arrived (with a whsec_ secret, any Standard Webhooks library works too), then answer 2xx quickly. A delivery that gets no 2xx is tried again after 30 seconds, 2, 10, 30 and 60 minutes, with the same webhook-id.

import { verifyAppEvents } from '@cerebro-labs/agentnava-sdk';

export async function POST(request: Request) {
  let delivery;
  try {
    delivery = await verifyAppEvents(await request.text(), request.headers, process.env.EVENTS_SECRET!);
  } catch {
    return new Response('bad signature', { status: 401 });
  }
  queue(delivery); // decide now, later or never; start the agent only for now
  return new Response(null, { status: 204 });
}

Where a run lands

A schedule or webhook runs in a conversation. What you name decides which one:

You nameEach firing runs in
conversationIdthat conversation, with its history and its drive. It also moves to the agent's latest version, so a fix you publish reaches it.
userIda new conversation for that end user, every time.
neitherone conversation the trigger keeps for itself, continued at every firing.
const conversation = await agent.start({ endUserId: 'ops-app' });

await agent.setTriggers([
  { kind: 'chat' },
  {
    kind: 'schedule',
    cron: '0 15 * * *',
    message: 'Refresh the dashboard.',
    conversationId: conversation.id,
  },
]);

One end user can have many conversations, so a userId cannot pick one, and the platform does not guess. To keep adding to the same conversation, name it. It must be a conversation of this agent, started for one of your end users; anything else is refused when you set the trigger. Name one or the other, never both. If the conversation is deleted later, each firing fails and says so on the schedule, and no other conversation is opened in its place.

A trigger is one list for every person, and each setTriggers() publishes a new version of the agent. A schedule naming a conversationId still works, and publishes a version at every change. To schedule one conversation without publishing a version, use its wake-ups (conversation.wakeups).

One person's schedule: wake-ups

A goal a person set ("every ask I owe answered on time", "close the Acme renewal by December 15") keeps working with your app closed: it wakes at its own times, for as long as the goal lives. Give its conversation wake-ups. They are not part of the agent's setup, so adding, changing or removing one publishes no version, however many people and goals there are.

const goal = await inbox.start({ endUserId: person.id });

// Every weekday at 8 in their morning, in their zone, across daylight saving.
const morning = await goal.wakeups.add({
  cron: '0 8 * * 1-5',
  timezone: 'Asia/Kolkata',
  message: 'Morning check: what does your person owe today?',
});

// Once, at a set time.
await goal.wakeups.add({ at: '2026-11-24T10:30:00+05:30', message: 'The Acme call is at 11: get the brief ready.' });

await goal.wakeups.change(morning.id, { cron: '30 8 * * 1-5' });   // keeps its id and its zone
await goal.wakeups.list();                                          // pending, soonest first
await goal.wakeups.remove(morning.id);
conversation.wakeupsagent.endUser(id).wakeups
Each firing runsin that conversation, with its history and drivein a new conversation for that person
On which versionthe agent's latest: the conversation is moved there first, so a fix you publish reaches every goal at its next wake-up
Withwhat the agent remembers about the person, when memory is on
Goes whenthe conversation is deleted, or its end user erasedyou remove it, or the end user is erased
At most20 of yours in one conversation20 of yours for one person
The agent sees and changes themyes, from that conversationno: they are yours (the list also shows its goals' own times, below)

The agent has the same wake-ups from inside the conversation, with its scheduling tools (CronCreate, ScheduleWakeup, CronList, CronUpdate, CronDelete), and only ever sees and changes that conversation's. list() shows its own beside yours (setBy: 'agent'), and either of you can change either: when the person says "check on Fridays instead", the agent moves your wake-up rather than adding one. A recurring one the agent sets itself stops after 7 days (until), and so does one it makes repeat; yours, and the repeating ones it only moved, last. Whether one of yours repeats stays yours to change.

A goal's own times. An agent that keeps goals in a knowledge space sets them itself, for the person a run is for, outside any conversation, each tied to one of its goals ("Mondays at 9", "an hour before the Acme call"), with goal_wakeup_add, goal_wakeup_update, goal_wakeup_remove and goal_wakeup_list. Each firing is a fresh run for that person, in a new conversation, its message naming the goal. They last while the goal is live, with no 7-day stop: pausing or ending the goal removes them, and when the person resumes it your app asks the agent to set them again, as at setup. agent.endUser(id).wakeups.list() shows them beside yours, as the agent's (setBy: 'agent') with the goal they serve; you may change or remove one, and it stays the goal's. At most 50 per agent and person, at most 48 of them run for the person a UTC day (past that, a repeating one comes again at its next time and a one-time one is dropped), and a repeating one names one minute of the hour, so it comes at most once an hour.

Only a conversation you started for one of your end users takes wake-ups: a workspace member's, a website visitor's or a project's is refused. A cron is read in its timezone (UTC when left out); an at already says its zone, in its offset, and may be up to 400 days ahead. Each firing is a turn, paid like any other.

Every firing is a request

And a request is billed

An interval fires at most once a minute (a shorter seconds is raised to 60), and with no maxRuns it is a bill that does not stop. Set maxRuns unless you mean it to run forever.

Out of credit, a firing is skipped instead of run, and it does not use up one of your maxRuns. The loop carries on at its usual pace, so it picks up again once credit is added.

Triggers belong to the version, like everything else that says what the agent is (a wake-up does not). A trigger's message is a prompt, so rolling an agent back brings its schedule with it. Only one schedule fires at a time: the scheduler reads the newest version. A trigger starts a new run and is never read by a conversation already in progress.

An interval follows the agent. Deleting the agent stops it, and so does a setTriggers() without it. Changing its seconds, maxRuns or message starts it again from its first run. Publishing anything else leaves it alone: it keeps its count and its next firing, and one that has used up its maxRuns stays finished.