https://retellai.com/?utm_source=discord&utm_medium=seo logo
how Code and Store Fields as Variables in it works
# ❓・ai-evy-support
q
@AI Evy how Code and Store Fields as Variables in it works?
a
Thanks for tagging me @Q4. I'll look through relevant sources and get back to you shortly.
### Answer In Code Node, the Store Fields as Variables feature lets you extract values from your code's return value and save them as dynamic variables for use in other nodes. [(1) ]() ## How It Works When your code returns a result (like a JSON object) , you specify which fields to extract using: - **Variable Name**: What you want to call the extracted value - **JSON Path**: The path to the value using dot notation ## Example If your code returns:
Copy code
javascript
{ "status": "shipped", "estimated_delivery": "March 25" }
You can extract values like this: | Variable Name | JSON Path | Extracted Value | |---------------|-----------|-----------------| |
order_status
|
status
|
"shipped"
| |
delivery_date
|
estimated_delivery
|
"March 25"
| These variables can then be referenced as
{{order_status}}
and
{{delivery_date}}
in other nodes. ## Path Syntax - **Top-level field**:
status
extracts
result.status
- **Nested field**:
data.order.id
extracts
result.data.order.id
- **Array element**:
items[0].name
extracts the first item's name If a path doesn't exist in the return value, the variable is skipped without causing an error.
​ To learn more, see the sources I considered: [[1] Code Node](https://docs.retellai.com/build/conversation-flow/code-node) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.