Command triggers are the reverse of webhooks. Someone mentions the bot in a Matrix room, Botrix calls an external HTTP webhook, and the bot replies in the room with the result.
@botrix deploy production
Triggers are defined in the YAML config, so they live in version control. The web UI lists them and manages their secret values. Changes to the config need a restart.
Add the trigger under triggers and, optionally, shared allowlists under access_profiles. The full field list is in the configuration reference.
access_profiles:
ops:
allowed_rooms: ["!ops123:matrix.example.com"]
allowed_users: ["@alice:matrix.example.com"]
triggers:
deploy:
description: Deploy a service
method: POST
url: https://ci.example.com/hooks/deploy
headers:
Authorization: "Bearer {{secret:TOKEN}}"
secrets: [TOKEN]
response_template: "Deploy ${status}: ${message}"
access_profile: ops
Then open Triggers in the web UI and use Set value next to TOKEN. Until a declared secret has a value, commands that use it fail.
Bearer {{secret:TOKEN}}.Anything an API needs to keep private, such as a token, key or password, goes in a header as a secret. Setting one up takes three steps:
secrets.{{secret:NAME}}.Botrix puts the stored value in place when the command runs. The text around the placeholder stays as you wrote it.
The most common case. The secret holds only the token, because Bearer is part of the header text in the config.
triggers:
deploy:
description: Deploy a service
method: POST
url: https://ci.example.com/hooks/deploy
headers:
Authorization: "Bearer {{secret:TOKEN}}"
secrets: [TOKEN]
Some services expect the key in a header of their own instead of Authorization.
triggers:
restart:
description: Restart the app
method: POST
url: https://api.example.com/v1/restart
headers:
X-Api-Key: "{{secret:API_KEY}}"
secrets: [API_KEY]
Basic authentication sends user:password encoded as Base64. Botrix inserts the value exactly as stored and does not encode anything, so put the encoded value in the secret. Encode it yourself on your own machine, as a single line:
printf '%s' 'user:password' | base64
Use printf rather than echo, because echo adds a newline that ends up inside the encoded value. Then paste the result as the secret’s value:
triggers:
backup:
description: Start a backup
method: POST
url: https://backup.example.com/run
headers:
Authorization: "Basic {{secret:BASIC_CREDENTIALS}}"
secrets: [BASIC_CREDENTIALS]
A trigger can declare as many secrets as it needs. One secret can be used in several headers, and one header value can contain several placeholders. Headers that hold nothing private are written out in full.
triggers:
sync:
description: Sync the data
method: POST
url: https://api.example.com/v1/sync
headers:
Authorization: "Bearer {{secret:TOKEN}}"
X-Client: "{{secret:CLIENT_ID}}:{{secret:CLIENT_SECRET}}"
Accept: application/json
X-Source: botrix
secrets: [TOKEN, CLIENT_ID, CLIENT_SECRET]
_ and -, and are case-sensitive: {{secret:token}} does not match TOKEN.secrets for that trigger.Authorization, Proxy-Authorization, Cookie and X-Api-Key must contain a placeholder. A literal value there stops Botrix from starting, so a credential cannot be committed by accident. Botrix cannot recognise a credential under another header name such as X-Auth-Token, so use a placeholder for those yourself.{{secret:...}} is not expanded again.| Mistake | What happens |
|---|---|
A header uses {{secret:NAME}} but NAME is not under secrets, or the case differs |
Botrix refuses to start and names the trigger, the header and the secret |
Authorization, Cookie or another credential header has a literal value |
Botrix refuses to start and names the header |
| The secret is declared but has no value yet | The command replies Command failed. The Logs page shows command setup failed with missing secret: NAME. |
A message is a command when the bot is mentioned in it and the text starts with that mention. The first word after the mention is the command, matched case-insensitively. Everything after it is passed on as arguments.
help is built in. It lists the enabled commands the sender may run in that room.unknown command.not authorized, and the webhook is not called.Botrix calls the trigger’s url with the configured method and headers. The JSON body always has these keys:
| Key | Value |
|---|---|
command |
The command word, lowercase |
arguments |
The text after the command, as one string |
args |
The same text split on whitespace |
raw_message |
The full message text |
sender |
The sender’s Matrix user ID |
room_id |
The room ID |
event_id |
The event ID of the message |
The reply is sent as a reply to the triggering message.
| Outcome | Reply |
|---|---|
2xx JSON response and a response_template |
The template rendered with the response body, using the same ${field.path} syntax as webhook templates |
| 2xx but no template, a non-JSON body, or a template that cannot be rendered | Command succeeded |
| Non-2xx status, timeout, blocked address, missing secret or any other error | Command failed |
Details of failures go to the Logs page. They are never put in the room, and logs never contain secret values or response bodies.
Replies are not retried. A command is never replayed, so a failed deploy is reported once and not run again after a restart.
Every command that runs, is refused or fails is recorded on the Logs page, along with the sender and room. Setting or clearing a secret is recorded too, with the secret’s name but never its value.
echo does not match echo2.Events are kept for 30 days, and at most 10,000 are stored.
http and https URLs are allowed, and certificates are validated.A trigger can limit the rooms and users that may run it, directly with allowed_rooms and allowed_users or through an access_profile. The sender must pass both checks, and an empty list does not restrict that dimension. Anyone who can mention the bot in a room can otherwise run an enabled command, so restrict commands that change things.