Skip to main content

Payload Transforms

Transforms allow you to reshape the event payload before it is formatted and delivered. Transforms use JSONata expressions.

How Transforms Work

  1. An event is received and stored with its original payload
  2. During delivery, if the endpoint-destination link has a transform_id set, the associated JSONata expression is evaluated against the original payload
  3. The transformed result becomes the payload used for template rendering and delivery
  4. If the transform fails for any reason, the original payload is used (fail-open behavior)

To disable a transform on a link, remove the transform_id assignment. The original payload will pass through unchanged.

Configuring Transforms

Transforms are created and managed from the Transforms page in the dashboard, then assigned to endpoint-destination links by selecting them from the link editor. Each link can reference a different transform, allowing different destinations to receive different views of the same event. See Dashboard: Transforms for details.

JSONata Examples

Extract specific fields

{
"action": action,
"repo": repository.full_name,
"sender": sender.login,
"url": pull_request.html_url
}

Flatten nested structures

{
"commit_count": $count(commits),
"branch": $substringAfter(ref, "refs/heads/"),
"pusher": pusher.name,
"messages": commits.message
}

Conditional values

{
"status": action = "opened" ? "New" : action = "closed" ? "Done" : "Updated",
"priority": $exists(labels[name = "critical"]) ? "high" : "normal"
}

Array operations

{
"files_changed": $count(commits.($count(added) + $count(modified) + $count(removed))),
"authors": $distinct(commits.author.name),
"latest_message": commits[-1].message
}

Fail-Open Behavior

Transforms are designed to be safe:

  • If the JSONata expression has a syntax error, the original payload is used
  • If the expression produces null or undefined, the original payload is used
  • If the expression throws a runtime error, the original payload is used
  • Transform errors are logged but do not block delivery

This ensures that a misconfigured transform does not prevent events from being delivered.

Transform vs. Template

FeatureTransformTemplate
LanguageJSONataTemplate expressions
PurposeReshape payload structureFormat message for delivery
InputRaw event payloadTransformed payload (or original)
OutputNew JSON objectDiscord embed / Slack Block Kit / Telegram HTML
TimingBefore formattingAfter transform

Transforms and templates work together: the transform reshapes the data, then the template formats it for display.