Templates (Handlebars)
Overview
Section titled “Overview”component-templates renders Handlebars text from the current flow payload and message envelope. It is a small, deterministic component for formatting replies, reports, prompts, labels, and notification text before routing to the next flow step.
Use it when a flow needs string rendering, not when it needs a full HTML/email templating system. The current component exposes one operation, text, and one config object, templates.
Flow Shape
Section titled “Flow Shape”Use the component through component.exec or through the dev flow generated by greentic-flow:
format_answer: component.exec: component: ai.greentic.component-templates operation: text input: config: templates: text: "Hello {{payload.name}}. Your order #{{payload.order_id}} is ready." routing: out msg: "{{msg}}" payload: "{{payload}}" routing: - out: trueThe component manifest defines this config:
| Field | Required | Default | Purpose |
|---|---|---|---|
templates.text | Yes | - | Handlebars template to render. |
templates.routing | No | out | Optional routing target returned with the component output. |
templates.output_path | No | text | Dot path where the rendered string is stored when wrapping output. |
templates.wrap | No | true | When true, return an object; when false, return the rendered string directly. |
Template Context
Section titled “Template Context”The runtime input gives the template two top-level objects:
| Object | Meaning |
|---|---|
payload | Incoming node payload. Use {{payload.name}}, {{payload.items}}, and similar paths. |
msg | Channel message envelope. Use this for message metadata such as tenant, session, channel, and provider values when present. |
{{payload}} is normalized to compact JSON for debugging. Use triple braces to avoid HTML escaping:
Debug payload: {{{payload}}}Supported Handlebars Syntax
Section titled “Supported Handlebars Syntax”Standard Handlebars variables and built-in control flow work:
{{payload.user.name}}
{{#if payload.active}} Active{{else}} Inactive{{/if}}
{{#each payload.items}} - {{this.name}} x {{this.quantity}}{{/each}}The current component does not register custom helpers such as uppercase, currency, formatDate, remote template loading, or partial files. If a workflow needs those, create a custom component with greentic-component wizard and add the helper behavior there.
Output Examples
Section titled “Output Examples”Default wrapped output:
{ "payload": { "text": "Hello Ada" }, "routing": "out"}Custom output path:
config: templates: text: "Hello {{payload.name}}" output_path: "reply.body"{ "payload": { "reply": { "body": "Hello Ada" } }, "routing": "out"}Raw string output:
config: templates: text: "Hello {{payload.name}}" wrap: false{ "payload": "Hello Ada", "routing": "out"}Create a Custom Template Component
Section titled “Create a Custom Template Component”Start from the wizard instead of copying this component by hand:
greentic-component wizard --schemagreentic-component wizard --answers component-template-answers.jsonFor a pack-owned component, use the top-level launcher:
gtc wizard --schemagtc wizard --answers pack-with-template-component.answers.jsonSet operation_names to the operations you need, for example render_text,render_email. Turn on advanced_setup when the component needs HTTP, state, secrets, events, messaging, filesystem access, or custom config fields. The wizard writes the manifest, WIT bindings, QA scaffolding, i18n keys, build/test wiring, and default operation metadata.