Prompt templates
A prompt template keeps instructions, a template body with placeholders, its variables, the expected output fields and examples in one record. The ai.prompt node fills it with workflow data.
A prompt template takes the prompt out of the workflow. Whoever tunes the wording edits the template; the workflow keeps pointing to the same record and picks up the change on its next run.
What a template holds
| Field | What it is |
|---|---|
slug, name, description | Stable key and labels. |
organization_id | Owner organization. |
llm_provider_id | The LLM provider the template is written for. |
language, format | Language of the prompt and format of the expected answer. |
system_instructions | The system part of the prompt. |
template_body | The prompt text, with placeholders such as {{ customer_name }}. |
variables | The placeholders the body expects. |
output_fields | The fields the answer should contain. |
style_guidelines | A list of style rules. |
examples | Worked examples of input and expected output. |
tags, is_system | Labels, and whether the template is a system template. |
Statuses: enabled, review, deprecated and archived.
Variables
Each entry of variables describes one placeholder:
{
"name": "customer_name",
"type": "string",
"description": "Name used in the greeting",
"required": true,
"default_value": "customer",
"allowed_values": []
}Output fields and examples
An output field has name, type, description and required. An example has inputs, expected_output and
notes. They document the contract of the template for whoever writes or reviews it.
Fill a template in a workflow
The ai.prompt node reads a template and returns the finished prompt.
- Set
template_idto the id of the template. - Pass
variables, an object whose keys match the placeholders. - The node replaces every
{{ key }}oftemplate_body(spaces inside the braces are allowed) with its value.
With this template body:
and this node configuration:
{
"template_id": "<prompt-template-id>",
"variables": {
"customer_name": "{{ $json.sender.name }}",
"language": "Spanish"
}
}the node returns:
{
"prompt": "Summarize the request from Ana Ruiz in Spanish, in three bullet points.",
"config": {
"provider": "<llm-provider-slug>",
"model": "<deployment-name>",
"language": "<template-language>",
"format": "<template-format>"
}
}config.provider and config.model come from the template’s LLM provider (its slug, and its deployment_name or
default_parameters.model); config.language and config.format come from the template. The next node reads the prompt with {{ $json.prompt }}.
Manage templates
In the portal, go to Advanced → Cognitive Infrastructure → Prompt Template. Through the API, use
/cognitive-infrastructure/cognitive-assets/prompt-template/ (see the
API reference).