https://retellai.com/?utm_source=discord&utm_medium=seo logo
I am creating an AI agent that is meant to have ca...
# ❓・ai-evy-support
g
@AI Evy I am creating an AI agent that is meant to have calls transferred to it by other AI agents when the caller starts to indicate they are having a life-threatening emergency. It is meant to send an email and sms message to a specified email address and phone number that is provided by the original AI agent's system prompt. However, after transferring to the emergency response agent, it seems to no longer remember the specified email address and phone number. It continues to ask what phone number and email address should it send the gathered info too.
a
Thanks for tagging me @Goopa Snoops. I'll look through relevant sources and get back to you shortly.
### Answer When using Agent Transfer, the destination agent has access to the full conversation history. [(1) ]() However, the issue you're experiencing is that the email address and phone number are defined in the original agent's system prompt, not passed as data during the conversation itself. The destination agent won't inherit the original agent's prompt or its hardcoded values—it only receives the conversation transcript. ## Solution: Use Dynamic Variables Pass the email and phone number as dynamic variables when initiating the call or during the transfer. Dynamic variables are injected into the Retell LLM prompt and tool descriptions. [(2) ]() You can define default dynamic variables like this:
Copy code
json
{ "customer_name": "John Doe" }
For your use case, you would include the emergency contact info as dynamic variables (e.g.,
{{emergency_email}}
,
{{emergency_phone}}
) , and ensure these are: 1. Set when the original call is created, or 2. Passed through your custom function/tool during the conversation before the transfer occurs Then configure your emergency response agent's prompt to reference these variables (e.g., "Send the alert to {{emergency_email}} and {{emergency_phone}}") . This way, the transferred agent will have access to those values through the dynamic variables rather than relying on prompt content that doesn't carry over.
​ To learn more, see the sources I considered: [[1] Agent Transfer](https://docs.retellai.com/build/single-multi-prompt/transfer-agent) [[2] Create Retell LLM](https://docs.retellai.com/api-references/create-retell-llm) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
g
@AI Evy Where would I add these dynamic variables? In which system prompt?
a
Thanks for the follow-up, @Goopa Snoops. I'll get back to you soon.
### Answer Dynamic variables should be added to the destination agent's prompt (your emergency response agent) , not the original agent's prompt. [(1) ]() Here's how to set this up: ## 1. Add Variables to Your Emergency Agent's Prompt In your emergency response agent's prompt, reference the variables using the
{{variable_name}}
syntax:
Copy code
Send the emergency alert to {{emergency_email}} and {{emergency_phone}}.
## 2. Set the Variable Values You have two options for providing the values: *Option A: At call creation (for outbound calls) * When using the Create Phone Call API, include the variables in `retell_llm_dynamic_variables`:
Copy code
json
{
  "emergency_email": "alert@example.com",
  "emergency_phone": "+12137771234"
}
Option B: For inbound calls Supply dynamic variables in the Inbound Call Webhook response. ## 3. Configure Agent-Level Defaults (Optional) You can also set default values for dynamic variables at the agent level. These serve as a fallback and will only be used when specific variables aren't included in the call request. The key point: the variables need to be defined in the agent that will use them (your emergency response agent) , and the values need to be passed when the call is initiated or via the inbound webhook.
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) ​
g
@AI Evy The issue is that the emergency email and phone number will be different depending on which agent transfers the call to the emergency response agent.
a
Thanks for the follow-up, @Goopa Snoops. I'll get back to you soon.
### Answer Since each originating agent has different emergency contact info, you'll need to use the Extract Dynamic Variables tool in each original agent to capture and store those values before the transfer occurs. [(1) ]() ## Workflow 1. In each original agent, use the Extract Dynamic Variable tool to set variables like
{{emergency_email}}
and
{{emergency_phone}}
with that agent's specific values. 2. In your emergency response agent's prompt, reference those variables:
Copy code
Send the emergency alert to {{emergency_email}} and {{emergency_phone}}.
[(2) ]() When Agent Transfer occurs, the destination agent has access to the full conversation history. [(3) ]() Dynamic variables extracted during the call persist and can be used by the transferred agent. The Extract Dynamic Variable tool lets you save values as dynamic variables that can then be referenced in subsequent prompts and tools. [(1) ]() ## Alternative Approach If the emergency contact info is known at call creation time, you can pass different values via
retell_llm_dynamic_variables
when initiating each call:
Copy code
json
{
  "emergency_email": "specific-alert@example.com",
  "emergency_phone": "+12137771234"
}
[(2) ]() This way, each call starts with the correct contact info already set, and it will be available to any agent that handles the call, including after a transfer.
​ 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) [[3] Agent Transfer](https://docs.retellai.com/build/single-multi-prompt/transfer-agent) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.