https://retellai.com/?utm_source=discord&utm_medium=seo logo
what is the best format for response from function...
# ❓・ai-evy-support
n
@AI Evy what is the best format for response from function or tool call? JSON or plain text?
a
Thanks for tagging me @neerajjoshi_. I'll look through relevant sources and get back to you shortly.
### Answer The best format depends on your implementation approach. For Code Tool, your JavaScript code can return any value—object, string, or number. [(1) ]() The code result is capped at 15,000 characters to prevent overloading the LLM context. For Custom Functions using the dashboard or API, when your endpoint is called, Retell sends a POST request with JSON containing
name
,
call
, and
args
. [(2) ]() Your response should return data that the LLM can process—this can be JSON or plain text depending on what you need the agent to understand and communicate. Based on community experience, one user found that their backend was returning data correctly but the agent wasn't using it properly until they switched from smee.io to ngrok for tunneling. [(3) ]() Another user reported an issue where the agent was announcing the entire JSON object instead of just the intended message. [(4) ]() The key is ensuring your response format matches what you've described in your function's JSON schema parameters and what the LLM expects to process for the conversation. [(5) ]()
​ To learn more, see the sources I considered: [[1] Code Tool](https://docs.retellai.com/build/single-multi-prompt/code-tool) [[2] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[3] Trouble accessing the response of a function call](https://discord.com/channels/1186424376300679209/1233767613293658162) [[4] Agent announces tool call JSON instead of just the 'execution_message'](https://discord.com/channels/1186424376300679209/1348675259867336736) [[5] Function Calling Overview](https://docs.retellai.com/build/single-multi-prompt/function-calling) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
n
@AI Evy can we use dynamic variable in query params?
a
Thanks for the follow-up, @neerajjoshi_. I'll get back to you soon.
### Answer Yes, you can use dynamic variables in query parameters for Custom Functions. [(1) ]() When configuring a Custom Function, you can define query parameters that include dynamic variables. Both the parameter description and const value fields support dynamic variables. Dynamic variables work in Custom Function configurations including: - Custom function URLs [(2) ]() - Tool descriptions - Property descriptions Query parameters can reference dynamic variables using the
{{variable_name}}
syntax. For example, you could use
{{customer_id}}
or
{{order_number}}
as query parameter values that get resolved at runtime with the actual values passed when the call is created.
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] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) ​
n
@AI Evy For mcp query params as well right?
a
Thanks for the follow-up, @neerajjoshi_. I'll get back to you soon.
### Answer I don't have specific information about MCP (Model Context Protocol) query parameters in the available Retell AI documentation. The documentation I have access to covers dynamic variables in Custom Functions [(1) ]() [(2) ]() , where you can use
{{variable_name}}
syntax in query parameters, URLs, headers, and other configuration fields [(3) ]() . Dynamic variables work in tool configurations including custom function URLs, tool descriptions, and property descriptions . If MCP refers to a specific integration or tool type within Retell AI that isn't covered in the standard Custom Function documentation, I'd need more details to provide an accurate answer. Could you clarify what MCP stands for in your use case, or point me to where you're seeing this referenced?
​ To learn more, see the sources I considered: [[1] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[2] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[3] 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.