https://retellai.com/?utm_source=discord&utm_medium=seo logo
Why is it that my function tool invocation sends {...
# ❓・ai-evy-support
p
@AI Evy Why is it that my function tool invocation sends {{variable}} to the API I set up instead of resolving it and sending that?
a
Thanks for tagging me @Prince P Appiah. I'll look through relevant sources and get back to you shortly.
### Answer When a dynamic variable like
{{variable}}
is sent to your API in its raw form instead of being resolved, this typically means the variable has no assigned value at the time of the function call. [(1) ]() ## Default Behavior for Missing Variables When a dynamic variable has no assigned value, it remains in its raw form with the curly braces intact. For example: - If
user_name
is not provided:
"Hello {{user_name}}, how can I help you today?"
- If
user_name
is "John":
"Hello John, how can I help you today?"
## How to Fix This 1. Ensure the variable is set when creating the call — For outbound calls, set your variables in the
retell_llm_dynamic_variables
field when using the [Create Phone Call]() API. Note that all values must be strings. 2. Set default values at the agent level — You can configure 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. 3. For inbound calls — Supply dynamic variables in the Inbound Call Webhook. ## Using Variables in Custom Functions In your custom function configuration, both the description and const value in query parameters can be dynamic variables. Description will be resolved by the LLM while const value will be applied directly to the function. [(2) ]() If you're using a
const
value with a dynamic variable in your parameter schema, like:
Copy code
json
"last_name": {
  "type": "string",
  "const": "{{last_name}}"
}
The variable still needs to be provided via
retell_llm_dynamic_variables
for it to resolve properly.
​ To learn more, see the sources I considered: [[1] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[2] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
p
Well that makes no sense because the variable is set. Asking for the first six digits of customer code {{customer_code[:6]}} sends literally {{customer_code[:6]}} instead of resolving it. It's jarring. Never used to do this as well
@AI Evy Well that makes no sense because the variable is set. Asking for the first six digits of customer code {{customer_code[:6]}} sends literally {{customer_code[:6]}} instead of resolving it. It's jarring. Never used to do this as well
@AI Evy Well that makes no sense because the variable is set. Asking for the first six digits of customer code {{customer_code[:6]}} sends literally {{customer_code[:6]}} instead of resolving it. It's jarring. Never used to do this as well
a
Thanks for the follow-up, @Prince P Appiah. I'll get back to you soon.
### Answer --- The syntax
{{customer_code[:6]}}
(using Python-style slicing) is not supported by Retell's dynamic variable system. [(1) ]() Dynamic variables in Retell use the
{{variable_name}}
syntax and support nested variables like
{{current_time_{{my_timezone}}}}
, but they do not support string manipulation operations such as slicing or substring extraction within the curly braces. ## Workarounds 1. Extract the substring before passing it — When you set
retell_llm_dynamic_variables
in your API call, pre-process the value on your backend so you pass
customer_code_prefix
already containing just the first six digits. 2. Create a separate variable — Instead of trying to slice within the template, create a dedicated variable like
{{customer_code_prefix}}
that holds the truncated value. 3. Handle it in your custom function — Pass the full
{{customer_code}}
to your API and perform the substring operation on your backend. I don't have documentation confirming that slicing syntax ever worked previously. If this behavior changed for you, I'd recommend reaching out to Retell support directly for clarification. Check out these potentially useful sources: - [Dynamic Variables]() - [Extract Dynamic Variables]() - [Contact Sales]()
​ 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.