Skip to main content

Template Editor

The template editor lets you create and customize message templates with a visual editor and live previews for each supported platform.

Creating a Template​

Templates are optional. GitHub, Stripe, Sentry and more are formatted automatically, so you only need a template when you want to customize how a message looks.

  1. Navigate to Templates → New Template
  2. Enter a name
  3. Choose a starting point:
    • Start from a recent event (the default)
    • Blank
  4. Click Create & Edit

Start from a recent event is the default when your project received events in the last 30 days. The newest usable event's payload becomes the sample, so the preview and field suggestions match what you actually receive. Click Choose a different event to pick another one. Blank starts with a generic example payload you can replace.

When the event's payload has a common display field such as action, type, status, name or title (never one that looks like a token, secret or password), the editor opens with a starter description that already uses it, such as action: {{.Payload.action}}, so you can see a working template straight away; otherwise the description starts as plain text. Starting from an event also adds a "Created from event" link back to it at the top of the editor.

An event can be used as a sample only if its payload is a JSON object no larger than 256 KB. Other events are skipped when the default is chosen, and picking one yourself asks you to choose a different event. If your project has no recent events, or none of them can be used, the dialog says so and starts blank — you can load a real event or paste a payload later from the editor.

Editor Layout​

The template editor has two main panels:

  • Left: Platform Tabs + Config Editor — switch between platform tabs (Discord, Slack, Telegram, Google Chat, Webex, Default) and edit the JSON config for each with syntax highlighting
  • Right: Live Preview — see a rendered preview for the active platform tab as you type. Advanced template expressions (such as index, range over array elements, {{with}}, and .Meta fields) render in the preview just as they will at delivery, with the few exceptions listed below. If a template expression is invalid, the preview shows the template error instead of silently leaving the raw {{…}} text — fix the expression and the error clears. The preview stays in view as you scroll the editor.

Embed field values can span multiple lines — press Enter inside the value editor to add a line break (for example, one bullet per item when looping over an array). Field names stay single-line.

Typing {{ adds the closing }} for you, and typing }} yourself steps over them. Escape closes suggestions without clearing the field. The same applies in the Description field.

Under the Description field, a help line reminds you of the syntax: Go template syntax: {{.Payload.field}}. JavaScript (${…}, =>) won't run here. Click Open the syntax reference to jump to the Reference tab.

The Sample Payload box is what the preview renders with. When it still holds the built-in example, a label says so — Example payload (GitHub push). Paste one of yours or pick a recent event. — so you know to swap in real data.

The Sample row under the preview shows what the preview is using (for example Sample: push) and stays collapsed to save space; select Edit sample to change it or pick a recent event. When a template has no saved sample, the editor starts with your newest real event, and falls back to the built-in example only if you have none. Previews show that event's real type, ID and time wherever a template uses them, including advanced expressions.

Editing the Default version​

The selector above the editor is labelled Editing, and each platform reads own version or uses Default. A line under it tells you which platforms currently use the Default version. On the Default tab, Preview as lets you see how Default looks on a specific platform, without changing anything saved. Copy from Default on a platform tab asks before replacing a version that already has content, and nothing is saved until you click Save.

Where a template is used​

Next to the template's name, a chip tells you whether it is in use. Not in use comes with an Attach button; Used by N routes opens a list of the routes using it, each marked as the default, as set by a rule, or paused, and each opens its routing page. The Templates list shows the same count on every template. A route counts once however many ways it uses the template; routes to webhook destinations and archived sources or destinations aren't counted. After you save a template that isn't used yet, a short notice offers Attach so it doesn't stay unused by accident.

JavaScript warnings​

Template fields read Go template syntax, not JavaScript, so anything outside {{ }} is sent as plain text. If you type JavaScript, the field shows a warning with a plain-language explanation and, when there is a safe rewrite, a one-click button:

  • Use {{.Payload.repository.name}} (the button names the exact replacement) — for example, e => e.repository.name becomes {{.Payload.repository.name}}
  • Convert to template syntax — shown when the fix is a longer rewrite
  • Generate with AI from this — shown when there is no safe one-click rewrite, such as a comparison, a ternary or a chained .filter().map(); the warning still names the template form to use. It opens Generate with AI with your code already in the description, introduced by "Turn this JavaScript into a template:". This button appears on the message fields of the Default tab (not the thumbnail URL), which is the tab AI generation writes to.

The checker recognizes arrow functions and function expressions, ${…} and backtick strings, ? :, [0], +, .map() and similar method calls, || and ??, ?., === and &&, and {{#if}}-style blocks, and it flags fields written without .Payload. When a field has more than one problem, the warning shows the first and notes "(+N more)". In multi-line fields, the exact text is also underlined with a wavy line. Valid template text, including Discord markdown, Slack <url|text> links and Telegram HTML, is left alone. It also warns when a field isn't in any of your real samples, because it would show as <no value> in your messages. If a close match exists, the warning offers a Did you mean button; one-click fixes appear only for fields your samples contain. Inside a {{range}} or {{with}} block, it suggests using $.Payload to reach the whole event. These field checks use your own samples, so they stay quiet while the editor holds only the built-in example.

The warning is advice, not a block: you can still save, and the text is delivered as written. If the live preview hits a common template error, it explains in plain language what to change — for example, Fields live under .Payload — try {{.Payload.repository.name}}. Select Show the original error to see the underlying error. Other errors are shown as reported.

What the preview can render

Advanced template expressions run on Dispatch's servers, so the preview supports a defined subset of the template language and tells you plainly when a template falls outside it. Field access, {{if}}, {{range}}, {{with}}, pipelines, index, slice, len, printf, urlquery, the comparison functions and every platform helper are all supported.

Simple field substitutions render instantly in your browser without a server round-trip. In rare cases their preview can differ slightly from the delivered message — very large numbers, len, json key ordering, short truncate widths, and .Payload.* fields referenced inside a {{range}} or {{with}} block (those preview as the payload value but deliver as <no value> or a template error — use the loop item's own fields instead) — while delivery always uses the real engine.

These are not, and show a "not supported in preview" message — they still work when the message is delivered:

  • Variables declared outside a {{range}} or {{with}} header ({{$x := …}}), and assignment ({{$x = …}}) — naming the subject, as in {{with $pr := .Payload.pull_request}}, is supported
  • print, println, html, js, call — use printf
  • printf argument indexes (%[1]s) and * widths — ordinary verbs and widths are fine
  • define, template, block
  • Looping over a computed value ({{range len .Payload.x}}), or more than two nested loops
Large numbers

JSON numbers are floating point, so {{.Payload.amount}} renders a large value as 1.5e+06. Use {{fixed 0 .Payload.id}} for a whole number and {{fixed 2 .Payload.total}} for a money amount. Stripe, PayPal and Shopify send amounts in cents, so divide first: {{fixed 2 (div 100 .Payload.amount)}} renders 1200 as 12.00. This affects delivered messages too, so it is worth checking any existing template that renders an ID, timestamp, or amount.

Very large sample payloads

So the preview stays responsive, it trims arrays and objects longer than 100 entries and leaves out anything nested deeper than 32 levels, telling you when it has. Delivery always uses your full payload. To preview the entire payload as JSON, use {{json .Payload}} — that renders identically in the preview and at delivery.

Platform Tabs​

Each tab represents a platform variant within a v2 multi-platform template:

TabFormatDescription
DiscordEmbed configStandard Discord embed with title, description, fields, color
SlackBlock Kit JSONNative Slack Block Kit blocks for rich Slack messages
TelegramHTML templateHTML string for Telegram's HTML parse mode
Google ChatText templateGoogle Chat formatted text (*bold*, _italic_, `code`)
WebexMarkdown templateWebex markdown (**bold**, *italic*, `code`, [text](url))
DefaultEmbed configFallback used when no platform-specific variant is configured

At delivery time, Dispatch selects the variant matching the destination type. If no matching variant is set for that platform, the Default variant is used. The line under the editor's selector lists exactly which platforms use Default.

tip

You don't need to configure all platforms. Configure only the tabs you need — leave the rest empty and Dispatch will fall back to auto-formatting or the Default tab.

Sample Sets​

Alongside the sample payload you are editing — the active sample, the one the live preview renders with — Dispatch stores a set of up to 10 sample events.

  • Save current payload as sample adds whatever is in the editor to the set.
  • Add from recent events opens a picker of the events your project received in the last 30 days, newest first — each labelled by its event type, or a short id when the source doesn't set one, with events your filters blocked marked filtered. A filter box above the list narrows it as you type; press ↓ to move from the box into the list, then move with the arrow keys (Home and End jump to the ends), press Space to select one or several, and Enter to add them — with nothing selected, Enter adds the highlighted event. Events already in the set are shown as Added.
  • Each stored sample can be loaded back into the editor as the active sample, or removed from the set.

Adding or removing a sample is an unsaved change — it takes effect when you save.

Creating a template from an event starts the set off with that event, unless the event is unusually large — in which case the template is still created, just without the first sample. A multi-row selection from the events table seeds one sample per selected event, up to the 10-sample cap — see Create from several events at once.

Storing several samples is worth doing when one source sends different event shapes — an opened pull request carries fields a closed one does not. AI generation reads the samples in the set on top of the payload in the editor, so the template it writes holds up across all of them.

Generating with AI​

The labeled Generate with AI button in the editor header (or Generate with AI from this under a JavaScript warning, which opens the same dialog with your snippet already in the description) drafts a template from a plain-language description (for example, "Dependabot alert: severity, package, CVE link, red accent"). It grounds every {{.Payload.…}} reference in your samples — the payload in the editor and every sample in the set — so a field that only some of your events carry is kept rather than corrected away. A path found in none of them is auto-corrected when there is an obvious match, and flagged with a warning in the review dialog when there isn't, so you can fix it rather than discover a blank field later. The dialog names what it will read — the payload in the editor, however many samples your set holds, or neither — and trims a very large set to fit the request by dropping whole samples from the end. With the sample box cleared and no stored samples, it tells you generation has nothing but your description to work from. Generated values apply to the Default platform tab.

Inside the dialog, Ctrl+Enter (⌘Enter on macOS) generates and Esc closes it.

Discord Tab​

The Discord tab uses the standard embed config format:

{
"title": "{{.Meta.EventType}}",
"description": "Event from {{.Payload.repository.full_name}}",
"color": 5763719,
"fields": [
{
"name": "Action",
"value": "{{.Payload.action}}",
"inline": true
}
],
"footer": "Dispatch",
"thumbnail": "{{.Payload.sender.avatar_url}}",
"timestamp": true
}

The live preview renders a Discord embed the way Discord destinations will receive it (see the preview note above for the few browser-side approximations).

Slack Tab​

The Slack tab accepts a slack_blocks array containing native Block Kit blocks. All string values inside the blocks support template expressions:

{
"slack_blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "{{upper .Meta.EventType}}"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Repository*\n{{.Payload.repository.full_name}}"
},
{
"type": "mrkdwn",
"text": "*Action*\n`{{.Payload.action}}`"
}
]
}
]
}

Telegram Tab​

The Telegram tab accepts a telegram_html string that supports template expressions and is sent with Telegram's HTML parse mode:

{
"telegram_html": "<b>{{upper .Meta.EventType}}</b>\n\nRepo: <code>{{.Payload.repository.full_name}}</code>\nAction: <code>{{.Payload.action}}</code>\n\nBy <b>{{.Payload.sender.login}}</b>"
}

Supported HTML tags: <b>, <i>, <u>, <s>, <code>, <pre>, <a href="...">, <tg-spoiler>.

Variable Discovery​

The editor helps you discover available template variables:

  • A Variables panel shows all available .Meta variables (event type, event ID, endpoint ID, timestamp)
  • If recent events exist for linked endpoints, the editor shows actual payload paths from real event data
  • Click a variable, a template function or a Discord ANSI color and it is inserted at the cursor of the template field you last used. Inside a {{range}} or {{with}} block it is inserted with $ (for example {{$.Payload.repository.name}}) so it still reads the whole event. If you haven't used a field yet, it is copied to your clipboard instead — click into a field and paste Function and color examples are filled in with real fields from your active sample, so what you insert works with your data; with only the built-in example they stay generic.

The Reference tab holds syntax examples and a Coming from JavaScript table, each with a copy button. See Coming from JavaScript for the full table. Open the syntax reference takes you straight to it.

This panel is available across all platform tabs.

Assigning Templates​

Templates are assigned per route (a source connected to a destination), in either direction:

  • From the source: go to Sources and open the routing page for the route; the template is one of the route's defaults.
  • From the template editor: click Attach in the editor header, or in the usage chip next to the template's name. The dialog lists every route in your project (arrow-key navigable) with what each currently uses, shows how many routes already use it (as a default or through a rule), warns you when attaching would replace another template, and stays open so you can wire several routes in one visit. Routes to webhook destinations appear but can't be chosen — they always receive the raw payload, so templates don't apply to them. Attaching uses the last saved version of the template — save your edits first. Prefer a narrower rollout? Scope with a rule… opens the chosen route's routing editor with a draft rule already carrying this template, so it applies only to events the rule matches — the route's defaults stay as they are, and nothing takes effect until you save the rule.

A template assigned either way is the route's default; routing rules on the route can still override it for specific events. See Templates for details.

Keyboard Shortcuts​

Ctrl+S (⌘S on macOS) saves the template you are editing, and Ctrl+Alt+P (⌘⌥P) opens AI generation. Both are shown in the tooltip of the button they trigger.

Ctrl+K (⌘K) opens the command palette, which lists both — plus everything else available on the page.

These are the default bindings — any shortcut can be rebound or unbound.