https://retellai.com/?utm_source=discord&utm_medium=seo logo
<@1145576664366055464> how should i be using varia...
# ❓・ai-evy-support
v
@AI Evy how should i be using variable placeholders for the likes of the metadata portion of this josn : { "call_id": "redacted", "call_type": "phone_call", "agent_id": "redacted", "call_status": "registered", "latency": {}, "metadata": { "first_name": "Joe", "last_name": "Blogs", "source": "null" }, "call_cost": { "product_costs": [], "total_duration_seconds": 0, "total_duration_unit_price": 0, "total_one_time_price": 0, "combined_cost": 0 }, "opt_out_sensitive_data_storage": false, "from_number": "+redacted", "to_number": "+redacted", "direction": "outbound" }
a
Thanks for tagging me @vaughan_54004. I'll look through relevant sources and get back to you shortly.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Dynamic Variables]() * [LLM WebSocket]() * [Webhook Overview]() * [Inbound call webhook]() -----------------------------
### Answer For metadata in your JSON payload, you can use dynamic variables which are placeholders surrounded by double curly braces [(1)]() . Here's how to implement it: 1. For outbound calls, you can set metadata in the payload when creating the call [(2)]() :
Copy code
json
{
  "metadata": {
    "random_id": "12345"
  }
}
2. For inbound calls, you can set metadata through the inbound call webhook response:
Copy code
json
{
  "call_inbound": {
    "metadata": {
        "random_id": "12345"
    }
  }
}
The metadata field will appear in webhook events that are triggered during the call lifecycle [(3)]() . You can verify this in webhook event payloads where metadata is included in the call object.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
v
@AI Evy how do i use this in my agent prompt?
a
Thanks for the follow-up, @vaughan_54004. I'll get back to you soon.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Dynamic Variables]() * [LLM WebSocket]() * [Step 2: Configure the basic settings]() * [Retell AI | 5 Useful Prompts for Building AI Voice Agents on Retell AI]() -----------------------------
### Answer Dynamic variables can be used in your agent prompt by using double curly braces. For example:
Copy code
json
"Hello {{user_name}}, I understand you're interested in {{product_name}}. How can I help you today?"
[(1)]() You can use dynamic variables in several places: - prompt - begin message - 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) To test your dynamic variables: 1. Add them to your prompts using the {{variable}} syntax 2. Test them using the web interface before deploying 3. For production implementation, set your variables in the
retell_llm_dynamic_variables
field when making calls Note: If a dynamic variable is not assigned a value, it will remain unchanged in the output (e.g., "Hello {{user_name}}" would appear exactly like that if user_name is not set)
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
v
@AI Evy what about when it is coming form the metadata section of the json?
a
Thanks for the follow-up, @vaughan_54004. I'll get back to you soon.
----------------------------- **While I generate an answer, here are some sources that might be helpful**: * [Dynamic Variables]() * [Manually test your agent]() * [LLM WebSocket]() * [Retell AI | Transforming After Hours Call Answering Services with AI Phone Agents]() -----------------------------
### Answer Based on the available documentation, I don't see explicit information about accessing metadata fields directly through dynamic variables. The documentation shows system variables [(1)]() and custom variables set through
retell_llm_dynamic_variables
[(2)]() , but doesn't specifically address accessing metadata fields. I recommend: 1. Contact Retell AI support for clarification on accessing metadata fields 2. Consider moving the metadata fields you need to access in your prompt to the
retell_llm_dynamic_variables
field instead, which is explicitly supported Would you like me to provide a general approach based on the documented dynamic variables functionality?
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.