> For the complete documentation index, see [llms.txt](https://docs.welkinhealth.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.welkinhealth.com/designer/documents-and-assessments/filtering-with-message-template-variables.md).

# Filtering with Message Template Variables

## Overview

Message template variables in Welkin can be filtered and formatted to control how dynamic data appears in your communication templates. This is useful when you want to display a date in a specific format, truncate long text, or conditionally show values.

## What is Variable Filtering?

When you insert a variable like `{{patient.date_of_birth}}` into a message template, you can apply a filter to transform the output. Filters are appended to the variable using a pipe character (`|`).

**Syntax:**

```
{{variable_name | filter_name}}
```

## Common Filters

### Date Formatting

Format dates to display in a specific way:

```
{{patient.date_of_birth | date: "MM/DD/YYYY"}}
```

Supported formats: `MM/DD/YYYY`, `YYYY-MM-DD`, `Month DD, YYYY`

### Uppercase / Lowercase

```
{{patient.first_name | upcase}}
{{patient.last_name | downcase}}
```

### Default Value

Display a fallback when the variable is empty:

```
{{patient.phone | default: "No phone on file"}}
```

### Truncate

Limit the number of characters displayed:

```
{{patient.notes | truncate: 100}}
```

## Combining Filters

Multiple filters can be chained together:

```
{{patient.first_name | upcase | default: "Patient"}}
```

## Configuration

Variable filtering is configured directly in the message template editor in Designer. When adding a variable, use the filter syntax in the template body. Test templates using the preview functionality before publishing.

For basic variable usage, see [Filtering Message Template Variables](/designer/documents-and-assessments/filtering-message-template-variables.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.welkinhealth.com/designer/documents-and-assessments/filtering-with-message-template-variables.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
