https://retellai.com/?utm_source=discord&utm_medium=seo logo
can you tell me all the rules and docs about the c...
# ❓・ai-evy-support
v
@AI Evy can you tell me all the rules and docs about the code node
a
Thanks for tagging me @Vyyy. I'll look through relevant sources and get back to you shortly.
### Answer Code Node executes JavaScript code directly in Retell's sandbox when the agent enters it. [(1) ]() Unlike custom functions, code nodes run directly in Retell's sandbox—no external server needed. The node is not intended for having a conversation with the user, but the agent can still talk while code is running if needed. ## Key Characteristics Code Node vs Custom Function: - Runs: JavaScript in Retell's sandbox - Requires: Nothing—runs directly - Best for: Data transformation, simple API calls, logic & calculations - Max code size: 5,000 characters Code Node is designed for lightweight logic like formatting, calculations, and simple read-only lookups. ## JavaScript Environment Your code runs in a JavaScript sandbox with these globals available:
dv
— Dynamic Variables:
Access your agent's dynamic variables as properties on the
dv
object. All values are strings.
Copy code
javascript
const name = dv.customer_name; // "John Doe"
const orderId = dv.order_id; // "78542"
const total = parseFloat(dv.amount) ; // Convert to number if needed
metadata
— Call Metadata:
Access metadata passed when the call was created via the API.
Copy code
javascript
const customerId = metadata.customer_id;
const priority = metadata.priority_level;
fetch(url)
— HTTP Requests:
Make HTTP requests to external APIs. Works like the standard Fetch API.
Copy code
javascript
// GET request
const response = await fetch("<https://api.example.com/data%22)> ;
const data = await response.json() ;
// POST request
const response = await fetch("<https://api.example.com/submit%22,> {
 method: "POST",
 headers: { "Content-Type": "application/json" },
 body: JSON.stringify({ name: dv.customer_name })
}) ;
console.log()
— Debugging:
Log output for debugging. Logs appear in the test output panel when using Run Code, and are also available in call logs. ## Response Variables Response variables let you extract specific values from your code's return value and store them as dynamic variables for use in other nodes. Specify each variable as a name and a JSON path using dot notation. ## Security Guidelines Do not treat dynamic variables or metadata as a secret vault. Avoid placing long-lived API keys, database credentials, or other sensitive secrets in dynamic variables or call metadata for use in Code Node. Both
dv
and
metadata
values are stored in plaintext with every call record—anything you pass in will be visible in call logs and API responses. Use
fetch()
with caution.
Enabling outbound HTTP requests from an LLM-invoked tool increases security and operational risk. Prefer read-only requests to low-risk, public endpoints. Keep production logic in your own backend. For anything involving sensitive credentials, direct writes to production systems, payment actions, regulated data workflows, or business-critical operations that require strict authentication, validation, audit logging, idempotency, or approval controls—use a Custom Function hosted on your own backend. ## Node Settings - Speak During Execution: When enabled, the agent says something while the code runs - Wait for Result: When enabled, the agent waits for the code to finish before transitioning - Timeout: How long the code can run before timing out. Range: 5–60 seconds. Default: 30 seconds - Global Node: Available as an option - Block Interruptions: When enabled, the agent will not be interrupted by the user when speaking
​ 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.