<!-- BusyBot node reference — https://busybot.net/tools/prompt-template/ -->

> Node: Prompt Template (`prompt_template`) · Action · v1
> Category: AI · Credentials: none
> Updated: 2026-08-16

# Prompt Template

> Build prompts from templates with variable substitution using {{variable}} syntax.

## Overview

Constructs prompt strings by substituting {{variable}} placeholders in a template with values from a provided variables object or from input item fields. Pure string manipulation — no API calls. Supports strict mode that throws on unresolved variables. Each input item produces one rendered prompt stored in a configurable output field (default: "prompt") along with a list of any unresolved variable names.

**Category:** AI  
**Tool Name:** `prompt_template`  
**Version:** 1

**Appearance:** Icon: `brain` | Color: `#6366f1`

## Node Type

**Action** — processes input items and produces output

## Input / Output

| Direction | Port(s) |
|-----------|--------|
| Input | `Input` |
| Output | `Output`, `Error` |

## Credentials

This tool does not require any credentials.

### Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| Template | `string` | Yes | — | Template string with {{variable}} placeholders. Falls back to item.template if empty. Supports expressions. |
| Variables | `string` | No | — | JSON object of variable name/value pairs. Falls back to item.variables. Any unresolved variables also fall back to matching item fields. Supports expressions. |
| Options | `collection` | No | `{}` | Optional output and validation settings. |
| — Response Field Name | `string` | No | `prompt` | The output field name where the rendered prompt will be stored. |
| — Strict Mode | `boolean` | No | `false` | If true, throw an error when any {{variable}} placeholder cannot be resolved. If false, unresolved placeholders are left as-is. |
| Include Input | `boolean` | No | `false` | Whether to include the original input item fields in the output alongside the rendered prompt. |
| Max Concurrency | `number` | No | `50` | Maximum number of items to process concurrently. Higher values are safe since this is pure string manipulation. |

## Output Data

One output item per input item. The rendered text is written to the field named by Response Field Name (`prompt` by default), alongside `unresolvedVars`. With Include Input off — the default — those two fields are the entire output item; turn it on to merge the original item fields underneath. Binary data is forwarded either way.

```json
{
  "prompt": "Hi Maria, welcome to Acme CRM!",
  "unresolvedVars": []
}
```

- `unresolvedVars` lists the placeholder names still present in the rendered text — the ones that matched neither the Variables object nor a field on the input item. It is an empty array when everything resolved.
- With Strict Mode on, an unresolved placeholder becomes an item error instead, so `unresolvedVars` on a successful item is always empty.

Reference the result downstream by expression, e.g. `{{ $json.prompt }}`.

## Usage Examples

- Build a system prompt with dynamic context variables
- Render a user message template with item-specific values
- Create batch prompts from a template and variable items
- Compose multi-section prompts with topic and content placeholders
- Validate templates in strict mode to catch missing variables

## Example Configuration

Minimal configuration — render a simple greeting using variables passed inline:

```json
{
  "name": "Build Greeting",
  "type": "prompt_template",
  "parameters": {
    "template": "Hi {{firstName}}, welcome to {{serviceName}}!",
    "variables": "{\"firstName\": \"Maria\", \"serviceName\": \"Acme CRM\"}",
    "includeInput": false,
    "maxConcurrency": 50
  }
}
```

Pass-through with input fields — include the original item fields in the output and resolve variables from the item itself, with no explicit `variables` object:

```json
{
  "name": "Enrich With Prompt",
  "type": "prompt_template",
  "parameters": {
    "template": "Summarize the following ticket (#{{ticketId}}): {{description}}",
    "variables": "",
    "includeInput": true,
    "maxConcurrency": 50,
    "options": {
      "responseFieldName": "prompt"
    }
  }
}
```

Strict mode with a custom output field — generate an LLM system prompt, store it in `systemPrompt`, and fail if any placeholder is unresolved:

```json
{
  "name": "Build System Prompt",
  "type": "prompt_template",
  "parameters": {
    "template": "You are a {{role}} assistant working for {{company}}. Always respond in {{language}}.",
    "variables": "{\"role\": \"support\", \"company\": \"Acme Inc\", \"language\": \"English\"}",
    "includeInput": false,
    "maxConcurrency": 20,
    "options": {
      "responseFieldName": "systemPrompt",
      "strictMode": true
    }
  }
}
```

Dynamic prompts from upstream data — when input items already carry the variable values as fields, omit `variables` entirely and each `{{field}}` placeholder resolves directly from the item:

```json
{
  "name": "Prompt From Item Fields",
  "type": "prompt_template",
  "parameters": {
    "template": "Write a product description for {{productName}} priced at {{price}}.",
    "variables": "",
    "includeInput": true,
    "maxConcurrency": 50,
    "options": {
      "responseFieldName": "productPrompt"
    }
  }
}
```

High-volume batch processing — for large batches of items, raise `maxConcurrency` since no external I/O is involved:

```json
{
  "name": "Batch Email Subjects",
  "type": "prompt_template",
  "parameters": {
    "template": "Re: {{subject}} — reply needed by {{dueDate}}",
    "variables": "",
    "includeInput": false,
    "maxConcurrency": 200,
    "options": {
      "responseFieldName": "emailSubject",
      "strictMode": false
    }
  }
}
```

Strict pipeline with controlled variables — in validated pipelines where missing data must halt execution, combine explicit `variables` with `strictMode: true`. Here `inputText` is not in `variables`, so it is resolved from the input item field `inputText`; if no such field exists the node raises an error:

```json
{
  "name": "Validated Prompt Builder",
  "type": "prompt_template",
  "parameters": {
    "template": "Translate the following text to {{targetLanguage}}: {{inputText}}",
    "variables": "{\"targetLanguage\": \"French\"}",
    "includeInput": false,
    "maxConcurrency": 50,
    "options": {
      "responseFieldName": "translationPrompt",
      "strictMode": true
    }
  }
}
```

### Error Handling

| Mode | Behavior |
|------|----------|
| **stop** | Halts workflow on first error |
| **continue** | Skips failed items, passes successful ones through |
| **errorPort** | Routes failed items to Error output port |

## Tips

The Prompt Template tool substitutes {{variable}} placeholders in a template string with values from a variables object or input item fields, with no external API calls. Use it to dynamically build LLM prompts or structured text that must vary per item before reaching a downstream API or processing node. Each item outputs a rendered prompt in a configurable field (default: prompt) and a list of any placeholder names that could not be resolved.

### Key Rules Summary

| Rule | Detail |
|---|---|
| `options` fields go **inside** `options` | Never place `responseFieldName` or `strictMode` at the top level of `parameters` |
| `variables` is a **JSON string** | Serialize the object: `"{\"key\": \"value\"}"` |
| Unresolved placeholders fall back to item fields | Explicit `variables` → `item.variables` → item fields |
| `strictMode: false` (default) leaves unresolved `{{vars}}` as-is | Set `true` to error instead |
| `includeInput: true` merges input fields into output | Useful when downstream nodes need both the prompt and original data |

### Placeholder syntax

- A placeholder is matched as `{{name}}` where the name is letters, digits and underscores only. Write `{{topic}}`, not `{{ topic }}` — a placeholder with spaces or dots inside the braces is never substituted, and never appears in `unresolvedVars` either.
- Values from the Variables object win over fields of the same name on the input item, so an explicit variable always overrides upstream data.