String Template
Build a string from a template and runtime data, e.g. a dynamic VLM prompt.
Build a string from a template with named placeholders that are filled in at runtime from workflow inputs and step outputs, enabling dynamic prompt construction for VLM blocks, message formatting for notification and sink blocks, and any other place where text must be assembled from workflow data.
How This Block Works
This block renders a template string by substituting named placeholders with runtime values. The block:
Receives a template string containing placeholders in curly braces, e.g.
"This facing contains one of the following products: {sku_list}. Answer with the product name or NONE."Receives input data as a dictionary of named variables, where values may be literal values, workflow inputs (
$inputs.*) or step outputs ($steps.*)Optionally applies data transformations using operations (the same operation system as the Property Definition and Expression blocks) to each variable before substitution - for example joining a list of values into a single string with
SequenceJoin, or extracting class names from detections withDetectionsPropertyExtractSubstitutes each
{variable_name}placeholder with the (transformed) value of the matching variable, converting non-string values to strings; standard Python format specifications are supported (e.g.{confidence:.2f})Returns the rendered string as output of kind
string, ready to connect into any block field accepting a string - for example thepromptfield of VLM blocks
Literal curly braces can be produced by doubling them ({{ renders as {, }} renders as }).
The block fails at runtime with a descriptive error when the template references a variable that is not defined in data, when positional placeholders ({} or {0}) are used, or when a placeholder uses attribute or index access ({var.attr}, {var[0]}) - use data operations to extract nested values instead. Failing loudly on template/data mismatches prevents silently malformed output (e.g. a prompt with a missing product list) from propagating downstream.
Common Use Cases
Constrained VLM prompts: Assemble prompts that embed runtime context (e.g. an expected product list from a planogram, a manifest, or a BOM) into an engineered prompt template, so users provide only the data while the tested prompt wording stays inside the workflow, enabling expectation-driven inspection workflows
Dynamic messages for sinks and notifications: Format human-readable messages containing detection counts, class names or timestamps for email, Slack, Twilio or webhook sink blocks, enabling readable alerting workflows
Structured text records: Compose single-line text records from multiple step outputs for logging or downstream processing, enabling text serialization workflows
Connecting to Other Blocks
This block consumes workflow inputs and step outputs and produces a string:
Before VLM blocks (e.g. Qwen-VL, Florence-2, OpenAI, Anthropic Claude, Google Gemini) to build the
promptfrom runtime data, enabling dynamic prompting workflowsAfter model and analytics blocks to render their outputs into readable text, enabling results formatting workflows
Before sink blocks (email, webhook, MQTT, OPC) to format message payloads, enabling notification workflows
Security Considerations
When the template or the data reference workflow inputs or upstream model outputs, whoever controls those sources influences the assembled prompt and, through it, the behaviour of any downstream model that consumes the rendered string (OWASP LLM01, prompt injection). This block guarantees structural safety - no attribute or index access, no positional placeholders, and loud failures on template/data mismatches - but it cannot prevent semantic injection, because a placeholder value is substituted verbatim. Deciding who may supply those inputs is therefore the responsibility of the workflow deployer; prefer constrained, domain-specific inputs (for example an allowlisted SKU catalog) over free-form text wherever the rendered string reaches a model.
Rendering is also bounded to keep a malicious or accidental template from exhausting memory. Numeric width and precision values in format specs are capped at 10,000 and rejected before the padded string is allocated. The rendered output is additionally capped at 1,000,000 characters; output exceeding that cap fails the step with a descriptive error instead of propagating downstream.
Requirements
The template must reference only variables defined in the data dictionary, using plain names without attribute or index access. Data operations are optional and use the same operation system as the Property Definition block; use them to transform values (e.g. join lists, extract properties) before substitution.
Type identifier
Use the following identifier in step "type" field: roboflow_core/string_template@v1 to add the block as a step in your workflow.
Properties
Name
Type
Description
Refs
name
str
Enter a unique identifier for this step..
❌
template
str
Template string with named placeholders in curly braces, filled in from data at runtime. Use double braces for literal braces. Example: 'This facing contains one of: {sku_list}. Answer with the product name or NONE.'.
✅
data
Dict[str, Union[bool, float, int, str]]
Dictionary of named variables used to fill template placeholders. Keys are variable names referenced in the template, values are selectors referencing workflow inputs or step outputs, or literal values..
✅
data_operations
Dict[str, List[Union[ClassificationPropertyExtract, ConvertDictionaryToJSON, ConvertImageToBase64, ConvertImageToJPEG, DetectionsFilter, DetectionsOffset, DetectionsPropertyExtract, DetectionsRename, DetectionsSelection, DetectionsShift, DetectionsToDictionary, Divide, ExtractDetectionProperty, ExtractFrameMetadata, ExtractImageProperty, LookupTable, Multiply, NumberRound, NumericSequenceAggregate, PickDetectionsByParentClass, RandomNumber, SequenceAggregate, SequenceApply, SequenceElementsCount, SequenceJoin, SequenceLength, SequenceMap, SortDetections, StringMatches, StringSubSequence, StringToLowerCase, StringToUpperCase, TimestampToISOFormat, ToBoolean, ToNumber, ToString]]]
Optional dictionary of operations to transform data variables before substitution. Keys are variable names from data, values are lists of operations (same as Property Definition block). Useful for joining lists into text (SequenceJoin) or extracting properties from predictions before templating..
❌
The Refs column marks possibility to parametrise the property with dynamic values available in workflow runtime. See Bindings for more info.
Input and Output Bindings
The available connections depend on its binding kinds. Check what binding kinds String Template in version v1 has.
Last updated
Was this helpful?