https://retellai.com/?utm_source=discord&utm_medium=seo logo
how can i make a variable coming from a webhook re...
# ❓・ai-evy-support
k
@AI Evy how can i make a variable coming from a webhook response in a custom function, later be used in another custom function as a sent variable
a
Thanks for tagging me @K Rudy. I'll look through relevant sources and get back to you shortly.
### Answer To use a variable from one custom function's response in another custom function, follow these steps: 1. Extract the variable from the first custom function's response When configuring your first custom function, use the response variables option to extract values from the API response and save them as dynamic variables. [(1) ]() For example, if your response body is:
Copy code
json
{
  "properties": {
    "user": {
      "name": "John Doe",
      "age": 26
    }
  }
}
You can extract
user_name
from this response and reference it later using
{{user_name}}
. 2. Use the extracted variable in another custom function In your second custom function, reference the variable using double curly braces `{{variable_name}}`: - **In the endpoint URL path**: ` - **In query parameters**: Both description and const value can include dynamic variables - **In request headers**: Header values can include dynamic variables Important distinction: If you need the variable in the URL path or query parameters (not just the request body) , you must extract it as a dynamic variable using the Extract Dynamic Variable node/function before calling the custom function that uses it. [(2) ]() Variables saved only as response variables from a custom function are sent in the request body, not automatically available for URL substitution. Key syntax note: Use double curly braces
{{variable_name}}
, not single braces
{variable_name}
. [(3) ]()
​ To learn more, see the sources I considered: [[1] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[2] Custom function failure to substitute dynamic variable](https://community.retellai.com/t/custom-function-failure-to-substitute-dynamic-variable/231) [[3] Issue with Global Variables Not Passing in Query Parameters for Custom Function Tool](https://community.retellai.com/t/issue-with-global-variables-not-passing-in-query-parameters-for-custom-function-tool/773) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.