Triggers, schedules and outcome billing
Start a workflow without clicking Run
Open Workspace → Schedules. Six ways to start a saved workflow:
| Trigger | What starts the run | Where the inputs come from |
|---|---|---|
| Schedule | A cron expression in your timezone | The inputs saved with the schedule |
| Webhook | Another system posting JSON to the trigger's URL | The posted body (payload), or the fields your mapping picks |
A message to the trigger's address (run+…@runs.changents.ai) | from, subject, text; attachments become the run's files | |
| Event | Something that happened on the platform (see Event triggers) | The event (payload.event) |
| File | A new or changed file in a synced SharePoint/OneDrive or Google Drive folder | The file, as the run's attachment; its name and link in payload.file |
| Stream | A message on a Redis stream, Kafka topic or AMQP queue you run (see Stream triggers) | The message (payload), or the fields your mapping picks |
When every step of a real run has finished, its report shows Run this every week. It opens Workspace → Schedules with a schedule for Mondays at 08:00 ready: pick the saved workflow, change the cron or timezone if you want another time, and create it. The link is not shown for a simulation, or for a run with a failed step or a step waiting for approval.
The URL or address is the credential: anyone who has it can start the run as you, through your quota, your agent charters and your approval rules. Share it only with the system that needs it, and delete the trigger to revoke it. The address or URL is shown in full only to you, in your workspace.
A trigger always runs the workflow's released version when one exists, never the draft someone is editing, exactly as a schedule does. Every run appears under Runs like a manual one, and the trigger shows its last run and status.
Example: a carrier's demurrage and detention invoice arrives by email. Create an email trigger on the "Demurrage & detention dispute case" workflow (From CHANGENTS, in the marketplace) and have your mailbox forward carrier invoices to its address. The invoice attachment is checked in code, the dispute letter waits for a person, and the recovered amount is recorded when the carrier answers.
Sending the same event twice
A webhook caller can send an Idempotency-Key header. The same key on the same trigger within 24 hours starts no second run: the answer is 202 with the first run's id and "duplicate": true. An email trigger does the same with the message's id, so a message delivered twice starts one run. A schedule fires once for each scheduled time.
Runs started by a trigger or a schedule are queued like any other run and survive a server restart (see Running & Monitoring Workflows). The trigger or schedule shows the run's outcome once it ends.
Mapping webhook fields
With no mapping, the whole JSON body is the payload input. To map fields, set inputMapping on the trigger (API: PATCH /api/triggers/:id), for example {"invoiceNo": "invoice.number", "carrier": "invoice.carrier"}.
Signed webhook requests
The URL alone is enough to start a run. To require more, turn on Require signed requests when you create a webhook trigger, or Require signing on an existing one. A signing secret (whsec_…) is shown once; store it in the sending system. Rotate secret issues a new one and the old one stops working at once. Stop signing goes back to URL-only.
With signing on, each request must carry a Changents-Signature header (X-Changents-Signature is accepted too) in the same form CHANGENTS.AI uses for its own outgoing webhooks: t=<unix seconds>,v1=<hex>, where v1 is the HMAC-SHA256 of "<t>.<raw request body>" keyed with the secret. A request with no signature, a wrong one, a changed body, or a t more than 300 seconds from our clock is refused with 401 and starts nothing.
const crypto = require('crypto');
const body = JSON.stringify({ invoice: 'DD-1' });
const t = Math.floor(Date.now() / 1000);
const v1 = crypto.createHmac('sha256', secret).update(`${t}.${body}`).digest('hex');
await fetch(triggerUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Changents-Signature': `t=${t},v1=${v1}`,
'Idempotency-Key': 'invoice-DD-1',
},
body,
});Triggers created before signing existed, and any trigger with signing off, keep accepting unsigned requests.
Sending the same request twice
Send an Idempotency-Key header (or Changents-Event-Id) with a value unique to the thing you are reporting. A repeat of the same key to the same trigger within 24 hours starts nothing: it answers 200 with "duplicate": true and the id of the run the first request started. A request whose run could not start (a disabled trigger, a workflow with no steps) does not use up its key, so you can send it again. Keys are stored only as a SHA-256 hash.
Event triggers
An event trigger starts a workflow when something happens on the platform. Pick the event, and optionally an agent type, when you create it.
| Event | When |
|---|---|
| run.finished | A real run (not a rehearsal or a simulation) ended completed, partial or cancelled |
| run.failed | A real run ended failed |
| approval.decided | A person approved or rejected a step that was waiting on them |
| alert.raised | An agent health alert, or an IoT device alert, was raised |
| document.synced | A synced folder had a new or changed file |
These are not the outgoing webhook events; they never leave the platform. Only your own events start your triggers (your organisation's, if you are a member). The run receives the event under payload.event: its type, time, workflow, agent type, run id and the facts listed for it (a run's status and duration, an approval's decision, an alert's rule or device reading, a file's name and link).
A workflow never restarts itself through an event. Each event carries the workflows whose runs led to it; a trigger on a workflow already in that chain does not fire, so a workflow's own run, or a loop of two workflows starting each other, stops. A chain is also cut at five workflows.
GET /api/triggers/events lists your events of the last seven days and which triggers each one started. Events are deleted after seven days.
File triggers
A file trigger watches one of your synced folders (connect one under Vault → Synced folders). Each time the folder syncs, every file that is new, or whose modified time changed, starts the workflow once, with the file as the run's attachment. The first sync of a folder records what is already there and starts nothing. Up to 20 files, and 60 MB, are announced per sync; the rest are announced at the next one. Each arrival is also a document.synced event.
The folder syncs on its own schedule (daily at 03:00 UTC unless you set another), or when you press Sync on it, so a file starts its run at the next sync, not the moment it is saved.
Stream triggers
A stream trigger starts the workflow once for each message published to a Redis stream, for a system that publishes messages and cannot call a URL. Give the stream's address (redis:// or rediss://, with a password if it needs one), the stream name and, if you want your own, a consumer group (changents unless you set another).
- Only messages published after the trigger is created start runs. The stream's history is not replayed.
- The stream is read every few seconds, through a consumer group, so each message starts one run however many copies of the platform are running.
- A message is acknowledged only once its run is queued. If the platform restarts in between, the message is delivered again and does not start a second run.
- A message whose run can never start (the workflow was deleted, or the message is over 200,000 characters) is acknowledged and not retried. The trigger shows the reason.
- A message's fields become
payload. A message with a single field namedpayloadordataholding a JSON object becomes that object. - The address is stored encrypted and is not shown again; the trigger shows the host, the stream name, when it was last read and the last error, if any.
On the hosted service the stream must be reachable on the public internet and use rediss:// (TLS). On an install you run on your own network (TOOL_EGRESS_ALLOW_PRIVATE=true, or air-gapped mode) it can be a private address, and an air-gapped install reads nothing else.
Kafka topics and AMQP queues
The same trigger reads two other kinds of broker. The start of the address says which:
| Address starts with | Reads | Name field | Consumer group |
|---|---|---|---|
redis://, rediss:// | A Redis stream | The stream | changents unless you set one |
kafka://, kafka+ssl:// | A Kafka topic | The topic | changents unless you set one |
amqp://, amqps:// | An AMQP 0-9-1 queue | The queue | None |
A Kafka topic is read by a consumer that stays connected, in the consumer group you name.
- A new group starts at the end of the topic, so only messages published after the consumer has joined start runs. Joining takes a few seconds after the trigger is created.
- A message's position is committed once its run is queued. A message delivered again does not start a second run.
- Put a user name and password in the address to sign in with SASL, and add
?mechanism=scram-sha-256or?mechanism=scram-sha-512if the cluster does not useplain. Add?brokers=host:port,host:portto name more brokers to connect through first. - A message that is a JSON object becomes
payload. Any other message becomespayload.message, as text.
An AMQP queue is read every few seconds, like a Redis stream.
- The queue must already exist. It is not created for you, so a mistyped name is reported on the trigger as a queue that does not exist.
- Every message waiting in the queue starts a run, including ones published before the trigger was created.
- A message is acknowledged once its run is queued. If that fails, it goes back on the queue.
- A message delivered again starts a second run unless the publisher set a message id on it: the message id is what a redelivery is recognised by.
- The path of the address is the virtual host:
amqps://user:password@broker.example.com/orders. - A JSON object becomes
payload; any other message becomespayload.message.
The address rules are the same for all three: on the hosted service a public address and the TLS form (rediss://, kafka+ssl://, amqps://); a private address only on an install you run on your own network. For a Kafka cluster this also applies to every broker the cluster names.
Through the API
| Method | Path | What it does |
|---|---|---|
| GET | /api/triggers | Your triggers |
| POST | /api/triggers | Create: workflowId, kind, name, signing, eventFilter, fileSourceId, stream (url, key, group) |
| PATCH | /api/triggers/{id} | Enable, rename, change the mapping or event filter, signing on or off |
| POST | /api/triggers/{id}/rotate-secret | A new signing secret, returned once |
| DELETE | /api/triggers/{id} | Revoke |
| GET | /api/triggers/event-types | The events an event trigger can start on |
| GET | /api/triggers/events | Your platform events of the last seven days |
| POST | /api/hooks/{token} | Start a webhook trigger's workflow |
* | /api/schedules… | List, create, pause, resume and delete schedules |
Outcome billing
Billing → Outcome billing shows what your agents' confirmed results would bill at your rates:
- a share of the demurrage and detention money a dispute recovered (default 20%), counted only once a person records the recovered amount on the invoice;
- a fixed amount per support case closed as resolved by a person.
Each outcome names the invoice or case it rests on; nothing is billed on the model's say-so, and an outcome is billed once. An organisation owner or admin can set the rates and issue a month's outcomes as an invoice on terms, one invoice per currency.