Expressions

Expressions are CEL. They are written in integration definitions and in hooks. An expression is at most 2,000 characters.

Syntax

WhereWritten asExample
An integration or hook written as JSON${{ <CEL> }}"${{ body.event.type == \"app_mention\" }}"
An integration or hook written in HCL$${{ <CEL> }}"$${{ body.data.id }}"
A hook's whenbare CEL, or ${{ <CEL> }}event.inputs.query != ''

A field that contains one expression must be the whole string, ${{ ... }}, with nothing around it but spaces. Such fields are rejected otherwise, with must be an expression, written as ${{ ... }}.

A field that contains text (a request's url, query, headers and body strings, a tool input's default, asymmetric.key, and a hook step's with strings and request fields) may contain any number of expressions inside it:

https://api.example.com/issues/${{ task.marks["linear.issue"] }}/comments

When the text is one expression and nothing else, it keeps the expression's type, so a body field written ${{ {"channel": target.channel} }} sends a JSON object. Otherwise each expression is written into the text.

In JSON, an integer is a number. An integer of 2^53 or more, or of -2^53 or less, is its digits as text. Bytes are base64 text. A timestamp is RFC 3339 text in UTC. A duration is text in seconds, as in 90s. A type is its name. A double that is not a number or is infinite is text: NaN, Infinity or -Infinity. A map is an object with text keys. A map with two keys that JSON writes the same, such as 1 and "1", fails the expression.

Evaluation

The expression isWhen it fails to evaluate
a condition (when, ignoreWhen, respond.when, expect.success, a hook's when)it counts as false
in a request's url, query, headers or body, or a hook requestthe request is not sent and fails
anywhere elseit reads as nothing: no mark is kept, a capture is null, a title is empty

Reading a field that is not there fails. has() tests whether a field is there:

has(body.data.assignee) ? body.data.assignee.email : ""

has() takes only a field of a value. For a field of a function's result, use in, as in "message" in parseJson(body.payload).

Functions

Besides the standard CEL functions, every expression can call:

FunctionReturnsDescription
parseJson(string)dynReads a JSON text as a value, as in parseJson(body.payload).type. Fails when the text is not JSON.
htmlUnescape(string)stringDecodes &amp;, &lt; and &gt; in a text, as in htmlUnescape(body.event.text). It does not rewrite Slack tokens such as <@U123>.

No expression may read a secret. An expression containing secret. or secret[ is rejected.

Integration positions

A position is the path of a field, with * for any key or index. Returns is what the expression must return, when anything is required. These tables leave out the integration. prefix and write [*] as .*: the check and positions APIs write webhook.events.*.when as integration.webhook.events[*].when, and a check names a real index, as in integration.webhook.events[0].when.

PositionReturnsVariables
webhook.verify.hmac.signed, webhook.verify.hmac.freshness.at, webhook.verify.asymmetric.key, webhook.verify.asymmetric.signed, webhook.verify.asymmetric.freshness.atbody, headers, raw
webhook.respond.whenboolbody, headers, raw
webhook.respond.bodybody, headers, raw
webhook.ignoreWhenboolbody, headers, raw
webhook.route.by, webhook.deliverybody, headers, raw
webhook.events.*.forEachlistbody, headers, raw
webhook.events.*.whenboolbody, headers, raw, item, lookup
webhook.events.*.lookup.request.url, .query.*, .headers.*, .bodybody, headers, raw, item
webhook.events.*.lookup.withbody, headers, raw, item
webhook.events.*.lookup.request.expect.successboolthe above, response, status
webhook.events.*.lookup.request.capture.*, webhook.events.*.lookup.capture.*the above, response, status
webhook.events.*.raise.message, .author.email, .opens.title, .opens.description, .opens.assignBy.email, .opens.chat.by.email, .branch, .marks.*.valuebody, headers, raw, item, lookup, captures
webhook.events.*.raise.attachments.eachlistbody, headers, raw, item, lookup, captures
webhook.events.*.raise.attachments.name, .type, .size, and .fetch request fieldsthe above, file
poll.request.url, .query.*, .headers.*, .bodycursor, connection
poll.request.expect.successboolcursor, connection, response, status, headers
poll.request.capture.*cursor, connection, response, status, headers
poll.cursorbody, cursor
poll.events.*as for webhook.events.*body, cursor, and as for webhook.events.*
actions.*.request.url, .query.*, .headers.*, .bodytask, ask, chat, reply, request, notice, target, connection, uploaded, inputs
actions.*.request.expect.successboolthe above, response, status, headers
actions.*.request.capture.*the above, response, status, headers
actions.*.usage.inputTokens, .outputTokens, .cost, .currency, .modeltask, ask, chat, reply, request, notice, target, connection, uploaded, inputs, response, status, capture
actions.*.uploads.eachlisttask, ask, target
actions.*.uploads.prepare.url, .query.*, .headers.*, .bodythe above, connection, file
actions.*.uploads.prepare.expect.success, .capture.*the above, response, status, headers
actions.*.uploads.send.url, .query.*, .headers.*task, ask, target, connection, file, prepared
actions.*.uploads.send.expect.success, .capture.*the above, response, status, headers
actions.*.uploads.complete.url, .query.*, .headers.*, .bodytask, ask, target, connection, uploaded
actions.*.uploads.complete.expect.success, .capture.*the above, response, status, headers
actions.*.uploads.ready.url, .query.*, .headers.*, .bodytask, ask, target, connection, file, prepared
actions.*.uploads.ready.expect.success, .capture.*the above, response, status, headers
tools.*.inputs.*.defaulttask
tools.*.outputtask, inputs, connection, response, status, capture
connection.oauth2.identityresponse
on.*.*.to.*task, ask, chat, reply, request, notice
on.*.*.mark.*.valuetask, ask, request, target, connection, uploaded, response, capture

item is seen only when the event has forEach. lookup is seen only when the event's lookup has call. Captures are the names in the event's lookup.capture, each seen by its own name. inputs is seen by an action only when a tool calls it. A capture named like a built-in name shadows it, and is warned about.

What an action has at run time depends on what calls it:

Called byHas
a tooltask, inputs, connection
an event's lookup.call, for a read-only toolinputs, connection
an on binding for a task eventtask, ask, target, uploaded, connection
an on binding for a chat eventchat, reply, target, uploaded, connection
an on binding for an inbox request eventtask, request, target, uploaded, connection
an on binding for a notice eventnotice, target, uploaded, connection
a scheduleconnection

An expression in an action, a binding or a tool's output is checked against what calls it, as the table above lists:

ExpressionChecked against
on.*.*.to.*, on.*.*.mark.*.valuewhat the binding's event has
actions.*.request fieldswhat each binding, tool, lookup and schedule that names the action has. It must check for each of them. A lookup counts only for a tool that a lookup of the same integration calls
actions.*.uploads fieldswhat a binding of a task event has. Only those bindings send files
tools.*.outputwhat a tool has, and what a lookup has when a lookup of the same integration calls the tool

An action that nothing names is checked against what any caller has. An expression that reads a variable its caller does not have gets a warning, as in does not check: Unknown variable: task. A notice event has no such variable for a binding of notice.raised that reads task.title.

Integration values

NameTypeDescription
bodydynThe delivery or poll response, parsed as JSON.
headersdynThe delivery's headers, by lowercase name.
rawstringThe delivery's body as text.
cursorstringThe poll's cursor, "" before the first.
connectionstringThe team's OAuth access token.
responsedynThe response body, parsed as JSON when it is JSON, else text; null when empty.
statusdynThe response's HTTP status.
capturemapThe request's capture values, by name.
itemdynThe current entry of forEach.
filedynThe current entry of attachments.each, or of uploads.each.
preparedmapThe capture values of uploads.prepare for the current file, by name.
uploadedlistThe files that uploads sent. Each has id, name, type, size and prepared. Empty for an action without uploads.
inputsmapThe tool's inputs, by name.
lookupdynThe output of the tool an event's lookup.call names. Unset when the call fails.
targetmap of stringThe values of the binding's to, and channel from routes.

task:

FieldTypeDescription
task.titlestringThe task's title.
task.urldynThe task's address in Spotlight.
task.pullRequestslist of stringThe addresses of the task's pull requests, one for each repository, the first opened first. Empty without one.
task.linestringThe key of the task's line.
task.stationstringThe name of the task's station.
task.stationKeystringThe key of the task's station.
task.marksmap of stringThe task's marks, by kind, as in task.marks["slack.thread"]. For a task created from a chat, also the chat's marks that do not find it.

ask:

FieldTypeDescription
ask.bodystringWhat the task asks, when it waits on a person; otherwise "". When it waits on an approval, ends with a link to decide it.
ask.linkdynThe address of the conversation in the inbox, or null.
ask.stationstringThe name of the task's station.
ask.attachmentslistThe files of the question, as a handover's screenshots. Each has id, name, type and size. Empty when the task does not wait on a person.

chat:

FieldTypeDescription
chat.marksmap of stringThe chat's marks, by kind, as in chat.marks["slack.channel"]. For chat.refused, the marks of the happening.

reply:

FieldTypeDescription
reply.bodystringWhat Spotlight says to the chat.
reply.linkdynThe address of the task the reply is about, else of the chat, in Spotlight; null for chat.refused.
reply.proposalslistThe chat's open proposals, listed in reply.body, for the last words of a run; otherwise empty. Each has number, title, and line and station, which can be null.

request:

FieldTypeDescription
request.formstringWhat the request asks for: memories for proposed memories, alert for a station alert.
request.linkdynThe address of the request in the inbox, or null.

notice:

FieldTypeDescription
notice.formstringended when a search for a better station config ended, advice for advice about a station.
notice.headlinestringThe notice's headline.
notice.pointslist of stringThe notice's points, in order.
notice.linkdynThe address of the notice in the inbox, or null.
notice.externalLinkdynThe notice's link outside Spotlight, such as a pull request, with url and label; null without one.

Hook positions

PositionReturnsVariables
hook.whenboolevent, task, run, vars, hook
hook.steps.*.with.*the above, step
hook.steps.*.request.urlthe above, step
hook.steps.*.request.headers.*the above, step
hook.steps.*.request.bodythe above, step
hook.briefthe above, step

A hook's match is compiled into conditions of the same kind as when.

Hook values

NameTypeDescription
eventobjectThe event's fields. Every event has event.at, an ISO 8601 time. The rest are listed per event in Events.
task.idstringThe task's id.
task.titlestringThe task's title.
task.urlstringThe task's address in Spotlight.
task.linestringThe key of the task's line.
task.stationstringThe name of the task's station.
task.stationKeystringThe key of the task's station.
task.marksmap of stringThe task's marks, by kind.
task.repositorieslist of stringThe line's repositories, as owner/name.
task.pullRequestdynThe address of the task's first pull request, or null.
task.pullRequestslist of stringThe addresses of the task's pull requests, one for each repository, the first opened first. Empty without one.
run.idstringThe run's id. Only on events that happen in a run.
varsmap of stringThe hook's vars.
hook.keystringThe hook's key.
step.<name>.statusstringdone, failed or waiting, for a step before this one.
step.<name>.outputdynThat step's response.

Type-checking

Every expression is type-checked against the variables of its position when the definition is written.

ProblemIntegrationHook
does not parseerror, write rejectederror, write rejected
does not type-check, or returns the wrong typewarning, definition kepterror, write rejected

An integration warning reads does not check: <message>, followed by . Did you mean <suggestion>? when there is one. Warnings are returned in the resource's warnings, and the Terraform provider shows them as warnings on the attribute.

body and response are dyn unless a shape declares them. See Shapes.

Check API

POST /api/v1/expressions/check

Type-checks one expression where it would be written, as terraform plan does. Needs the plan permission; a workspace token without it gets 403. It takes the same credentials and returns the same problems as the resource API.

FieldTypeDescription
positionstringWhere the expression is written, as in integration.webhook.events[0].when or hook.steps[0].with.text. Begins with integration or hook.
expressionstringThe CEL, without ${{ }}.
definitionobjectThe whole integration or hook, as it would be created.
{
  "position": "hook.when",
  "expression": "event.inputz.query != ''",
  "definition": { "key": "grafana-reads", "on": "tool.used", "steps": [{ "name": "notify", "call": "grafana.search" }] }
}

The response:

FieldTypeDescription
typestring or nullThe CEL type the expression returns, or null when it does not check.
errorsarrayEach has message, span (start, end, or null) and suggestion (or null).
warningsarrayEach has position and message.

422 when the request is not shaped as a check, when the position names neither an integration nor a hook attribute, when the definition has errors (each listed under definition), or when the position contains no expression in the definition.

Positions API

GET /api/v1/expressions/positions

Returns every position, integration and hook, as a list. It needs any credential.

FieldTypeDescription
positionstringThe position, beginning with integration or hook, with [*] for any key or index, as in integration.webhook.events[*].when.
returnsstring or nullbool, list, or null.
variablesarrayThe variables the expression can read, each with name, type and nested fields.
addedVariablesarrayVariables that only some definitions add: item, captures, inputs.
callsarrayWhat can call an expression at the position, each with by (task, chat, inbox-request or notice for a binding of that kind of event, tool, lookup or schedule) and the variables that this caller has. Empty where the variables do not depend on what calls the expression.

On this page