# 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
