https://retellai.com/?utm_source=discord&utm_medium=seo logo
how can i retrieve a response variable from custom...
# ❓・ai-evy-support
k
@AI Evy how can i retrieve a response variable from custom function To letter he used as a sent variable to another custom function
a
Thanks for tagging me @K Rudy. I'll look through relevant sources and get back to you shortly.
### Answer To retrieve a response variable from a custom function and use it in another custom function, follow these steps: Step 1: Set Response Variables When configuring your first custom function, use the "Set response variables" option to extract values from the API response and save them as dynamic variables. [(1) ]() [(2) ]() For example, if your API returns:
Copy code
json
{
  "properties": {
    "user": {
      "name": "John Doe",
      "age": 26
    }
  }
}
You can extract the user's name and reference it later using
{{user_name}}
. Step 2: Use the Variable in Another Custom Function Once extracted as a dynamic variable, you can reference it in your second custom function using the
{{variable_name}}
syntax in: [(3) ]() - Endpoint URLs - Request headers (can be static or include dynamic variables) [(1) ]() [(2) ]() - Query parameters (both description and const value can include dynamic variables) - Parameter properties using
"const": "{{variable_name}}"
in the JSON schema Example parameter schema using a dynamic variable:
Copy code
json
{
  "type": "object",
  "properties": {
    "last_name": {
      "type": "string",
      "const": "{{last_name}}"
    }
  }
}
Important Note: Response variables saved from a custom function need to be extracted as dynamic variables to be used in subsequent function calls' URL paths or query parameters. Use the variable name directly like
{{variable_name}}
in both the const value and description fields. [(4) ]()
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] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[4] Custom function failure to substitute dynamic variable](https://community.retellai.com/t/custom-function-failure-to-substitute-dynamic-variable/231) ​