https://retellai.com/?utm_source=discord&utm_medium=seo logo
Hey how can we write a prompt in a conversation no...
# ❓・ai-evy-support
a
@AI Evy Hey how can we write a prompt in a conversation node with variables ? the variable value not accessed correctly for me ?
a
Thanks for tagging me @afrah_85175. I'll look through relevant sources and get back to you shortly.
### Answer To use dynamic variables in conversation nodes, you need to use the double curly brace syntax [(1) ]() . Here's how to properly implement them: Where you can use dynamic variables: - prompt - begin message - tool call url - tool call description - custom tool call properties description - voicemail setting (both prompt and static text) - transfer call function number - warm transfer setting (both prompt and static text) Syntax example:
Copy code
"Hello {{user_name}}, I understand you're interested in {{product_name}}. How can I help you today?"
For Conversation Flow nodes specifically: [(2) ]() In conversation nodes, you can write instructions using either: - **Prompt**: Write a prompt for the agent to dynamically generate what to say - **Static Sentence**: Agent will say a fixed sentence first, and if later still inside this node, it will generate content dynamically based on the static sentence set Setting up variables: [(1) ]() 1. Add dynamic variables in your prompts using the
{{variable_name}}
syntax 2. Test your dynamic variables using the web interface 3. Configure agent-level default dynamic variables as fallback values For production implementation: When using the Create Phone Call API, set your variables in the
retell_llm_dynamic_variables
field :
Copy code
{
  "user_name": "John Smith",
  "product_name": "Premium Plan",
  "account_status": "active"
}
Common troubleshooting: [(3) ]() Based on community reports, dynamic variables may work differently between "Test LLM" and "Test Audio" modes, with some users reporting better results testing via the API directly .
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Conversation Node](https://docs.retellai.com/build/conversation-flow/conversation-node) [[3] The agent does not use the {{variable}}.](https://discord.com/channels/1186424376300679209/1318471948434669641) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
Thanks for the follow-up, @afrah_85175. I'll get back to you soon.
### Answer When default dynamic variables aren't working, here are the key troubleshooting steps based on common issues: Check Variable Name Matching [(1) ]() Dynamic variables must match the exact names in your prompt and be case-sensitive . The variables in
retell_llm_dynamic_variables
must be sent as strings and match exactly what's in your prompt . Verify Default Variables Setup [(2) ]() You can set default values for dynamic variables at the agent level . Default variables serve as a fallback and will only be used when specific variables aren't included in the call request . For the Update Retell LLM API, set defaults like this [(3) ]() :
Copy code
javascript
"default_dynamic_variables": {
  "customer_name": "John Doe"
}
Common Issue Resolution [(4) ]() A community member found that using this format in their webhook response fixed variable setting issues :
Copy code
javascript
return {
  "call_inbound": {
    "dynamic_variables": {
        "caller_name": " "
    }
  }
}
Edge Case Behavior [(2) ]() When a dynamic variable is not assigned a value, it will remain unchanged in the output . For example, if
user_name
is not set, the output will show
"Hello {{user_name}}, how can I help you today?"
with the variable visible in raw form . Verification Steps 1. Test your dynamic variables using the web interface before deploying 2. Ensure your prompt explicitly references the variables using
{{variable_name}}
syntax 3. Check that default variables are configured at the agent level If the variables appear in the Data tab but aren't being used in functions, verify that your prompt explicitly references them and that the tool/function is properly configured to use them [(1) ]() .
​ To learn more, see the sources I considered: [[1] dynamic variables are not being used even though in data tab it was captured](https://discord.com/channels/1186424376300679209/1380529470468919320) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[3] Update Retell LLM](https://docs.retellai.com/api-references/update-retell-llm) [[4] Dynamic Variables](https://discord.com/channels/1186424376300679209/1356680357084135558) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
Thanks for the follow-up, @afrah_85175. I'll get back to you soon.
a
@AI Evy I asked this for conversation agent
a
### Answer For conversation flow agents specifically, here's how to properly set up default dynamic variables: Setting Default Variables for Conversation Flow [(1) ]() In the Create Conversation Flow API, set your default dynamic variables like this:
Copy code
javascript
"default_dynamic_variables": {
  "company_name": "Retell Inc",
  "support_hours": "9 AM - 5 PM"
}
Where Variables Can Be Used in Conversation Flow [(2) ]() Dynamic variables work in conversation flow agents in these locations: - prompt - begin message - tool call url - tool call description - custom tool call properties description - voicemail setting (both prompt and static text) - transfer call function number - warm transfer setting (both prompt and static text) Troubleshooting for Conversation Flow [(3) ]() Based on community feedback, some users have found that conversation flow agents may have different behavior with dynamic variables compared to single prompt agents . One user reported that the agent only recognized the variable correctly when it was included in the welcome message, but not when it was only in the prompt . Verification Steps for Conversation Flow 1. Ensure your
default_dynamic_variables
object is properly configured in your conversation flow [(1) ]() 2. Test that variables appear correctly using the
{{variable_name}}
syntax [(2) ]() 3. Check that all values in your dynamic variables are strings If default variables still aren't working in your conversation flow agent, you may want to test with a simple variable first to isolate the issue, as suggested in the community discussions [(4) ]() .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
@AI Evy I want to set the values for that variable when i get the value from the user during the convseration flow
a
Thanks for the follow-up, @afrah_85175. I'll get back to you soon.
### Answer Setting Dynamic Variables During Conversation Flow For conversation flow agents, you can use equation conditions to set and check dynamic variables during the conversation [(1) ]() . Here's how to work with variables that are collected during the flow: Using Variables in Transition Conditions You can use variables that are passed in as dynamic variables for equation conditions. Note that if you need to use information extracted by the LLM during the call, you should use prompt conditions instead . Equation Examples for Dynamic Variables
Copy code
- {{user_age}} > 18
- {{current_time}} > 9 AND {{current_time}} < 18
- {{user_location}} == "New York"
- {{user_location}} != "New York"
- "New York, Los Angeles" CONTAINS {{user_location}}
- "New York, Los Angeles" NOT CONTAINS {{user_location}}
- {{user_age}} < 18 OR {{user_location}} == "New York"
Checking If Variables Are Set [(2) ]() To check if a dynamic variable is not set in conversation flow: - In equations: use
{{user_name}} contains {{
- this evaluates to true if the variable is not set - In prompts: use
{{user_name}} is not set (have curly braces around it)
Important Limitations [(1) ]() You can only use variables that are passed in as dynamic variables for equation conditions. If you need to use information extracted by the LLM (such as information learned during the call) , you must use prompt conditions instead . Edge Case Behavior [(2) ]() When a dynamic variable is not assigned a value, it will remain unchanged in the output. For example, if
user_name
is not set, the output will show
"Hello {{user_name}}, how can I help you today?"
with the variable visible in raw form . Based on the available documentation, conversation flow agents primarily work with pre-set dynamic variables rather than dynamically setting new variable values during the conversation. For information extracted during the call, you'll need to use prompt conditions in your transition logic [(1) ]() .
​ To learn more, see the sources I considered: [[1] Step 3: Add transition conditions](https://docs.retellai.com/build/conversation-flow/transition-condition) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.