---
title: "Message Formatter"
icon: "align-left"
---

## Message Formatter


The Message Formatter step generates a plain text string using a Handlebars-like template, transforming structured data into a human-readable message.

### When to Use

*   Format HTTP responses into chat-ready or user-friendly text.
*   Create concise summaries without needing an LLM.
*   Build consistent and deterministic responses for end-users.

### Configuration

*   **Template**: A multiline text field where you define your message using Handlebars expressions (e.g., `{{ ... }}`).

    > 💡 Note: This template engine is based on Scriban, a powerful scripting language. You can leverage many of Scriban's advanced features like piping and various syntax constructs to manipulate data within your template.

### Input

The Message Formatter uses upstream data, referencing values via `Inputs...` or `Steps...`. This includes branch output if the formatter is placed within an **If** step.

**Example Input:**

```json
[
  {
    "$type": "sdkStep",
    "Output": { 
      "Body": [ 
        { "name": "Google Pixel 6 Pro", "data": { "color": "Cloudy White" } } 
      ] 
    }
  }
]
```

#### Syntax

The message formatter's templating engine is based on [Scriban](https://github.com/scriban/scriban). This allows for powerful data manipulation beyond simple variable insertion.

For example, to parse a JSON string from a step's output and then access a field:

```liquid
UserInput: {{ (Steps.CreateJSON.Output | object.from_json).UserInput }}
```

In this example, `Steps.CreateJSON.Output` is treated as a string, then piped through the `object.from_json` filter to cast it into an object, and finally, the `UserInput` field is accessed.

### Output Schema

The step outputs a single rendered string.

```json
{
  "$type": "sdkStep",
  "Output": "a rendered string",
  "Success": true
}
```

*   **`Output`**: The generated plain text string after the template has been processed with the provided data.
*   **`Success`**: A boolean indicating if the message was successfully formatted.

### Example: "First Product" Message

This example demonstrates how to format details about a product fetched from a previous `HTTP_Request` step into a user-friendly message.

**Template:**

```handlebars
Great, here’s the first product I found:
Name: {{ Steps.HTTP_Request.Output.Body[0].name }}
Color: {{ Steps.HTTP_Request.Output.Body[0].data.color }}
Capacity: {{ Steps.HTTP_Request.Output.Body[0].data.capacity }}
{{Helpers.CurrentDateTime}}
```

**Example Output:**

```json
{
  "$type": "sdkStep",
  "Output": "Great, here’s the first product I found:\n\nName: Google Pixel 6 Pro\nColor: Cloudy White\n\n2025-12-15T13:17:19.424Z",
  "Success": true
}
```
