Triggers
A trigger starts a task when something happens, as a schedule does at a time:
| Trigger | Starts the task when | Watched by |
|---|---|---|
| File | a file is created (or changed, or deleted) in a folder | the agent, which also runs the task |
| a mail that matches arrives in a mailbox | the agent, which also runs the task | |
| Webhook | another system calls the trigger's web address | the server; the task runs on any free agent, a group or one agent |
| Hotkey | someone presses a key combination on the agent machine | the agent (its tray app), which also runs the task |
Like schedules, triggers run the task's public version on behalf of the user who created the trigger (that user's vault access applies). Runs started by a trigger show its name under Started by on the execution pages.
The event in the task
The event's details reach the task as its trigger input, a record. Declare it to use them:
input --name:trigger --type:record --required:false
log --message:"New file: $trigger.Path$"
| Trigger | Fields of $trigger$ |
|---|---|
| File | Path, Name, Folder, Extension, Size (bytes), Event (created, changed or deleted), Time |
Id, From, FromName, To, Cc, Subject, Date, Body, HtmlBody, Attachments (names), Folder |
|
| Webhook | Body (JSON as a record or list; any other body as text), Query (the address's parameters), ContentType, ReceivedAt |
| Hotkey | Keys, Machine, UserName, Time |
A mail's Id works with the mail command, for example to save its attachments:
input --name:trigger --type:record --required:false
mail --action:saveattachments --server:imap.company.com --credential:$mailbox$ --id:$trigger.Id$ --destination:C:\In\$trigger.Id$
The trigger can also give the task's other inputs fixed values (under INPUTS in the trigger form).
Create a trigger
Open Triggers (Manage triggers permission, Developer by default) and click New trigger. Choose what starts the task, then fill in:
| Field | Description |
|---|---|
| Name | For example New invoices. |
| Task | The task to run. Tasks without a public version are disabled. |
| Agent | File, mail and hotkey triggers: the agent that watches and runs the task. Webhooks: Any available agent, an agent group or one agent. |
| Active | Whether the trigger starts the task. |
File triggers
| Field | Description |
|---|---|
| Folder | On the agent machine or a share it reaches (\\server\share\in). Environment variables such as %USERPROFILE% work. |
| Files | A filter such as *.pdf (default *.*). |
| When a file is | Created (default; a file renamed into the filter counts as new), Changed or Deleted. |
| Subfolders too | Watch the folders inside it as well. |
A new file is sent once it is complete: when it can be opened and its size has stopped growing, so a large copy does not start the task half way. A folder that does not exist yet is looked for again every 30 seconds, and the trigger shows the problem meanwhile.
Mail triggers
| Field | Description |
|---|---|
| IMAP server, Port, Security | For example outlook.office365.com, 993, SSL/TLS. |
| Sign-in | User name and password, or Microsoft 365 (OAuth) with an app registration: then also the Tenant and the Mailbox address, and the credential holds the application (client) id as user name and the client secret as password (as for the mail command). |
| Vault, Credential | Where the mailbox password (or app secret) is kept. |
| Mail folder | INBOX by default. |
| From contains, Subject contains | Optional filters. |
| Check every | 15 to 3600 seconds (default 60). |
Each unread mail that matches starts the task once and is marked as read. Mails are taken oldest first, at most 20 per check. Sign-in problems are shown on the trigger (once, not at every check).
Webhook triggers
When a webhook trigger is created, Botream shows its address and a token, once. Other systems call it with POST:
curl -X POST "https://rpa-server/api/hooks/12" \
-H "X-Botream-Token: <token>" \
-H "Content-Type: application/json" \
-d "{\"orderNo\": \"A-17\"}"
- The token goes in the
X-Botream-Tokenheader, or as?token=in the address. A wrong or missing token answers404, as if the trigger did not exist. - The answer is
202with{"status": "Started", "executionId": "1042"}, or"Queued"when no agent is free; a trigger that is turned off answers409. - New token in the trigger's menu replaces the token; the old one stops working at once.
- The address needs no sign-in. Publish it to the systems that call it only, preferably over HTTPS.
Hotkey triggers
Click the Key combination field and press the keys, for example Ctrl+Shift+F9. A combination needs Ctrl, Alt, Shift or Win, except F-keys, Pause and Print Screen, which may stand alone. Two hotkey triggers of an agent cannot share a combination, and a combination another program holds is refused (the trigger shows why).
Hotkeys work while someone is signed in on the agent machine and the Botream Agent tray app runs.
When the agent is busy
An agent runs one task at a time. An event that finds no free agent waits on the server, and the trigger shows Waiting for an agent with the number of waiting events. The server tries again every few seconds, oldest event first. Events wait up to an hour (and at most 1,000 per trigger); then they are dropped and the trigger says so.
Events an agent notices while it cannot reach the server wait on the agent and are sent when it is connected again (up to an hour).
The Triggers page
Each trigger shows what it listens to, the agent, its Last event (Started with a link to the run, Waiting for an agent, or Problem with the reason when you hover it), how many runs it started, and an Active switch. Creating, changing and deleting triggers and renewing tokens are recorded in the audit log.