https://retellai.com/?utm_source=discord&utm_medium=seo logo
how do I add a JSON body to a custom function
# ❓・ai-evy-support
t
@AI Evy how do I add a JSON body to a custom function
a
Thanks for tagging me @thisisalbe. I'll look through relevant sources and get back to you shortly.
### Answer [(1) ]() , [(2) ]() To add a JSON body to a custom function in Retell AI, you need to define parameters using JSON schema format [(1) ]() [(2) ]() . This is only available for POST, PATCH, and PUT requests . Here's how to set it up: 1. **Select the HTTP method**: Choose POST, PATCH, or PUT (required for JSON body parameters) 2. Define parameters using JSON schema format . Here's an example parameter schema:
Copy code
json
{
 "type": "object",
 "properties": {
 "city": {
 "type": "string",
 "description": "The city of the weather"
 }
 },
 "required": [
 "city"
 ]
}
**Important note**: Only include the parameters portion in the JSON schema field [(3) ]() . The function name and description should go in the separate form fields, not in the JSON schema . When Retell calls your custom function, it will send a POST request with a JSON body containing [(2) ]() : - `name`: the function name - `call`: call object with context - `args`: the arguments as a JSON object For additional guidance on JSON schema format, you can refer to OpenAI's Function Calling Guide and Function Calling Tutorial [(1) ]() [(2) ]() .
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] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[3] JSON Schema not saving in custom functions](https://discord.com/channels/1186424376300679209/1319363416296657039) ​
t
How do I insert variables into the JSON body @AI Evy
a
Thanks for the follow-up, @thisisalbe. I'll get back to you soon.
### Answer For custom functions in Retell AI, variables are automatically inserted into the JSON body through the
args
parameter when your function is called [(1) ]() . When Retell calls your custom function, it sends a request with this structure :
Copy code
json
{
  "name": "function_name",
  "call": { /* call object for context */ },
  "args": { /* the arguments as a JSON object */ }
}
The
args
object contains the variables that the LLM extracted from the conversation based on your JSON schema parameters . For example, if you defined a parameter for
city
in your JSON schema, and the user mentions "New York" during the conversation, Retell will automatically populate:
Copy code
json
{
  "name": "get_weather",
  "call": { /* call context */ },
  "args": {
    "city": "New York"
  }
}
The LLM handles the variable extraction and insertion automatically - you don't need to manually insert variables into the JSON body . You just need to define the parameter structure in your JSON schema, and Retell will populate the
args
with the appropriate values from the conversation .
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) ​