Rich Message Templates
Configure one message template for each destination.
A message template is text that uses values from the incoming request. PayloadRelay can use a template to create a message for Slack, Discord, Microsoft Teams, or Telegram. You configure the template for each destination. So one incoming webhook can create a different message for each channel.
Enabling a template#
- Open the endpoint. Select the
Outputstab and expand the destination to change. - Open the
Message templatecard. Turn onUse custom message template. - Enter a
Title, aBody, or both. At least one field must contain text. - Optional: Select a
Colorfor a Slack attachment, a Discord embed, or the Microsoft Teams theme. Telegram does not support a color theme. - Optional: Turn on
Include "View in PayloadRelay" linkto add a link to the endpoint activity log. - Save the endpoint. The live preview updates while you type.
The live preview needs a saved destination. For a new destination, save the endpoint first. The preview
uses the current values of Enable Markdown formatting for Slack, and of Send as text-to-speech (TTS)
and Truncate long messages for Discord. It uses them also before you save them.
To remove the title or the color, clear the field and save the endpoint.
Placeholder syntax#
{{ body.path.to.value }} JSON dot-path into the request body
{{ headers.X-Event }} case-insensitive header lookup
{{ query.token }} query parameter value
{{ body }} entire JSON body as textA missing value in a permitted namespace becomes an empty string. PayloadRelay rejects an unknown namespace and an unknown helper when you save the template.
A failover destination also fills in {{ query.* }} from the original request.
Helpers#
Use one of these helpers after the pipe to format a value:
| Helper | Effect |
|---|---|
default('n/a') | Use the literal value when the value is null or blank. |
upper / lower | Change the case. |
iso_date | Parse epoch seconds, epoch milliseconds, or an ISO‑8601 input, and write ISO‑8601 UTC. |
truncate(n) | Cut the value to n characters, and add …. The maximum is 8000. |
strip_html | Remove the HTML tags. |
Examples:
{{ body.event | upper }}
{{ body.timestamp | iso_date }}
{{ body.message | truncate(140) }}
{{ body.user.name | default('anonymous') }}Channel-specific behavior#
- Slack: PayloadRelay sends a Slack message with a top-level
textfallback and a Block Kitattachments[].blockspayload. The payload contains aheaderblock for the title, onesectionblock or more withmrkdwnfor the body, and an optional link section. PayloadRelay divides a long body to stay in the Slack section text limits. The body supports Slack mrkdwn such as*bold*,_italic_, and<url|text>. With Markdown on, PayloadRelay escapes&,<, and>in each value that a placeholder inserts. A mention such as<!channel>works only in the literal text of the template. The title header block is plain text. - Discord: PayloadRelay sends an embed with
title,description, an optionalurl, and aView in PayloadRelayfield. It converts#RRGGBBinto the decimal color value that Discord needs. Discord limits an embed description to 4000 characters. PayloadRelay cuts a body that is longer than 4000 characters, for the Discord delivery and the preview. PayloadRelay cuts a title that is longer than 256 characters.Send as text-to-speech (TTS)applies to a template message.Truncate long messagesdoes not apply, because PayloadRelay always cuts the title and the body. The message setsallowed_mentionsto{"parse": []}, so it mentions nobody. - Microsoft Teams: PayloadRelay sends a
MessageCardwiththemeColor,title,text, and an optionalOpenUriaction. A legacy Incoming Webhook connector shows the link action as a button. Teams Workflows can ignore the button when it posts the card. - Telegram: PayloadRelay sends
parse_mode: "HTML"with<b>title</b>, the escaped body, and an optional<a>link. Telegram limits the message to 4096 characters.
Limits and validation#
- Title: 512 characters.
- Body: 8000 characters in the message after the template processing. The
truncate(n)helper has the same 8000-character limit. - You can save a Discord template body to the general 8000-character limit. The Discord embed description has a limit of 4000 characters.
- Color: the value must match
#RRGGBB. - PayloadRelay accepts the
body.,headers., andquery.namespaces only. You cannot save a template that uses a different namespace, such as{{ secrets.token }}. - You cannot save a template that uses an unknown helper.
A cut never divides a character that uses two UTF-16 code units, for example most emoji. A cut
also never divides an escaped entity such as &.
Falling back to the default behavior#
To use the default behavior, disable the template control. The default Slack
message puts the incoming payload in the Slack text field. A destination with
no configured template continues to give the same result.
If the title and the body of a template both become empty after the processing, PayloadRelay
sends the default message. For Discord, Send as text-to-speech (TTS) and Truncate long messages
both apply to the default message. The default Discord message mentions nobody. An incoming payload in the Discord
message shape keeps its own allowed_mentions.