← Back to documentation

Rich Message Templates

Configure one message template for each destination.

4 min read

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#

  1. Open the endpoint. Select the Outputs tab and expand the destination to change.
  2. Open the Message template card. Turn on Use custom message template.
  3. Enter a Title, a Body, or both. At least one field must contain text.
  4. Optional: Select a Color for a Slack attachment, a Discord embed, or the Microsoft Teams theme. Telegram does not support a color theme.
  5. Optional: Turn on Include "View in PayloadRelay" link to add a link to the endpoint activity log.
  6. 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#

Code Example
{{ 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 text

A 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:

HelperEffect
default('n/a')Use the literal value when the value is null or blank.
upper / lowerChange the case.
iso_dateParse 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_htmlRemove the HTML tags.

Examples:

Code Example
{{ 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 text fallback and a Block Kit attachments[].blocks payload. The payload contains a header block for the title, one section block or more with mrkdwn for 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 optional url, and a View in PayloadRelay field. It converts #RRGGBB into 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 messages does not apply, because PayloadRelay always cuts the title and the body. The message sets allowed_mentions to {"parse": []}, so it mentions nobody.
  • Microsoft Teams: PayloadRelay sends a MessageCard with themeColor, title, text, and an optional OpenUri action. 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., and query. 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 &amp;.

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.