Templating (Scriban)
Using the Scriban syntax to inject dynamic data, logic, and formatting.
Iqra AI uses the Scriban engine to make your agents dynamic. This allows you to inject variables, format dates, perform math, and execute logic directly within your text fields.
You can use templating anywhere you see the Braces Icon in the input label (e.g., AI Response text, SMS content, Tool configurations).
The Smart Editor
We have integrated a Monaco-based Editor for all template fields.
- Intellisense: As you type
{{, a dropdown menu will appear listing all available variables in the current context. - Validation: The editor provides real-time syntax highlighting to catch errors (like unclosed braces) before you save.
Validation
While the frontend editor catches syntax errors, the final execution and validation happen on the backend during the call.
Basic Syntax
To inject a variable, wrap it in double curly braces:
Hello {{ variables.user_name }}, how can I help you?If variables.user_name is "Ahmed", the agent will say: "Hello Ahmed, how can I help you?"
Accessing Data
Data is organized into Namespaces. Here are the common sources available during a conversation:
| Namespace | Variable | Description |
|---|---|---|
| Variables | {{ variables.key }} | State stored via Script Variables or Set Variable nodes. |
| Metadata | {{ metadata.key }} | Data passed when launching the call (via API or CSV). |
| Call | {{ call.from }} | The caller's phone number. |
| Call | {{ call.to }} | The number dialed. |
| Agent | {{ agent.name }} | The internal name of the agent. |
Formatting & Filters
Raw data often sounds robotic. Use Pipes | to apply filters that format the output for natural speech.
Date & Time
Raw ISO: 2023-10-25T14:00:00 > Spoken: "Twenty twenty-three dash..." (Bad).
// Format: Wednesday, October 25 at 2 PM
{{ variables.appt_date | date.to_string "%A, %B %d at %I:%M %p" }}String Manipulation
// Capitalize the first letter
{{ variables.name | string.capitalize }}
// Safety: Default value if variable is empty
{{ variables.name | default "Valued Customer" }}Learn More
Scriban is powerful. Check the official documentation for a full list of built-in functions:
Logic & Control Flow
You can add logic inside a text field. This is powerful for handling minor variations without creating complex branches in your graph.
Conditional Text (If/Else)
Change the greeting based on a flag.
{{ if metadata.is_vip }}
Welcome back to the Premium line, {{ metadata.name }}.
{{ else }}
Thanks for calling Customer Support.
{{ end }}Loops (For)
Iterate over lists returned by FlowApps (e.g., available calendar slots).
I found the following times:
{{ for slot in variables.available_slots }}
- {{ slot.time }}
{{ end }}Best Practices
1. Always use Defaults
If a variable might be null (e.g., a CSV column that is sometimes empty), accessing it directly might cause an error or silence.
Bad: Hello {{ metadata.name }}
Good: Hello {{ metadata.name | default "there" }}
2. Math Calculations
You can perform math directly in the template.
// Calculate remaining balance
Your remaining credit is {{ metadata.limit - variables.current_spend }} dollars.