> ## Documentation Index
> Fetch the complete documentation index at: https://docs.struct.to/llms.txt
> Use this file to discover all available pages before exploring further.

# Template Syntax

> Write dynamic templates using Handlebars syntax with built-in formatters and helpers.

Automations use [Handlebars](https://handlebarsjs.com/) syntax for templating. This applies to user prompt templates in both AI and Direct processing modes, and to all text fields in Discord and Telegram output configurations.

## Basics

Event data is available under the `event` object. Access fields with double curly braces:

```
Market: {{event.market_name}}
Trader: {{event.trader_address}}
Price: {{event.price}}
```

## Conditionals

```
{{#if event.market_name}}
Market: {{event.market_name}}
{{else}}
No market data available
{{/if}}

{{#unless event.error}}
Trade successful
{{/unless}}
```

## Loops

```
{{#each event.positions}}
- {{this.market_name}}: {{this.side}} at {{this.price}}
{{/each}}
```

## Logical Operators

Combine conditions using `and`, `or`, and comparison helpers as sub-expressions:

```
{{#if (and (gt event.size_usd 50000) (eq event.side "Buy"))}}
Large buy detected
{{/if}}

{{#if (or (eq event.side "Buy") (eq event.side "Sell"))}}
Trade event
{{/if}}
```

## Formatters

Built-in helpers format event data for readability.

| Helper | Usage | Output |
| - | - | - |
| `formatNumber` | `{{formatNumber event.volume}}` | `2,450,000` |
| `formatCurrency` | `{{formatCurrency event.size_usd}}` | `$15,420.50` |
| `formatPercent` | `{{formatPercent event.current_probability}}` | `72%` |
| `formatDate` | `{{formatDate event.block_timestamp}}` | `Jun 15, 2025` |
| `uppercase` | `{{uppercase event.side}}` | `BUY` |
| `lowercase` | `{{lowercase event.side}}` | `buy` |
| `truncate` | `{{truncate event.description 100}}` | First 100 chars + `...` |
| `default` | `{{default event.category "N/A"}}` | Fallback when value is empty |
| `math` | `{{math event.price "*" 100}}` | Basic arithmetic (`+`, `-`, `*`, `/`) |
| `json` | `{{json event}}` | Pretty-printed JSON |

### Formatter Options

Some formatters accept named options:

```
{{formatNumber event.volume decimals=2}}        → 2,450,000.00
{{formatCurrency event.size_usd currency="EUR"}} → €15,420.50
{{formatDate event.timestamp format="long"}}     → June 15, 2025
```

## Comparison Helpers

Use these as sub-expressions inside `{{#if}}` blocks:

| Helper | Description |
| - | - |
| `eq` | Equal (`===`) |
| `ne` | Not equal (`!==`) |
| `gt` | Greater than |
| `gte` | Greater than or equal |
| `lt` | Less than |
| `lte` | Less than or equal |

```
{{#if (gt event.size_usd 100000)}}
Whale trade: {{formatCurrency event.size_usd}}
{{/if}}
```

## Event Fields

Each webhook event type exposes different fields. You can browse the available fields for any event type from the automation editor in the dashboard. Click **View Event Fields** when configuring your template.

See [Webhook Events](/webhooks/getting-started#available-events) for the full list of supported event types.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.