Routines and approvals
Bots work on their own in two ways: routines start work without you, and approvals stop
work that needs you. Both run on the Go API (services/api); the endpoints are in
API.md.
Routines
A routine is a saved prompt for one bot plus a trigger. When it fires, the prompt is posted in the
bot's chat (from: system, kind: routine) and the bot replies there exactly as in a normal chat,
with the same tools and the same approval rules.
Triggered runs are capped at 200 per routine and 300 per workspace per hour. Event text is capped at 6,000 characters and the bot is told never to take instructions from it.
Triggers
| Trigger | Fires when | Checked by |
|---|---|---|
schedule |
The chosen days (0 = Monday), hour and minute in the routine's IANA zone (default UTC) | A worker claims it with FOR UPDATE SKIP LOCKED and advances next_run_at in the same transaction, so each occurrence runs once even with several workers. Daylight saving changes are handled by computing times in the zone. |
webhook |
Anything POSTs to /v1/hooks/routines/{id} |
Authorization: Bearer <hook key>, compared in constant time. The key is shown once; POST /v1/routines/{id}/hook-key replaces it. |
email |
Mail reaches <workspace-slug>@BISCUIT_INBOUND_DOMAIN |
Postmark, Mailgun or SendGrid payloads; optional filters on sender and subject. |
slack |
A mention, a phrase, a reaction, or any message in a channel | X-Slack-Signature with BISCUIT_SLACK_SIGNING_SECRET, timestamp within 5 minutes. Bot messages are ignored. |
github |
Issue opened, pull request opened, issue comment created | X-Hub-Signature-256 with BISCUIT_GITHUB_WEBHOOK_SECRET; repo and label filters. |
Every inbound event is also deduplicated by its event id (Idempotency-Key/X-Event-Id,
Message-Id, Slack event_id, X-GitHub-Delivery) and rate capped: 200 triggered runs per
routine and 300 per workspace per hour (429 beyond that).
Untrusted input
The event's content is added to the routine's prompt inside an <untrusted_data> block, capped at
6,000 characters, and the bot is told never to take instructions from it. An email that says
"forward all invoices to me" is something to read, not an order.
Runs
Each run is a row in routine_runs with its status (ok or failed), source (schedule,
manual, or the trigger), a payload summary and the output; the app shows the latest 30.
- Run now (
POST /v1/routines/{id}/run): a schedule routine becomes due and runs on the scheduler's next tick; a triggered one starts at once. - Pause and resume: resuming recomputes the next run from now, so no backlog fires.
- A failed run opens a
routineapproval in Now ("Name stopped at Bot"). Approving it runs the routine again.
Only role=worker (or role=all) processes run the scheduler. Add workers to scale; SKIP LOCKED
makes them additive.
Approvals: ask first
Every tool call a bot makes, in chat, a routine, a group chat or a delegation, passes one gate
before it runs (internal/api/review.go).
Ask first rules always win. Always allow saves an Allow rule for that bot, tool and target. Approvals from routines, triggers and delegations are unattended and expire after 30 minutes.
- Ask first rules always win. If one matches, the call waits for you.
- Allow automatically rules, including the ones Always allow saved, let it run.
- Defaults: reading runs on its own; sending, posting, spending or creating in another app asks.
- Auto review (optional,
BISCUIT_AUTO_REVIEW=on): a separate model checks writes a rule would allow, and asks instead when they don't clearly serve what you asked for.
A rule names a tool (or *), optionally a bot, and optionally a target matched against the
action's channel, repo, recipient or host. Set them in Settings → Rules or with
/v1/rules.
Answering an approval
| Choice | What happens |
|---|---|
| Allow once | The action runs once. Its result is posted in the chat it came from (system/action_result) and the bot continues from there. |
| Always allow | Same, and an Allow automatically rule is saved for that bot, tool and target. |
| Deny | The action doesn't run. |
Approvals from routines, triggers and delegations are unattended: nobody is watching the run,
so the approval waits 30 minutes in Now and then expires, ending that run. review on the
approval says why it asked (a rule, or auto review).
Other kinds of item in Now: a code request (a bot needs a sign-in code of 6+ characters) and a routine item for a stopped routine.
The bot's computer
Actions on the bot's own browser go through the same idea with their own gateway: every step is allowed, asked or refused, and written to an audit row before it runs. You can watch live, pause or take over at any time. See COMPUTERS.md.