https://retellai.com/?utm_source=discord&utm_medium=seo logo
can you output what JSON would be sent in a custom...
# ❓・ai-evy-support
l
@AI Evy can you output what JSON would be sent in a custom function?
a
Thanks for tagging me @legend28469. I'll look through relevant sources and get back to you shortly.
### Answer When Retell calls your custom function, it sends a POST request with the following JSON structure in the request body [(1) ]() :
Copy code
json
{
  "name": "function_name",
  "call": { /* call object with context and transcript */ },
  "args": { /* function arguments as JSON object */ }
}
The request body contains : - `name`: the name of the custom function - `call`: the call object for context, including real-time transcript up to when the request is sent - `args`: the arguments for the custom function as a JSON object The request also includes headers : - `X-Retell-Signature`: encrypted request body using your secret key to verify the request is from Retell -
Content-Type: application/json
indicating the payload is in JSON format For GET and DELETE requests, the request body is empty .
Thanks for the follow-up, @legend28469. I'll get back to you soon.
l
@AI Evy can you populate it with an example custom function?
a
### Answer Based on the sources, here's an example of what JSON Retell sends when calling a custom function [(1) ]() :
Copy code
json
{
  "call": {
    "call_type": "phone_call",
    "from_number": "+12137771234",
    "to_number": "+12137771235",
    "direction": "inbound",
    "call_id": "Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6",
    "agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
    "call_status": "registered",
    "metadata": {},
    "retell_llm_dynamic_variables": {
      "customer_name": "John Doe"
    },
    "opt_out_sensitive_data_storage": true
  },
  "name": "get_weather",
  "args": {
    "city": "New York"
  }
}
In this example, the custom function is named
get_weather
, and it receives a
city
argument with the value
"New York"
. The
call
object contains context about the phone call, including caller information, call ID, agent ID, and any dynamic variables .
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] Discord message from @bimal.patel on 2024-11-17](https://discord.com/channels/1186424376300679209/1294891368505937952/1307604643517304842) ​
l
@AI Evy this is true for outgoing calls too?
a
Thanks for the follow-up, @legend28469. I'll get back to you soon.
### Answer Yes, the JSON structure for custom functions is the same for outbound calls [(1) ]() . When Retell calls your custom function endpoint, it always sends a POST request with the same structure regardless of call direction [(2) ]() . The
call
object will include a
direction
field that indicates whether it's an
"inbound"
or
"outbound"
call [(1) ]() . For outbound calls, the
from_number
will be your Retell number and the
to_number
will be the destination number you're calling [(3) ]() .
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] Discord message from @noahreis on 2024-11-18](https://discord.com/channels/1186424376300679209/1294891368505937952/1308171340859183164) [[2] Discord message from @fyodor2572 on 2024-10-26](https://discord.com/channels/1186424376300679209/1294891368505937952/1299822141763752090) [[3] Outbound Calls (Make Calls)](https://docs.retellai.com/deploy/outbound-call) ​
​ To learn more, see the sources I considered: [[1] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.