https://retellai.com/?utm_source=discord&utm_medium=seo logo
Is there a way in a single prompt to go 'if it's o...
# ❓・ai-evy-support
c
@AI Evy Is there a way in a single prompt to go 'if it's out_of_office, say this and dont deviate from it'. out_of_office is a variable set from the call_inbound webhook
a
Thanks for tagging me @Ciaran. I'll look through relevant sources and get back to you shortly.
### Answer Yes, you can achieve this by passing the
out_of_office
variable from your inbound webhook and referencing it in your prompt using dynamic variable syntax. 1. Return the variable from your inbound webhook: Your webhook response should nest dynamic variables under `call_inbound`: [(1) ]() , [(2) ]()
Copy code
json
{
  "call_inbound": {
    "dynamic_variables": {
      "out_of_office": "true"
    }
  }
}
[(1) ]() , [(2) ]() 2. Reference it in your single prompt: Use the
{{out_of_office}}
syntax in your agent's prompt with conditional instructions: [(3) ]()
Copy code
If {{out_of_office}} is "true", say: "Thank you for calling. Our office is currently closed. Please call back during business hours." Do not deviate from this message and end the call politely.

If {{out_of_office}} is "false", proceed with normal conversation...
Important notes: - All dynamic variable values must be strings (e.g.,
"true"
not
true
) - If the variable isn't provided, it remains in raw form with curly braces intact For more robust conditional routing, you might consider using Conversation Flow with equation-based transitions, which lets you set conditions like
{{out_of_office}} = "true"
to route to specific nodes without relying solely on prompt instructions. [(4) ]()
​ To learn more, see the sources I considered: [[1] Inbound webhook](https://docs.retellai.com/features/inbound-call-webhook) [[2] Inbound webhook returns retell_llm_dynamic_variables but agent doesn't receive them](https://community.retellai.com/t/inbound-webhook-returns-retell-llm-dynamic-variables-but-agent-doesnt-receive-them/733) [[3] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[4] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy We set an intro variable. Updated to use custom message. Is it possible you could write me a prompt I could use?
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer Based on your setup with an
intro
variable for out-of-office messaging, here's a prompt structure you can use:
Copy code
You are a helpful assistant for [Your Company Name].

{{intro}}

If {{intro}} appears with curly braces (meaning no custom intro was provided) , greet the caller with: "Hello, thank you for calling [Your Company Name]. How can I help you today?"

If {{out_of_office}} is "true":
- Deliver only the message in {{intro}}
- Do not engage in any other conversation
- Politely end the call after delivering the message
- Do not answer questions or provide additional information

If {{out_of_office}} is "false" or not set:
- Proceed with normal conversation
- [Add your regular agent instructions here]
[(1) ]() Key points: - The
{{intro}}
variable will be replaced with your custom message when provided - You can check if a variable is unset by adding logic for when it "appears with curly braces" - All dynamic variable values must be strings You can also set a default value for
{{intro}}
at the agent level in the dashboard, which serves as a fallback when the variable isn't included in the call request.
​ To learn more, see the sources I considered: [[1] 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.
c
@AI Evy Since we have a custom message and ai speaks first, its always saying the message rather than this message. Setting it to dynamic message, it doesnt say what I want. I'm a little lost. If this was a conversational flow, it would be easy but it's really hard to use variables in a single prompt
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer I understand the frustration—single prompt agents require more careful prompt engineering for conditional logic compared to conversation flow. The issue: When "AI speaks first" is enabled, the Begin Message field takes priority and speaks before the prompt logic kicks in. Your prompt instructions won't control that initial message. [(1) ]() Solution: Use a dynamic variable directly in the Begin Message field itself, not just in the prompt. Set your Begin Message to:
Copy code
{{intro}}
Then from your inbound webhook, pass the appropriate
intro
value based on office status: - If out of office:
"intro": "Thank you for calling. Our office is currently closed. Please call back during business hours. Goodbye."
- If in office:
"intro": "Hello, thank you for calling [Company Name]. How can I help you today?"
This way the dynamic variable controls exactly what the agent says first. In your prompt, you can then add:
Copy code
If {{out_of_office}} is "true":
- Do not engage in any other conversation after the greeting
- Politely end the call immediately
- Do not answer questions

If {{out_of_office}} is "false":
- Proceed with normal conversation
[(2) ]() Alternative: If you need more reliable conditional branching, Conversation Flow with equation-based transitions (e.g.,
{{out_of_office}} == "true"
) gives you deterministic control without relying on the LLM to interpret prompt instructions. [(3) ]() , [(4) ]()
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) [[3] Retell AI’s Advanced Conversation Flow | Retell AI](https://www.retellai.com/blog/unlocking-complex-interactions-with-retell-ais-conversation-flow) [[4] Step 3: Add transition conditions](https://docs.retellai.com/build/conversation-flow/transition-condition) ​
c
@AI Evy So i've got the call_inbound set and it sets {{intro}}. The prompt calls but it doesn't end the call. If {{out_of_office}} is "true": 1. Say exactly: "Hello, you've reached [AGENT] at [COMPANY NAME]. Thank you for your call! We're currently closed, our operating hours are Monday to Friday, from 9 AM to 6 PM. Please call us back during these hours, and we'll be happy to assist you" 2. After speaking the message, trigger the action/function: 'end_call - Do not continue conversation after calling end_call. - Do not generate additional responses.
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer The issue is that function calling (like
end_call
) depends on the LLM to actually invoke it, and this isn't always 100% reliable. [(1) ]() Here's how to improve your prompt structure for better results: 1. Use explicit conditional checking before every response:
Copy code
## Response Guidelines

- Before every response, check if {{out_of_office}} is "true".
- If {{out_of_office}} == "true":
  - Say exactly: "Hello, you've reached [AGENT] at [COMPANY NAME]. Thank you for your call! We're currently closed, our operating hours are Monday to Friday, from 9 AM to 6 PM. Please call us back during these hours, and we'll be happy to assist you."
  - Immediately call the function: end_call
2. Consider your LLM choice and temperature: Function calling reliability depends heavily on the LLM model. GPT-4.1 or GPT-4o tend to perform better for function calling. Using a lower temperature value (closer to 0, between 0.0-0.3) improves consistency and makes function calling more deterministic. 3. Make sure
end_call
is properly configured as a function:
The function needs to be added to your agent's function calling setup with a clear description so the LLM knows when to invoke it. [(2) ]() If reliability remains an issue: Conversation Flow with equation-based transitions (
{{out_of_office}} == "true"
) gives you deterministic control without relying on the LLM to interpret prompt instructions. [(3) ]()
​ To learn more, see the sources I considered: [[1] How to get a desired call duration to control costs](https://community.retellai.com/t/how-to-get-a-desired-call-duration-to-control-costs/293) [[2] Extract Dynamic Variables](https://docs.retellai.com/build/single-multi-prompt/extract-dv) [[3] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy So whats happening is... Agent says {{intro}}, doesn't end the call and then once I say hello, repeats the sentence and ends. Setting it to dynamic message works. We need to handle multiple booleans. christmas, new_years_day, out_of_office and else christmas, new_years_day and out_of_office will have theyre defined intros otherwise, say this other sentence
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer For handling multiple boolean conditions in a single prompt, the cleanest approach is to handle the logic in your inbound webhook and pass a single
{{intro}}
variable with the appropriate message already set, plus a single
{{should_end_call}}
flag. [(1) ]() From your webhook, determine the priority and set variables accordingly:
Copy code
json
{
  "call_inbound": {
    "dynamic_variables": {
      "intro": "Merry Christmas! Our office is closed for the holidays...",
      "should_end_call": "true"
    }
  }
}
In your prompt, use this structure: [(2) ]()
Copy code
## Response Guidelines

- Before every response, check if {{should_end_call}} is "true".
- If {{should_end_call}} == "true":
  - The greeting in {{intro}} has already been spoken.
  - Immediately call the function: end_call
  - Do not respond to anything the user says.
  - Do not generate additional responses.

- If {{should_end_call}} is "false" or appears with curly braces:
  - Proceed with normal conversation.
  - [Your regular agent instructions here]
, [(3) ]() Why this approach works better: - Offload the conditional logic (christmas vs new_years_day vs out_of_office vs else) to your webhook where you have full programming control [(1) ]() - The LLM only needs to check one simple boolean rather than evaluating multiple conditions [(3) ]() - Function calling reliability improves with simpler, more explicit instructions If the
end_call
still doesn't trigger reliably
, Conversation Flow with equation-based transitions gives you deterministic control—you can create a node specifically for closed-hours that transitions based on
{{should_end_call}} == "true"
without relying on the LLM. [(4) ]()
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) [[3] How to get a desired call duration to control costs](https://community.retellai.com/t/how-to-get-a-desired-call-duration-to-control-costs/293) [[4] Retell AI’s Advanced Conversation Flow | Retell AI](https://www.retellai.com/blog/unlocking-complex-interactions-with-retell-ais-conversation-flow) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy Since I changed it to a dynamic message, its not saying the initial message, she's going a little bit rogue. Agent should always says a set thing for christmas, new_years_day, out_of_office and then else.
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer When using dynamic messages and the agent is "going rogue," the issue is that the LLM has too much freedom to interpret what to say. You need to combine a static Begin Message with strict prompt instructions. [(1) ]() , [(2) ]() Recommended approach: 1. In your inbound webhook, pass the exact intro text and a flag: [(3) ]()
Copy code
json
{
  "call_inbound": {
    "dynamic_variables": {
      "intro": "Merry Christmas! Our office is closed for the holidays. Please call back after December 26th.",
      "should_end_call": "true"
    }
  }
}
2. Set your Begin Message field to:
Copy code
{{intro}}
[(2) ]() 3. Use a sectional prompt with explicit response control: [(1) ]()
Copy code
## Identity
You are a phone assistant for [Company Name].

## Style Guardrails
Be concise: Keep responses under 2 sentences.

## Response Guidelines
- If {{should_end_call}} is "true":
  - Do NOT say anything else after the greeting.
  - Immediately call the function: end_call
  - Do NOT respond to user input.
  - Do NOT generate additional responses.

- If {{should_end_call}} is "false" or appears with curly braces:
  - Proceed with normal conversation.
, [(4) ]() Key points: - Handle all your conditional logic (christmas, new_years_day, out_of_office, else) in your webhook code and pass the final
intro
message [(3) ]() , [(2) ]() - The Begin Message with
{{intro}}
ensures the exact text is spoken first - Lower your model temperature (0.1-0.3) for more deterministic behavior [(4) ]() If the agent still deviates, Conversation Flow with equation-based transitions provides deterministic control without relying on the LLM to follow prompt instructions. [(5) ]()
​ To learn more, see the sources I considered: [[1] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[3] Inbound webhook](https://docs.retellai.com/features/inbound-call-webhook) [[4] How to get a desired call duration to control costs](https://community.retellai.com/t/how-to-get-a-desired-call-duration-to-control-costs/293) [[5] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy
Copy code
## Response Guidelines
- If {{should_end_call}} is "true":
  - Do NOT say anything else after the greeting.
  - Immediately call the function: end_call
  - Do NOT respond to user input.
  - Do NOT generate additional responses.

- If {{should_end_call}} is "false" or appears with curly braces:
  - Proceed with normal conversation.
It should be something like... Say {{intro}} and then if {{should_end_call}} is "true" ...
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer If you're using a dynamic Begin Message set to
{{intro}}
, that message is already spoken first. Your prompt doesn't need to instruct the agent to "say {{intro}}" again—it will have already been delivered. [(1) ]() Here's the adjusted prompt structure:
Copy code
## Response Guidelines

- The greeting in {{intro}} has already been spoken as the Begin Message.
- Before every response, check if {{should_end_call}} is "true".
- If {{should_end_call}} == "true":
  - Do NOT say anything else.
  - Immediately call the function: end_call
  - Do NOT respond to user input.
  - Do NOT generate additional responses.

- If {{should_end_call}} is "false" or appears with curly braces:
  - Proceed with normal conversation.
  - [Your regular agent instructions here]
Why this works: - The Begin Message field handles the initial
{{intro}}
delivery automatically - The prompt then only needs to handle what happens after that message - The LLM checks the
{{should_end_call}}
flag and either ends the call or continues normally If you want the agent to explicitly say
{{intro}}
within the prompt itself (not using Begin Message) , you'd need to switch to Conversation Flow where you can have a dedicated node that speaks a specific message and then transitions based on equation conditions like
{{should_end_call}} == "true"
. [(2) ]()
​ To learn more, see the sources I considered: [[1] How to get a desired call duration to control costs](https://community.retellai.com/t/how-to-get-a-desired-call-duration-to-control-costs/293) [[2] Retell AI’s Advanced Conversation Flow | Retell AI](https://www.retellai.com/blog/unlocking-complex-interactions-with-retell-ais-conversation-flow) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy It's using a dynamic message and isn't saying the {{intro}}. That's not used but what i'm saying is that we can use it in this prompt?
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer Yes, you can reference
{{intro}}
directly in your prompt. Dynamic variables work in prompts using the
{{variable_name}}
syntax. [(1) ]() If you're using a dynamic message (where the LLM generates its own opening) rather than a static Begin Message, you need to explicitly instruct the agent to say the intro in your prompt:
Copy code
## Response Guidelines

- First, say exactly: {{intro}}
- After speaking the intro, check if {{should_end_call}} is "true".
- If {{should_end_call}} == "true":
  - Immediately call the function: end_call
  - Do NOT respond to user input.
  - Do NOT generate additional responses.

- If {{should_end_call}} is "false" or appears with curly braces:
  - Proceed with normal conversation.
, [(2) ]() Important: When a dynamic variable has no assigned value, it remains in its raw form with curly braces intact. [(1) ]() You can add defensive logic:
Copy code
If {{intro}} appears with curly braces, use a generic greeting instead.
Keep in mind that function calling reliability depends on the LLM model—GPT-4.1 tends to perform better for these cases. Using a lower temperature (0.0-0.3) also improves consistency. [(2) ]()
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] How to get a desired call duration to control costs](https://community.retellai.com/t/how-to-get-a-desired-call-duration-to-control-costs/293) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy Do you think using a custom message of {{intro}} is better or to use a dynamic message and message within the prompt?
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer Using a custom Begin Message set to
{{intro}}
is generally the better approach for your use case. Here's why: Custom Begin Message with `{{intro}}`: - The message is spoken immediately and exactly as you set it from your webhook [(1) ]() - No LLM interpretation or generation involved for the opening line - More deterministic and reliable behavior [(2) ]() Dynamic message with prompt instructions: - The LLM generates its own opening, which introduces variability - You're relying on the LLM to follow your prompt instruction to "say exactly {{intro}}" - More prone to the agent "going rogue" as you've experienced [(3) ]() Recommendation: Set your Begin Message to
{{intro}}
and handle all the conditional logic (christmas, new_years_day, out_of_office, else) in your inbound webhook. Pass the exact message you want spoken as the
intro
value, plus a
should_end_call
flag. This way: [(1) ]() 1. The exact greeting is spoken first without LLM interpretation 2. Your prompt only needs to handle the
end_call
logic afterward Dynamic variables work in the Begin Message field. [(2) ]()
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Issue using retell_llm_dynamic_variables](https://discord.com/channels/1186424376300679209/1223405124882534470) [[3] How to get a desired call duration to control costs](https://community.retellai.com/t/how-to-get-a-desired-call-duration-to-control-costs/293) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy Answer is... Put number on a conversational. Handle the out of office, christmas etc. If its none of those, transfer agent to the single prompt 🙂
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer That's a solid approach! Using Conversation Flow for the conditional routing (out_of_office, christmas, new_years_day) and then transferring to your single prompt agent for normal operations gives you the best of both worlds: [(1) ]() - Conversation Flow provides deterministic control with equation-based transitions (e.g.,
{{out_of_office}} == "true"
) without relying on the LLM to interpret prompt instructions - Single Prompt handles your regular conversation logic once you've confirmed it's a normal business hours call This approach minimizes hallucinations for the conditional logic since Conversation Flow uses predefined pathways rather than LLM interpretation. Your flow would look something like: 1. Entry node checks
{{christmas}}
,
{{new_years_day}}
,
{{out_of_office}}
variables [(2) ]() 2. If any are "true" → route to appropriate closed-hours node with the specific message, then end call [(1) ]() 3. If none are true → transfer to your single prompt agent for normal conversation Glad you found a solution that works! 🙂
​ To learn more, see the sources I considered: [[1] Retell AI’s Advanced Conversation Flow | Retell AI](https://www.retellai.com/blog/unlocking-complex-interactions-with-retell-ais-conversation-flow) [[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.
c
@AI Evy Since doing this, it's put a blocker on the agent. I.e: If I just call to know how it works, she will Conversational flow check {{user_id}} exists. If not, get the name, are they calling for a pharmacy etc. But if the patient rings just wanting to know how it works, the agent will just go round in circles asking for their name
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer This looping behavior is a known issue with Conversation Flow nodes when transitions aren't handled properly. [(1) ]() , [(2) ]() The problem: Your flow requires
{{user_id}}
or name collection before proceeding, but there's no escape path for callers who just want general information without identifying themselves. Solutions: 1. Add an "else" or fallback transition — Create a transition condition like "User asks a general question" or "User declines to provide information" that routes to a general FAQ node instead of looping back to ask for their name again. 2. Make nodes smaller with clearer transitions — When nodes have too much content or complex logic, they're more likely to loop. Try splitting the identification flow into separate, simpler nodes. [(1) ]() 3. Add transition fine-tune examples — If the node isn't transitioning when it should, add fine-tune examples showing when the agent should move to the next node vs. when to stay. [(3) ]() 4. Use a Logic Split node with an "else" condition — After checking
{{user_id}}
, add a split that includes an explicit "else" path for users who don't want to identify. [(2) ]() Example structure: - Node 1: Check
{{user_id}}
exists → if yes, proceed; if no, ask for name - Node 2: Ask for name → transition on "User provides name" OR "User asks general question without identifying" - Node 3: General FAQ node for unidentified callers The key is ensuring every node has a valid exit path for all possible u
ser responses.
​ To learn more, see the sources I considered: [[1] Discord message from @medivoice_63089 on 2025-02-21](https://discord.com/channels/1186424376300679209/1186462578310910112/1342636342814703657) [[2] Conversation Flow Node Looping](https://discord.com/channels/1186424376300679209/1372978630841602078) [[3] Tools not being triggered](https://community.retellai.com/t/tools-not-being-triggered/201) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy Basically, if we dont know the {{user_id}} from the call_started webhook, I want to ask who is calling, are they calling on behalf of a Pharmacy but at anypoint i.e: the start of the call, the user might just go, how does it work?
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer --- For handling this "interrupt at any point" scenario in Conversation Flow, Flex Mode is likely your best option. [(1) ]() Why Flex Mode works here: Flex Mode combines conversation flow structure with single prompt flexibility. When enabled, all nodes get converted into a single flex node that behaves like a single prompt agent—meaning the agent can easily switch context between tasks. Key benefits for your use case: - You can easily switch context from different tasks (e.g., every node would become like a global node) - The agent can move to the proper task if the user completed multiple tasks at the same time - After switching context to another flow, the agent can resume the previous task without repeating already completed steps How to structure it: 1. Enable Flex Mode at the agent level in your Conversation Flow 2. Create nodes for: - Identification flow (ask name, pharmacy check) - General FAQ / "how does it work" responses - Your out_of_office/christmas/new_years logic The agent will dynamically navigate between these tasks based on what the user says, rather than being locked into a rigid sequence. Important notes for Flex Mode: - Write node instructions concisely so the LLM can focus on the task - Only use Prompt edges, avoid Equation edges as LLM is bad at interpreting equation conditions in Flex Mode - If using more than 20 nodes, performance might degrade and hallucination risk increases—split into smaller components - Node-level Knowledge Base is ignored; configure KB at agent level instead This way, when someone asks "how does it work?" at any point, the agent can immediately address that question and then return to identification if needed.
​ To learn more, see the sources I considered: [[1] Flex Mode](https://docs.retellai.com/build/conversation-flow/flex-mode) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy Is there no possible way to check if variables exist in a single prompt?
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Prompt Engineering Guide](https://docs.retellai.com/build/prompt-engineering-guide) [[3] How to get a desired call duration to control costs](https://community.retellai.com/t/how-to-get-a-desired-call-duration-to-control-costs/293) ​
### Answer Yes, you can check if a variable exists in a single prompt. When a dynamic variable has no assigned value, it remains in its raw form with the curly braces intact. [(1) ]() In your prompt, you can add conditional logic like:
Copy code
If {{user_id}} appears with curly braces, the variable is not set.
Otherwise, the user has been identified.
For Conversation Flow (using Equations) , you can check:
Copy code
Equation: {{user_id}} exists
Result: True if variable is set
Practical example for your single prompt:
Copy code
## Response Guidelines

- If {{user_id}} appears with curly braces (meaning the variable is unset) :
  - Ask for the caller's name
  - Ask if they're calling on behalf of a pharmacy
  
- If the user asks "how does it work" at any point:
  - Provide the explanation
  - Then return to collecting their information if {{user_id}} is still unset

- If {{user_id}} has a value (no curly braces) :
  - Proceed with the identified user flow
, [(2) ]() The key limitation is that in a single prompt, you're relying on the LLM to interpret these conditions correctly—it's not deterministic like Conversation Flow's equation-based transitions. [(3) ]()
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
c
@AI Evy How do I go about using extract dynamic variables in single prompt, can you give me an example?
a
Once extracted, these values are saved as dynamic variables that you can reference later in the conversation using
{{caller_name}}
or
{{is_pharmacy}}
. [(2) ]()
### Answer --- To use the Extract Dynamic Variable tool in a single prompt agent, follow these steps: [(1) ]() 1. Add an Extract Dynamic Variable Tool In the tools section, click "+ Add" and select "Extract Dynamic Variable." The description is optional. 2. Add Variables Click "+Add" at the bottom and fill in: - Variable Name – A short name to reference this variable (e.g.,
user_name
,
phone_number
) - Description – A brief explanation of what this value should be - Variable Type – Choose from
Text
,
Number
,
Enum
, or
Boolean
- Enum Options – Options to choose from (only when type is enum) Variable Types available: - Text - Any word or sentence (e.g.,
"headache"
,
"John Smith"
) - Number - A numeric value (e.g.,
42
,
98.6
) - Enum - A value from a predefined list (e.g.,
"Yes"
,
"No"
,
"Maybe"
) - Boolean - True or false 3. Save the Extract Dynamic Variable Tool Click the save button. 4. Update your prompt to instruct when to extract Add explicit instructions in your prompt for when to invoke the extraction. For example:
Copy code
When user states his name and phone number, please extract the information by calling the `extract_user_details` function.
Example for your use case: You could create variables like: -
caller_name
(Text) - "The name of the person calling" -
is_pharmacy
(Boolean) - "Whether the caller is calling on behalf of a pharmacy" Then in your prompt:
Copy code
When the user provides their name, extract it using the extract_user_details function.
When the user confirms whether they are calling for a pharmacy, extract that information as well.
​ To learn more, see the sources I considered: [[1] Extract Dynamic Variables](https://docs.retellai.com/build/single-multi-prompt/extract-dv) [[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.