Talkif Docs
Flow Builder

Prompt Library

Create reusable, dynamic prompts with Handlebars template variables and AI-assisted generation.

The Prompt Library lets you write prompts once and reference them across multiple flows. Changes to a library prompt propagate to every flow that uses it.

Creating prompts

Open the Prompt Library from the Flow Builder sidebar. Each prompt has:

  • Name — a descriptive identifier (e.g., "Support Agent System Prompt")
  • Category — optional grouping for organization
  • Content — the prompt text with optional Handlebars template variables

Template variables

Prompts support Handlebars syntax for injecting dynamic data at runtime. Variables are replaced with real values when the call starts.

You are a support agent for {{account.name}}.
The caller's name is {{default contact.name "there"}}.
{{#ifExists contact.company}}They work at {{contact.company}}.{{/ifExists}}

Contact variables

VariableTypeDescription
contact.namestringFull name
contact.firstNamestringFirst name (derived)
contact.lastNamestringLast name (derived)
contact.primaryPhonestringPhone number
contact.emailstringEmail address
contact.companystringCompany name
contact.occupationstringJob title
contact.notesstringFree text notes
contact.timezonestringTimezone (e.g., "America/New_York")
contact.languagestringLanguage code (e.g., "en")
contact.interestsarrayTopics and hobbies
contact.personalityarrayPersonality traits
contact.communicationStylestringCommunication style
contact.preferredTopicsarrayPreferred discussion topics
contact.tagsarrayLabels and tags
contact.address.streetstringStreet address
contact.address.citystringCity
contact.address.statestringState/province
contact.address.postalCodestringZIP/postal code
contact.address.countrystringCountry
contact.customFieldsobjectAny custom fields you've defined

Call variables

VariableTypeDescription
call.idstringCall UUID
call.directionstringinbound or outbound
call.fromNumberstringCaller ID / source number
call.toNumberstringDestination number

Account variables

VariableTypeDescription
account.idstringAccount UUID
account.namestringAccount name

System variables

Always available, populated automatically.

VariableTypeDescription
system.datestringCurrent date (YYYY-MM-DD)
system.timestringCurrent time (HH:MM:SS)
system.timezonestringTimezone (default: UTC)
system.timestampstringFull ISO 8601 timestamp

Helpers

Helpers let you transform data, handle missing values, and add conditional logic inside your prompts.

default

Returns a fallback value when the variable is empty or missing.

Hello {{default contact.name "there"}}, thanks for calling {{default account.name "us"}}.

ifExists

Block helper that renders content only when the value exists and is not empty.

{{#ifExists contact.email}}We'll send a confirmation to {{contact.email}}.{{else}}Can I get your email for a confirmation?{{/ifExists}}

Comparisons

Use inside {{#if ...}} blocks. All return true/false.

HelperDescriptionExample
eqEqual{{#if (eq call.direction "inbound")}}
neNot equal{{#if (ne contact.language "en")}}
gtGreater than{{#if (gt call.duration 300)}}
ltLess than{{#if (lt contact.tags.length 3)}}
gteGreater or equal{{#if (gte account.plan "pro")}}
lteLess or equal{{#if (lte retry_count 3)}}

Logic

Combine conditions with boolean logic.

{{#if (and contact.email contact.company)}}
I see you're at {{contact.company}} — I'll send details to {{contact.email}}.
{{/if}}

{{#if (or contact.notes contact.preferredTopics)}}
I have some context about your preferences.
{{/if}}

{{#if (not contact.notes)}}
I don't have any notes on file for you.
{{/if}}

String and array

HelperDescriptionExample
includesCheck if array contains value or string contains substring{{#if (includes contact.tags "vip")}}VIP treatment{{/if}}
matchRegex test on a string{{#if (match contact.primaryPhone "^\\+1")}}US number{{/if}}
replaceRegex replace (global){{replace contact.primaryPhone "[^0-9]" ""}}
joinJoin array elements with separator{{join contact.interests ", "}}
jsonConvert value to JSON string{{json contact.address}}

formatDate

Format ISO 8601 date strings.

Today is {{formatDate system.date "long"}}.
FormatOutput
"short"MM/DD/YYYY
"long"Month DD, YYYY
"time"HH:MM:SS
"datetime"YYYY-MM-DD HH:MM:SS
(default)YYYY-MM-DD

Behavior

  • Missing variables render as empty — strict mode is off, so an undefined variable won't crash the call
  • No HTML escaping — output is plain text for voice, not web
  • Truthiness — empty strings, "none", "null", empty arrays, and empty objects are all treated as falsy

AI-assisted generation

Click Generate to describe what you want in plain language. The AI creates a complete Handlebars template using your available variables.

The generator knows about your contact fields, call context, and all available helpers. It produces prompts that are immediately usable — no placeholder text, no manual editing required.

Multi-turn chat is supported. Refine the generated prompt by asking for changes in follow-up messages.

Using prompts in agent nodes

When configuring an Agent node's system prompt or task prompt, you can either:

  1. Write inline — type the prompt directly in the agent node
  2. Reference a library prompt — select from the Prompt Library dropdown

Library prompts appear with a link icon in the agent node, indicating the prompt is managed centrally.

Best practices

  • Use the library for prompts shared across multiple flows (e.g., company-wide tone guidelines)
  • Use inline prompts for flow-specific instructions that won't be reused
  • Use default for every contact field — not all contacts have complete data
  • Use ifExists blocks to conditionally include entire sections
  • Adapt behavior based on call.direction — inbound and outbound calls need different openings
  • Keep prompts focused on one objective per agent node

On this page