Skip to content

Notify with Actions

Actions send notifications when evaluation or build events occur. Examples: a mail to the team on every failed build, a web request on each successful build, or a Matrix or Slack message.

Requirements:

1. Add the Action

On the task, go to Actions -> New Action and select a type.

Type Fields
Mail Recipients, a comma-separated list of email addresses or team:<name>. An optional Subject Template
Webhook URL. An optional Token, displayed one time after saving
Matrix Homeserver, Room ID, Access Token
Slack Webhook URL

Mail works only after email has been configured on the server.

A team:<name> recipient names a team granted with users on the project. Mail goes to its verified members.

services.gradient.state.tasks.web-app.actions = [
  {
    name = "notify-ops";
    type = "send_mail";
    events = [ "evaluation.failed" "build.failed" ];
    config.recipients = [ "ops@example.com" ];
  }
  {
    name = "chat-hook";
    type = "send_web_request";
    events = [ "evaluation.completed" "evaluation.failed" ];
    config = {
      url = "https://hooks.example.com/gradient";
      token_file = "/run/secrets/chat-hook-token";
    };
  }
  {
    name = "ops-room";
    type = "send_matrix_message";
    events = [ "evaluation.failed" "build.failed" ];
    config = {
      homeserver = "https://matrix.example.org";
      room_id = "!abc123:example.org";
      access_token_file = "/run/secrets/ops-room-token";
    };
  }
  {
    name = "ops-channel";
    type = "send_slack_message";
    events = [ "evaluation.failed" ];
    config.webhook_url_file = "/run/secrets/ops-channel-webhook";
  }
];

2. Pick the Events

An action without events can never fire. Most actions need only a few of them, listed here.

Event Trigger
evaluation.completed All builds in the evaluation passed
evaluation.failed The evaluation failed
build.failed A single build failed
fork_pull_request_approval.needs_maintainer_approval A commit of a fork pull request waits for maintainer approval

The events reference list every available event.

Mail

  • Subject placeholders: {event}, {task}, {project}, {id}, {status}.
  • Default subject: [Gradient] {event}: {task}.
  • Body: the message line, the event, the time and a link to the evaluation log.

Web Request

Every delivery arrives as a POST request with a JSON body. The content field holds the event data.

{
  "event": "build.failed",
  "at": "2026-09-26T12:00:00.123Z",
  "content": { "build_id": "...", "evaluation_id": "...", "task": "...", "project": "...", "status": 4, "status_name": "failed_permanent" }
}
Header Value
X-Gradient-Event Name of the event
X-Gradient-Signature sha256=<HMAC-SHA256 of the body, with the token as key> with the token only

A receiver can verify the signature to reject requests not sent by Gradient.

  • Gradient can retry rate limits (429) and server errors (5xx). The wait can last for the delay from Retry-After.

Matrix and Slack

Each event becomes a single message line with a link to the evaluation log.

web/app: hello-2.12.1 failed on 3f9c2ab
Part Content
web/app Project and task
hello-2.12.1 Derivation, on build events only
failed Status, taken from the event name
3f9c2ab Short commit hash
  • Gradient retries rate limits (429) and server errors (5xx).
  • Any other HTTP error ends the delivery as failed. Failed deliveries show up under Deliveries.
  • The access token and the webhook URL sit in storage in encrypted form. The UI and the API never send them back.

Matrix Access Token

  • Use a dedicated bot account. The bot has to have joined the room.
  • Encrypted rooms do not work.
  • Find the Room ID under room settings -> Advanced, in the form !abc123:example.org. Rooms of version 12 and later have IDs without the server part, like !abc123. Room aliases like #ops:example.org get rejected.
  • Edits that move Homeserver to another scheme, host, or port require the access token again. These edits fail without the token. Failed edits leave the stored token unchanged.

A password login gives the access token of the bot account.

curl -s -X POST https://matrix.example.org/_matrix/client/v3/login \
  -d '{"type":"m.login.password","identifier":{"type":"m.id.user","user":"gradient-bot"},"password":"<password>"}' \
  | jq -r .access_token

Slack Webhook URL

  • Slack apps with Incoming Webhooks enabled issue one URL per channel, under Add New Webhook to Workspace.
  • The URL looks like https://hooks.slack.com/services/T.../B.../....

Commit Status

The Report commit status option on the Repository page of a task can post one check per step to commits and pull requests. The option can use the connection of the task to the Git host. Set the option in Git host guides.

Check State
gradient/<task>: Approval Fork pull requests only. Stays pending until a maintainer approves
gradient/<task>: Evaluation Pending while the evaluation runs, then reports success or failure. A failure marks any entry point that could not be evaluated, while the remaining builds keep going
gradient/<task>: Build <entry point> One check per entry point. Moves from pending to running, then to success or failure. An entry point that failed to evaluate shows failure with no build

An evaluation started with /gradient run <wildcard> reports as gradient/<task>: Evaluation: <wildcard> in addition to the default checks.

Use Test the status report to post a pending status on the latest evaluated commit and display the response from the Git host.

Verify Deployment

  • Each action row contains a Test button. A click sends a sample event to the receiver with "synthetic": true set.
  • The Deliveries view on each action row shows all requests with their status, duration, request body and response body.

Troubleshooting

Symptom Fix
Mail absent from the type list Set up email on the server
Delivery fails with connection refused The server cannot reach the URL
Deliveries never happen The action was deactivated, or none of the events fired
Matrix delivery fails with 403 The bot left the room, or the access token got revoked
Slack delivery fails with 403 or 404 The webhook was deleted in Slack

Next Steps