Add a Code node to a Retell conversation flow to run JavaScript, read dynamic variables and metadata, call HTTP APIs, and store results.
A Code node runs JavaScript when a conversation flow enters the node. Use it
for calculations, data formatting, and lightweight HTTP lookups that don’t
require your own server. The code can read dynamic variables and call metadata,
then store fields from its return value for later nodes.For example, a Code node can normalize an appointment timestamp, return an
appointment_label, and let the flow route based on whether the timestamp was
valid.If you use a single- or multi-prompt agent, see Code Tool.
Automatically when the flow enters a function node
Inputs
Dynamic variables and call or chat metadata
Parameters, dynamic variables, and request data
Best for
Formatting, calculations, and low-risk HTTP lookups
Authenticated integrations and production workflows
Maximum code size
20,000 characters
Not applicable
Use a Code node only for logic that can run without secrets. Dynamic variables
and metadata are stored in plaintext with the call or chat record. For
authentication, secret management, internal systems, or production writes, use
a custom function hosted on your
backend.
Under Store Fields as Variables, map a dynamic-variable name to a path
in the returned value. For the example above, map appointment_is_valid to
valid and appointment_label to appointment_label.See Store response variables for nested and
array paths.
5
Configure execution and transitions
Set the timeout in the code editor. In Execution mode, choose Wait for completion if the next node needs the result, or Run in background (async) to continue without waiting. Waiting mode also offers speech and typing-sound feedback.
6
Test the code
Use Dynamic Variables in the editor to add test values, then select
Run Code. The result and any console.log() output appear below the
editor.Test values stay in the dashboard and don’t change the live agent. The
dashboard test doesn’t populate metadata, so metadata-dependent code must
handle an empty object during testing.
Use dv.user_number, not {{user_number}}, inside JavaScript. Runtime values
such as call_id, chat_id, session_type, direction, user_number, and
agent_number are available when they apply to the current session.
Dynamic variables are available through dv inside JavaScript. {{...}}
template substitution isn’t available inside code.
fetch() supports HTTP and HTTPS URLs, request methods, string-valued headers,
and request bodies. The returned response supports status, ok,
statusText, url, headers.get(), text(), and json().
The sandbox blocks non-HTTP protocols and selected local, private, and platform
addresses. It doesn’t provide the complete browser Fetch API.Code node fetch() requests originate from 35.166.138.221. If your public
API restricts inbound traffic by IP address, allowlist 35.166.138.221/32.
The sandbox provides common JavaScript built-ins such as Array, Date,
JSON, Map, Math, Promise, RegExp, and Set. Node.js modules, browser
DOM APIs, require, import, and Intl aren’t available.
Stored values are strings. Objects and arrays are stored as JSON strings. If a
path doesn’t exist or resolves to null, Retell skips that variable without
failing the execution.Response-variable extraction uses the full return value, even when the result
sent to the agent is capped at 15,000 characters.
Execution mode defaults to Wait for completion. Retell waits for the code result before evaluating transitions, so returned fields are available to conditions and the next node. Choose Run in background (async) only when later nodes can proceed before the result and response variables are available. The API represents this choice with wait_for_result.Waiting mode offers Talk While Waiting and Play typing sound. These controls are hidden in background mode. Caller interruptions can still affect speech timing.To branch on whether code execution itself succeeded, set the API’s execution status variable, separately from response-variable extraction.Use transition conditions that
check stored result fields before the agent confirms an action succeeded.
Don’t put API keys, credentials, or sensitive tokens in code, dv, or
metadata.
Use fetch() for low-risk HTTP reads. Put authenticated requests and
state-changing operations behind a custom function on your backend.
For critical routing, provide a safe else path. A timeout, thrown error, or
sandbox failure doesn’t retry automatically and doesn’t extract response
variables.
No. The sandbox doesn’t provide require, import, Node.js modules, browser DOM APIs, or Intl. Use the available JavaScript built-ins and fetch().
Can I use built-in system variables in the code?
Runtime values are available as properties of dv, including dv.call_id, dv.user_number, and dv.agent_number when they apply. Use dv.name syntax to access them. {{...}} template substitution isn’t available inside JavaScript.
What happens if the code times out or throws an error?
Retell marks the execution as failed, doesn’t extract response variables, and doesn’t retry automatically. Use try/catch for expected errors and return a structured fallback such as { "ok": false, "error": "lookup failed" }. For critical routing, configure a safe else path.
Why did the agent talk with Talk While Waiting off?
The setting suppresses the node’s entry message. If the caller speaks while the code is running, that user turn can still trigger an agent response before the code result is available. Ground any success confirmation in a stored result field instead of conversation context alone.
Can I use async/await?
Yes. Top-level await is supported, including for fetch() calls.
Is there a limit on the result size?
Retell sends up to 15,000 characters to the agent by default. Response-variable extraction uses the full return value before that result is capped.
Was this page helpful?
⌘I
{"docsConfig":{"theme":"almond","$schema":"https://mintlify.com/docs.json","name":"Retell AI","description":"Explore Retell AI docs to learn how to build, test, deploy, and optimize AI voice agents with APIs, integrations, conversation flows, and production-ready tools.","colors":{"primary":"#606A78","light":"#F5F5FA","dark":"#172131"},"logo":{"light":"https://mintcdn.com/retellai/-E9UettTBfBiCBBS/images/docs-light.png?fit=max\u0026auto=format\u0026n=-E9UettTBfBiCBBS\u0026q=85\u0026s=64eb26a2d3cc9a67ee3ea0bfe086dd14","dark":"https://mintcdn.com/retellai/-E9UettTBfBiCBBS/images/docs-dark.png?fit=max\u0026auto=format\u0026n=-E9UettTBfBiCBBS\u0026q=85\u0026s=08472a0c78599498b85d23348d7826f6"},"favicon":"https://mintcdn.com/retellai/TsBk7Stx4694-7p1/logo/favicon-light.ico?fit=max\u0026auto=format\u0026n=TsBk7Stx4694-7p1\u0026q=85\u0026s=4e90f4db5e89b5ec7fe249a4844c2d97","api":{"openapi":["openapi-final.yaml"],"playground":{"display":"interactive"},"mdx":{"auth":{"method":"bearer"},"server":"https://api.retellai.com"}},"navbar":{"links":[{"icon":"message-circle-question-mark","href":"https://docs.retellai.com/general/support","label":"Support"},{"icon":"chart-line","href":"https://status.retellai.com/","label":"Status"},{"icon":"book","href":"https://www.retellai.com/changelog","label":"Changelog"}],"primary":{"type":"button","label":"Dashboard","href":"https://dashboard.retellai.com"}},"footer":{"socials":{"x":"https://x.com/retellai","linkedin":"https://www.linkedin.com/company/98828489","github":"https://github.com/RetellAI","instagram":"https://www.instagram.com/retell_ai","youtube":"https://www.youtube.com/@retellai"}},"fonts":{"family":"Inter"},"icons":{"library":"lucide"},"styling":{"codeblocks":"dark","latex":true},"integrations":{"mixpanel":{"projectToken":"c8676d3561adb5eefc366aa2a66725bc"}},"contextual":{"options":["copy","view","chatgpt","claude","cursor"],"display":"header"},"interaction":{"drilldown":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"retellai","hasAudioNarration":false,"actualSubdomain":"retellai","customDomains":["docs.retellai.com"],"gitSource":{"type":"github","owner":"retellai","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae825ab21b4422fadc6ad73","collectionId":"b4ff8e8c-150d-4079-881b-b7ec427c9421","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae825ab21b4422fadc6ad73"},"feedback":{"thumbs":true,"edits":false,"issues":false,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae825ab21b4422fadc6ad73","clientVersion":"0.0.4044","searchFilterCounts":[{"language":"default","tag":"Guides","count":214},{"language":"default","tag":"API Reference","count":107},{"language":"default","tag":"Build","count":68},{"language":"default","tag":"Deploy","count":35},{"language":"default","tag":"Integrations","count":30},{"language":"default","tag":"Conversation flow agents","count":24},{"language":"default","tag":"Deprecations","count":22},{"language":"default","tag":"CRM","count":21},{"language":"default","tag":"Detailed Deprecation Guide","count":21},{"language":"default","tag":"Monitor","count":17}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instinct-self-updating-docs","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"@media (min-width:1024px){#navbar .flex-1:has(>[data-slot=context-menu-trigger]),#navbar .flex-1:has(>a>.nav-logo){flex:none!important;width:15rem}#navbar .justify-end:has(.nav-tabs),#navbar .ustify-end:has(.nav-tabs){justify-content:space-between!important;margin-left:0!important}#navbar .flex:has(>.justify-end),#navbar .flex:has(>.ustify-end){flex:1!important}#navbar .nav-tabs{white-space:nowrap}}.max-w-prose,.max-w-xl,article{max-width:48rem!important}video.scroll-play{cursor:zoom-in}.video-zoom-overlay{position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;padding:4vmin;background:rgba(0,0,0,.8);backdrop-filter:blur(2px);cursor:zoom-out}.video-zoom-media{max-width:92vw;max-height:92vh;width:auto;height:auto;border-radius:12px;box-shadow:0 10px 40px rgba(0,0,0,.5);cursor:default}.video-zoom-close{position:fixed;top:16px;right:20px;display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border:0;border-radius:999px;background:rgba(255,255,255,.15);color:#fff;font-size:24px;line-height:1;cursor:pointer}.video-zoom-close:hover{background:rgba(255,255,255,.3)}.ui-btn{background-color:#f4f5f7!important;color:#1f2328!important;border:1px solid #d0d5dd!important;border-bottom-width:2px!important;border-radius:6px!important;padding:.1em .42em!important}[data-theme=dark] .ui-btn,html.dark .ui-btn{background-color:#21252d!important;color:#e6e8eb!important;border-color:#3a4048!important}img[src$=\"/images/icons/wss-badge.svg\"]{width:auto!important;height:15px!important}a[aria-current=page] img[src$=\"/images/icons/wss-badge.svg\"]{content:url(\"data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2227%22 height=%2215%22 viewBox=%220 0 27 15%22 role=%22img%22 aria-label=%22WSS%22%3E %3Crect width=%2227%22 height=%2215%22 rx=%224%22 fill=%22%23F54A00%22/%3E %3Ctext x=%2213.5%22 y=%2210.7%22 text-anchor=%22middle%22 font-family=%22ui-sans-serif, system-ui, -apple-system, Segoe UI, Inter, Helvetica, Arial, sans-serif%22 font-size=%228.8%22 font-weight=%22700%22 fill=%22%23FFFFFF%22%3EWSS%3C/text%3E %3C/svg%3E\")}"}],"page":{"pagePath":"build/conversation-flow/code-node","slug":"/build/conversation-flow/code-node","pageMetadata":{"title":"Code node: run JavaScript in a conversation flow","description":"Add a Code node to a Retell conversation flow to run JavaScript, read dynamic variables and metadata, call HTTP APIs, and store results.","keywords":["Code node","conversation flow JavaScript","JavaScript sandbox","dynamic variables","response variables"],"og:title":"Run JavaScript in a Retell conversation flow with Code node","og:description":"Use a Code node to run JavaScript, read dynamic variables and metadata, call public HTTP APIs, and route a conversation flow from structured results.","href":"/build/conversation-flow/code-node"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Add a Code node to a Retell conversation flow to run JavaScript, read dynamic variables and metadata, call HTTP APIs, and store results.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{Accordion,AccordionGroup,CodeBlock,Frame,Heading,Note,OptimizedImage,Step,Steps,Table,Warning}=_components;if(!Accordion)_missingMdxReference(`Accordion`,true);if(!AccordionGroup)_missingMdxReference(`AccordionGroup`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Frame)_missingMdxReference(`Frame`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Step)_missingMdxReference(`Step`,true);if(!Steps)_missingMdxReference(`Steps`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`A Code node runs JavaScript when a conversation flow enters the node. Use it\nfor calculations, data formatting, and lightweight HTTP lookups that don’t\nrequire your own server. The code can read dynamic variables and call metadata,\nthen store fields from its return value for later nodes.`}),`\n`,_jsxs(_components.p,{children:[`For example, a Code node can normalize an appointment timestamp, return an\n`,_jsx(_components.code,{children:`appointment_label`}),`, and let the flow route based on whether the timestamp was\nvalid.`]}),`\n`,_jsxs(_components.p,{children:[`If you use a single- or multi-prompt agent, see `,_jsx(_components.a,{href:`/build/single-multi-prompt/code-tool`,children:`Code Tool`}),`.`]}),`\n`,_jsx(Frame,{caption:`A Code node on the conversation flow canvas.`,children:_jsx(OptimizedImage,{src:`https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/code-node.png?fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=47f4edf2355f4b2f96ca573723392a7f`,alt:`Conversation flow canvas with a Code node that has an Open button for its code configuration and an outgoing transition.`,\"data-og-width\":`150`,width:`150`,\"data-og-height\":`159`,height:`159`,\"data-path\":`images/cf/code-node.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/code-node.png?w=280\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=893f53508f5d3df3d69327b9ae5b02dd 280w, https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/code-node.png?w=560\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=7a25a458e322fe50a41abb3aa1f2000e 560w, https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/code-node.png?w=840\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=46d9a2f5738ee5f4fe85a1169ebdb50b 840w, https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/code-node.png?w=1100\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=527c834ae11aab601abc1cc768350240 1100w, https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/code-node.png?w=1650\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=e0280edeb4255d5c66a4f45bacbe2f5b 1650w, https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/code-node.png?w=2500\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=5fa1cb52d5b91c6a461efe5eccd55219 2500w`})}),`\n`,_jsx(Heading,{level:`2`,id:`when-to-use-a-code-node`,children:`When to use a Code node`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{}),_jsx(_components.th,{children:`Code node`}),_jsx(_components.th,{children:`Custom function`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Runs`})}),_jsx(_components.td,{children:`JavaScript in Retell’s sandbox`}),_jsx(_components.td,{children:`An HTTP request to your server`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Trigger`})}),_jsx(_components.td,{children:`Automatically when the flow enters the node`}),_jsx(_components.td,{children:`Automatically when the flow enters a function node`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Inputs`})}),_jsx(_components.td,{children:`Dynamic variables and call or chat metadata`}),_jsx(_components.td,{children:`Parameters, dynamic variables, and request data`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Best for`})}),_jsx(_components.td,{children:`Formatting, calculations, and low-risk HTTP lookups`}),_jsx(_components.td,{children:`Authenticated integrations and production workflows`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Maximum code size`})}),_jsx(_components.td,{children:`20,000 characters`}),_jsx(_components.td,{children:`Not applicable`})]})]})]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Use a Code node only for logic that can run without secrets. Dynamic variables\nand metadata are stored in plaintext with the call or chat record. For\nauthentication, secret management, internal systems, or production writes, use\na `,_jsx(_components.a,{href:`/build/conversation-flow/custom-function`,children:`custom function`}),` hosted on your\nbackend.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`configure-a-code-node`,children:`Configure a Code node`}),`\n`,_jsxs(Steps,{children:[_jsxs(Step,{title:`Add a Code node`,children:[_jsxs(_components.p,{children:[`Select `,_jsx(_components.strong,{children:`Code`}),` from the action nodes in the left sidebar.`]}),_jsx(Frame,{caption:`Code in the conversation flow action-node menu.`,children:_jsx(OptimizedImage,{src:`https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/add-code-node.png?fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=f3a2d7d9e7db9ff3687f4abf9573737a`,alt:`Conversation flow action-node menu with Code between Extract Variable and MCP.`,\"data-og-width\":`220`,width:`220`,\"data-og-height\":`215`,height:`215`,\"data-path\":`images/cf/add-code-node.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/add-code-node.png?w=280\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=88b41ecfbcd0a0e2f82388e880837a7e 280w, https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/add-code-node.png?w=560\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=5597e528f9c538f36032767d82a76e98 560w, https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/add-code-node.png?w=840\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=fae438d1d6332d0bea847991d1989b48 840w, https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/add-code-node.png?w=1100\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=e0bf7cd86e35292534d15fc9d6f846bb 1100w, https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/add-code-node.png?w=1650\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=cdf81034b4ed9ebf9a4d0b4e6c38e648 1650w, https://mintcdn.com/retellai/9xto-Or-KLZnnbLr/images/cf/add-code-node.png?w=2500\u0026fit=max\u0026auto=format\u0026n=9xto-Or-KLZnnbLr\u0026q=85\u0026s=c2f8a5a1382763af9203b97b5bf96aa4 2500w`})})]}),_jsx(Step,{title:`Open the code editor`,children:_jsxs(_components.p,{children:[`Select the node, then select `,_jsx(_components.strong,{children:`Open`}),` under `,_jsx(_components.strong,{children:`Code Configuration`}),`.`]})}),_jsxs(Step,{title:`Write JavaScript`,children:[_jsxs(_components.p,{children:[`Read values from `,_jsx(_components.code,{children:`dv`}),` or `,_jsx(_components.code,{children:`metadata`}),` and return a JSON-serializable value.\nObjects are the easiest return type to map into response variables.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` start`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`new`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:` Date`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`dv`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`appointment_start`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`Number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`isNaN`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`start`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`getTime`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`())) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`valid:`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`error:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"Invalid appointment_start\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` };`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` valid:`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` appointment_label:`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` start`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`toISOString`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`]})})})]}),_jsxs(Step,{title:`Store fields as variables`,children:[_jsxs(_components.p,{children:[`Under `,_jsx(_components.strong,{children:`Store Fields as Variables`}),`, map a dynamic-variable name to a path\nin the returned value. For the example above, map `,_jsx(_components.code,{children:`appointment_is_valid`}),` to\n`,_jsx(_components.code,{children:`valid`}),` and `,_jsx(_components.code,{children:`appointment_label`}),` to `,_jsx(_components.code,{children:`appointment_label`}),`.`]}),_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`#store-response-variables`,children:`Store response variables`}),` for nested and\narray paths.`]})]}),_jsx(Step,{title:`Configure execution and transitions`,children:_jsxs(_components.p,{children:[`Set the timeout in the code editor. In `,_jsx(_components.strong,{children:`Execution mode`}),`, choose `,_jsx(_components.strong,{children:`Wait for completion`}),` if the next node needs the result, or `,_jsx(_components.strong,{children:`Run in background (async)`}),` to continue without waiting. Waiting mode also offers speech and typing-sound feedback.`]})}),_jsxs(Step,{title:`Test the code`,children:[_jsxs(_components.p,{children:[`Use `,_jsx(_components.strong,{children:`Dynamic Variables`}),` in the editor to add test values, then select\n`,_jsx(_components.strong,{children:`Run Code`}),`. The result and any `,_jsx(_components.code,{children:`console.log()`}),` output appear below the\neditor.`]}),_jsxs(_components.p,{children:[`Test values stay in the dashboard and don’t change the live agent. The\ndashboard test doesn’t populate `,_jsx(_components.code,{children:`metadata`}),`, so metadata-dependent code must\nhandle an empty object during testing.`]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`javascript-environment`,children:`JavaScript environment`}),`\n`,_jsxs(_components.p,{children:[`The code runs inside a QuickJS sandbox. Top-level `,_jsx(_components.code,{children:`await`}),` is supported.`]}),`\n`,_jsxs(Heading,{level:`3`,id:`dv-dynamic-variables`,children:[_jsx(_components.code,{children:`dv`}),`: dynamic variables`]}),`\n`,_jsxs(_components.p,{children:[`Read `,_jsx(_components.a,{href:`/build/dynamic-variables`,children:`dynamic variables`}),` as properties of `,_jsx(_components.code,{children:`dv`}),`. All\nvalues in `,_jsx(_components.code,{children:`dv`}),` are strings, including values stored by earlier nodes.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` customerName`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`dv`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`customer_name`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` orderTotal`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`Number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`dv`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`order_total`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` callerNumber`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`dv`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`user_number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`dv.user_number`}),`, not `,_jsx(_components.code,{children:`{{user_number}}`}),`, inside JavaScript. Runtime values\nsuch as `,_jsx(_components.code,{children:`call_id`}),`, `,_jsx(_components.code,{children:`chat_id`}),`, `,_jsx(_components.code,{children:`session_type`}),`, `,_jsx(_components.code,{children:`direction`}),`, `,_jsx(_components.code,{children:`user_number`}),`, and\n`,_jsx(_components.code,{children:`agent_number`}),` are available when they apply to the current session.`]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[`Dynamic variables are available through `,_jsx(_components.code,{children:`dv`}),` inside JavaScript. `,_jsx(_components.code,{children:`{{...}}`}),`\ntemplate substitution isn’t available inside code.`]})}),`\n`,_jsxs(Heading,{level:`3`,id:`metadata-call-or-chat-metadata`,children:[_jsx(_components.code,{children:`metadata`}),`: call or chat metadata`]}),`\n`,_jsxs(_components.p,{children:[`Read metadata passed when you create the `,_jsx(_components.a,{href:`/api-references/create-phone-call`,children:`phone call`}),`\nor `,_jsx(_components.a,{href:`/api-references/create-chat`,children:`chat`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` customerId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`metadata`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`customer_id`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` priority`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`metadata`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`priority_level`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Metadata values can use JSON types. Unlike values in `,_jsx(_components.code,{children:`dv`}),`, they aren’t limited\nto strings.`]}),`\n`,_jsxs(Heading,{level:`3`,id:`fetch-url-options--http-requests`,children:[_jsx(_components.code,{children:`fetch(url, options)`}),`: HTTP requests`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`fetch()`}),` supports HTTP and HTTPS URLs, request methods, string-valued headers,\nand request bodies. The returned response supports `,_jsx(_components.code,{children:`status`}),`, `,_jsx(_components.code,{children:`ok`}),`,\n`,_jsx(_components.code,{children:`statusText`}),`, `,_jsx(_components.code,{children:`url`}),`, `,_jsx(_components.code,{children:`headers.get()`}),`, `,_jsx(_components.code,{children:`text()`}),`, and `,_jsx(_components.code,{children:`json()`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` response`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.zippopotam.us/us/90210\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` (!`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`response`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`ok`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`found:`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`status:`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` response`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`status`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` };`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` location`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` response`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` found:`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` city:`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` location`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`places`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#B5CEA8`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`][`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"place name\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` state:`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` location`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`places`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#B5CEA8`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`][`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"state abbreviation\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The sandbox blocks non-HTTP protocols and selected local, private, and platform\naddresses. It doesn’t provide the complete browser Fetch API.`}),`\n`,_jsxs(_components.p,{children:[`Code node `,_jsx(_components.code,{children:`fetch()`}),` requests originate from `,_jsx(_components.code,{children:`35.166.138.221`}),`. If your public\nAPI restricts inbound traffic by IP address, allowlist `,_jsx(_components.code,{children:`35.166.138.221/32`}),`.`]}),`\n`,_jsxs(Heading,{level:`3`,id:`console-log--test-output`,children:[_jsx(_components.code,{children:`console.log()`}),`: test output`]}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`console.log()`}),` while testing. Logs appear in `,_jsx(_components.strong,{children:`Run Code`}),` results. They\naren’t added to the live code result or shown as Code node logs in call logs.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"Customer:\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`dv`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`customer_name`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`runtime-limits`,children:`Runtime limits`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Limit`}),_jsx(_components.th,{children:`Value`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Code size`}),_jsx(_components.td,{children:`20,000 characters`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Timeout`}),_jsx(_components.td,{children:`5–60 seconds; 30 seconds by default`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Result sent to the agent`}),_jsx(_components.td,{children:`15,000 characters by default`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Automatic retries`}),_jsx(_components.td,{children:`None`})]})]})]}),`\n`,_jsxs(_components.p,{children:[`The sandbox provides common JavaScript built-ins such as `,_jsx(_components.code,{children:`Array`}),`, `,_jsx(_components.code,{children:`Date`}),`,\n`,_jsx(_components.code,{children:`JSON`}),`, `,_jsx(_components.code,{children:`Map`}),`, `,_jsx(_components.code,{children:`Math`}),`, `,_jsx(_components.code,{children:`Promise`}),`, `,_jsx(_components.code,{children:`RegExp`}),`, and `,_jsx(_components.code,{children:`Set`}),`. Node.js modules, browser\nDOM APIs, `,_jsx(_components.code,{children:`require`}),`, `,_jsx(_components.code,{children:`import`}),`, and `,_jsx(_components.code,{children:`Intl`}),` aren’t available.`]}),`\n`,_jsx(Heading,{level:`2`,id:`store-response-variables`,children:`Store response variables`}),`\n`,_jsx(_components.p,{children:`Response variables copy fields from the full return value into dynamic\nvariables. For this return value:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` status:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"confirmed\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` order:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` id:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"ord_123\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` items:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [{ `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`name:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"Replacement filter\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` }]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`configure these mappings:`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Dynamic-variable name`}),_jsx(_components.th,{children:`Path to value`}),_jsx(_components.th,{children:`Stored value`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`order_status`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`status`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`confirmed`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`order_id`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`order.id`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`ord_123`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`first_item_name`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`order.items[0].name`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`Replacement filter`})})]})]})]}),`\n`,_jsxs(_components.p,{children:[`Stored values are strings. Objects and arrays are stored as JSON strings. If a\npath doesn’t exist or resolves to `,_jsx(_components.code,{children:`null`}),`, Retell skips that variable without\nfailing the execution.`]}),`\n`,_jsx(_components.p,{children:`Response-variable extraction uses the full return value, even when the result\nsent to the agent is capped at 15,000 characters.`}),`\n`,_jsx(Heading,{level:`2`,id:`control-transition-timing`,children:`Control transition timing`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Execution mode`}),` defaults to `,_jsx(_components.strong,{children:`Wait for completion`}),`. Retell waits for the code result before evaluating transitions, so returned fields are available to conditions and the next node. Choose `,_jsx(_components.strong,{children:`Run in background (async)`}),` only when later nodes can proceed before the result and response variables are available. The API represents this choice with `,_jsx(_components.code,{children:`wait_for_result`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`Waiting mode offers `,_jsx(_components.strong,{children:`Talk While Waiting`}),` and `,_jsx(_components.strong,{children:`Play typing sound`}),`. These controls are hidden in background mode. Caller interruptions can still affect speech timing.`]}),`\n`,_jsxs(_components.p,{children:[`To branch on whether code execution itself succeeded, set the API’s `,_jsx(_components.a,{href:`/build/conversation-flow/custom-function#track-execution-status-via-the-api`,children:`execution status variable`}),`, separately from response-variable extraction.`]}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.a,{href:`/build/conversation-flow/transition-condition`,children:`transition conditions`}),` that\ncheck stored result fields before the agent confirms an action succeeded.`]}),`\n`,_jsx(Heading,{level:`2`,id:`node-settings`,children:`Node settings`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Setting`}),_jsx(_components.th,{children:`Default`}),_jsx(_components.th,{children:`Behavior`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Timeout`})}),_jsx(_components.td,{children:`30 seconds`}),_jsx(_components.td,{children:`Stops execution after 5–60 seconds.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Talk While Waiting`})}),_jsx(_components.td,{children:`Off`}),_jsx(_components.td,{children:`Speaks one generated prompt or static sentence when the node starts.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Play typing sound`})}),_jsx(_components.td,{children:`Off`}),_jsxs(_components.td,{children:[`Plays a typing sound in `,_jsx(_components.strong,{children:`Wait for completion`}),` mode.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Execution mode`})}),_jsx(_components.td,{children:`Wait for completion`}),_jsxs(_components.td,{children:[`Waits for the result, or runs in the background when `,_jsx(_components.strong,{children:`Run in background (async)`}),` is selected.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Global Node`})}),_jsx(_components.td,{children:`Off`}),_jsx(_components.td,{children:`Lets other nodes jump to this node without a direct edge.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`LLM`})}),_jsx(_components.td,{children:`Flow default`}),_jsx(_components.td,{children:`Optionally uses a different model for this node’s generated speech and transitions.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Fine-tuning Examples`})}),_jsx(_components.td,{children:`None`}),_jsx(_components.td,{children:`Adds transition examples for this node.`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`use-code-node-safely`,children:`Use Code node safely`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Don’t put API keys, credentials, or sensitive tokens in code, `,_jsx(_components.code,{children:`dv`}),`, or\n`,_jsx(_components.code,{children:`metadata`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Use `,_jsx(_components.code,{children:`fetch()`}),` for low-risk HTTP reads. Put authenticated requests and\nstate-changing operations behind a custom function on your backend.`]}),`\n`,_jsx(_components.li,{children:`For critical routing, provide a safe else path. A timeout, thrown error, or\nsandbox failure doesn’t retry automatically and doesn’t extract response\nvariables.`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`faq`,children:`FAQ`}),`\n`,_jsxs(AccordionGroup,{children:[_jsx(Accordion,{title:`Can I use npm packages or browser APIs?`,id:`can-i-use-npm-packages-or-browser-apis`,children:_jsxs(_components.p,{children:[`No. The sandbox doesn’t provide `,_jsx(_components.code,{children:`require`}),`, `,_jsx(_components.code,{children:`import`}),`, Node.js modules, browser DOM APIs, or `,_jsx(_components.code,{children:`Intl`}),`. Use the available JavaScript built-ins and `,_jsx(_components.code,{children:`fetch()`}),`.`]})}),_jsx(Accordion,{title:`Can I use built-in system variables in the code?`,id:`can-i-use-built-in-system-variables-in-the-code`,children:_jsxs(_components.p,{children:[`Runtime values are available as properties of `,_jsx(_components.code,{children:`dv`}),`, including `,_jsx(_components.code,{children:`dv.call_id`}),`, `,_jsx(_components.code,{children:`dv.user_number`}),`, and `,_jsx(_components.code,{children:`dv.agent_number`}),` when they apply. Use `,_jsx(_components.code,{children:`dv.name`}),` syntax to access them. `,_jsx(_components.code,{children:`{{...}}`}),` template substitution isn’t available inside JavaScript.`]})}),_jsx(Accordion,{title:`What happens if the code times out or throws an error?`,id:`what-happens-if-the-code-times-out-or-throws-an-error`,children:_jsxs(_components.p,{children:[`Retell marks the execution as failed, doesn’t extract response variables, and doesn’t retry automatically. Use `,_jsx(_components.code,{children:`try/catch`}),` for expected errors and return a structured fallback such as `,_jsx(_components.code,{children:`{ \"ok\": false, \"error\": \"lookup failed\" }`}),`. For critical routing, configure a safe else path.`]})}),_jsx(Accordion,{title:`Why did the agent talk with Talk While Waiting off?`,id:`why-did-the-agent-talk-with-talk-while-waiting-off`,children:_jsx(_components.p,{children:`The setting suppresses the node’s entry message. If the caller speaks while the code is running, that user turn can still trigger an agent response before the code result is available. Ground any success confirmation in a stored result field instead of conversation context alone.`})}),_jsx(Accordion,{title:`Can I use async/await?`,id:`can-i-use-async-await`,children:_jsxs(_components.p,{children:[`Yes. Top-level `,_jsx(_components.code,{children:`await`}),` is supported, including for `,_jsx(_components.code,{children:`fetch()`}),` calls.`]})}),_jsx(Accordion,{title:`Is there a limit on the result size?`,id:`is-there-a-limit-on-the-result-size`,children:_jsx(_components.p,{children:`Retell sends up to 15,000 characters to the agent by default. Response-variable extraction uses the full return value before that result is capped.`})})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":"dark","config":{},"pageMetadata":{"title":"Code node: run JavaScript in a conversation flow","description":"Add a Code node to a Retell conversation flow to run JavaScript, read dynamic variables and metadata, call HTTP APIs, and store results.","keywords":["Code node","conversation flow JavaScript","JavaScript sandbox","dynamic variables","response variables"],"og:title":"Run JavaScript in a Retell conversation flow with Code node","og:description":"Use a Code node to run JavaScript, read dynamic variables and metadata, call public HTTP APIs, and route a conversation flow from structured results.","href":"/build/conversation-flow/code-node"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"When to use a Code node","slug":"when-to-use-a-code-node","depth":2,"children":[]},{"title":"Configure a Code node","slug":"configure-a-code-node","depth":2,"children":[]},{"title":"JavaScript environment","slug":"javascript-environment","depth":2,"children":[{"title":"dv: dynamic variables","slug":"dv-dynamic-variables","depth":3,"children":[]},{"title":"metadata: call or chat metadata","slug":"metadata-call-or-chat-metadata","depth":3,"children":[]},{"title":"fetch(url, options): HTTP requests","slug":"fetch-url-options--http-requests","depth":3,"children":[]},{"title":"console.log(): test output","slug":"console-log--test-output","depth":3,"children":[]},{"title":"Runtime limits","slug":"runtime-limits","depth":3,"children":[]}]},{"title":"Store response variables","slug":"store-response-variables","depth":2,"children":[]},{"title":"Control transition timing","slug":"control-transition-timing","depth":2,"children":[]},{"title":"Node settings","slug":"node-settings","depth":2,"children":[]},{"title":"Use Code node safely","slug":"use-code-node-safely","depth":2,"children":[]},{"title":"FAQ","slug":"faq","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/retellai/e3fe5c9b64f9e274/scroll-play-videos.js"],"subdomain":"retellai","siteName":"Retell AI","title":"Run JavaScript in a Retell conversation flow with Code node","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-27T22:11:51.945Z","originalFileLocation":"build/conversation-flow/code-node.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Add a Code node to a Retell conversation flow to run JavaScript, read dynamic variables and metadata, call HTTP APIs, and store results.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Retell AI\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/retellai/aRxZhiMifgkRJF_R/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/retellai/aRxZhiMifgkRJF_R/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/retellai/aRxZhiMifgkRJF_R/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/retellai/aRxZhiMifgkRJF_R/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/retellai/aRxZhiMifgkRJF_R/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/retellai/aRxZhiMifgkRJF_R/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/retellai/aRxZhiMifgkRJF_R/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/retellai/aRxZhiMifgkRJF_R/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/retellai/aRxZhiMifgkRJF_R/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Run JavaScript in a Retell conversation flow with Code node\">\u003cmeta data-mint-head property=\"og:description\" content=\"Use a Code node to run JavaScript, read dynamic variables and metadata, call public HTTP APIs, and route a conversation flow from structured results.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Retell AI\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.retellai.com/build/conversation-flow/code-node\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://retellai.mintlify.app/_mintlify/api/og/v2?division=Nodes\u0026amp;title=Code+node%3A+run+JavaScript+in+a+conversation+flow\u0026amp;description=Add+a+Code+node+to+a+Retell+conversation+flow+to+run+JavaScript%2C+read+dynamic+variables+and+metadata%2C+call+HTTP+APIs%2C+and+store+results.\u0026amp;theme=35696226f7b423b96c359dbf\u0026amp;signature=e55f297ddd0d444df502c3d29b3b0e811734c0fbc2b1a5299c66650880e566a2\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Run JavaScript in a Retell conversation flow with Code node\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Use a Code node to run JavaScript, read dynamic variables and metadata, call public HTTP APIs, and route a conversation flow from structured results.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://retellai.mintlify.app/_mintlify/api/og/v2?division=Nodes\u0026amp;title=Code+node%3A+run+JavaScript+in+a+conversation+flow\u0026amp;description=Add+a+Code+node+to+a+Retell+conversation+flow+to+run+JavaScript%2C+read+dynamic+variables+and+metadata%2C+call+HTTP+APIs%2C+and+store+results.\u0026amp;theme=35696226f7b423b96c359dbf\u0026amp;signature=e55f297ddd0d444df502c3d29b3b0e811734c0fbc2b1a5299c66650880e566a2\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/retellai/aRxZhiMifgkRJF_R/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Retell AI\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#606A78\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.retellai.com/build/conversation-flow/code-node\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/build/conversation-flow/code-node.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.retellai.com/#organization\",\"name\":\"Retell AI\",\"url\":\"https://docs.retellai.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/retellai/-E9UettTBfBiCBBS/images/docs-light.png?fit=max\u0026auto=format\u0026n=-E9UettTBfBiCBBS\u0026q=85\u0026s=64eb26a2d3cc9a67ee3ea0bfe086dd14\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.retellai.com#website\",\"name\":\"Retell AI\",\"url\":\"https://docs.retellai.com\",\"publisher\":{\"@id\":\"https://docs.retellai.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.retellai.com/build/conversation-flow/code-node#webpage\",\"url\":\"https://docs.retellai.com/build/conversation-flow/code-node\",\"name\":\"Code node: run JavaScript in a conversation flow\",\"description\":\"Add a Code node to a Retell conversation flow to run JavaScript, read dynamic variables and metadata, call HTTP APIs, and store results.\",\"dateModified\":\"2026-10-27T22:11:51.945Z\",\"isPartOf\":{\"@id\":\"https://docs.retellai.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.retellai.com/build/conversation-flow/code-node#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.retellai.com/build/conversation-flow/code-node#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Build\",\"item\":\"https://docs.retellai.com/build/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Conversation flow agents\",\"item\":\"https://docs.retellai.com/build/conversation-flow/overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Nodes\",\"item\":\"https://docs.retellai.com/build/conversation-flow/node\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Code node: run JavaScript in a conversation flow\",\"item\":\"https://docs.retellai.com/build/conversation-flow/code-node\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.retellai.com/build/conversation-flow/code-node#article\",\"headline\":\"Code node: run JavaScript in a conversation flow\",\"name\":\"Code node: run JavaScript in a conversation flow\",\"description\":\"Add a Code node to a Retell conversation flow to run JavaScript, read dynamic variables and metadata, call HTTP APIs, and store results.\",\"url\":\"https://docs.retellai.com/build/conversation-flow/code-node\",\"mainEntityOfPage\":{\"@id\":\"https://docs.retellai.com/build/conversation-flow/code-node#webpage\"},\"dateModified\":\"2026-10-27T22:11:51.945Z\",\"keywords\":\"Code node, conversation flow JavaScript, JavaScript sandbox, dynamic variables, response variables\",\"publisher\":{\"@id\":\"https://docs.retellai.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.retellai.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Retell AI\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Retell AI","nav":{"global":null,"tabs":[{"tab":"Guides","icon":"book","groups":[{"group":" ","pages":[{"title":"Introduction to Retell","href":"/general/introduction"},{"title":"Build your first phone agent in 15 minutes","href":"/get-started/quick-start"}]},{"group":"Conductor (AI Assistant)","icon":"https://mintlify.s3.us-west-1.amazonaws.com/retellai/images/conductor/conductor-icon.svg","pages":[{"title":"Retell AI Conductor overview","sidebarTitle":"Overview","href":"/conductor/overview"},{"group":"Functionality","pages":[{"title":"Build and refine agents","href":"/conductor/build-and-refine"},{"title":"Test and improve agents","href":"/conductor/test-and-improve"},{"title":"Inspect knowledge bases","href":"/conductor/knowledge-base"},{"title":"Review calls and chats","href":"/conductor/call-and-chat-history"},{"title":"Build analytics dashboards","href":"/conductor/analytics-dashboards"},{"title":"Review QA results","href":"/conductor/ai-qa"},{"title":"Review contacts","href":"/conductor/contacts"}]},{"title":"Pricing","href":"/conductor/usage-and-billing"}]},{"group":"Build","icon":"bot","pages":[{"title":"Build a Retell agent: configuration overview","href":"/build/overview"},{"title":"Single prompt vs. conversation flow","href":"/build/choose-agent-type"},{"title":"General prompting principles","href":"/build/prompt-engineering-guide"},{"group":"Single prompt agents","pages":[{"title":"Single prompt best practices","href":"/build/single-multi-prompt/write-single-prompt"},{"title":"Configure basic settings","href":"/build/single-multi-prompt/configure-basic-settings"},{"group":"Functions","pages":[{"title":"Function calling for single and multi-prompt agents","href":"/build/single-multi-prompt/function-calling"},{"title":"End call","href":"/build/single-multi-prompt/end-call"},{"title":"Transfer call tool (single \u0026 multi-prompt agents)","href":"/build/single-multi-prompt/transfer-call"},{"title":"Send SMS","href":"/build/single-multi-prompt/send-sms"},{"title":"Press digit (IVR navigation)","href":"/build/single-multi-prompt/press-digit"},{"title":"Integrate any system with custom function","href":"/build/single-multi-prompt/custom-function"},{"title":"Integration tools","href":"/build/single-multi-prompt/integration-tools"},{"title":"Code tool: run JavaScript in a Retell agent","href":"/build/single-multi-prompt/code-tool"},{"title":"Extract Dynamic Variables","href":"/build/single-multi-prompt/extract-dv"},{"title":"Agent Transfer tool: hand a call to another AI agent","href":"/build/single-multi-prompt/transfer-agent"},{"title":"MCP tools for single and multi-prompt agents","href":"/build/single-multi-prompt/mcp"}]}]},{"group":"Conversation flow agents","pages":[{"title":"Conversation flow agents: structured voice AI call control","href":"/build/conversation-flow/overview"},{"title":"Conversation flow best practices","href":"/build/conversation-flow/best-practices"},{"title":"Configure global settings","href":"/build/conversation-flow/global-setting"},{"group":"Nodes","pages":[{"title":"Nodes and edges","href":"/build/conversation-flow/node"},{"title":"Subagent node","href":"/build/conversation-flow/subagent-node"},{"title":"Conversation node","href":"/build/conversation-flow/conversation-node"},{"group":"Function Node","pages":[{"title":"Call a function from a conversation flow node","href":"/build/conversation-flow/function-node"},{"title":"Custom function in conversation flow","href":"/build/conversation-flow/custom-function"},{"title":"Integration tools in conversation flow","description":"Call HubSpot, Salesforce, Zendesk, or Cal.com tools from a Retell AI conversation flow function node, and branch transitions on what comes back.","href":"/build/conversation-flow/integration-tools"}]},{"title":"Code node: run JavaScript in a conversation flow","href":"/build/conversation-flow/code-node"},{"title":"Call transfer node in conversation flow","description":"Use a call transfer node to hand a Retell phone call off to a different number. Supports Retell and imported numbers, with optional pre-transfer messages.","href":"/build/conversation-flow/call-transfer-node"},{"title":"Press Digit Node","href":"/build/conversation-flow/press-digit-node"},{"title":"End node","href":"/build/conversation-flow/end-node"},{"title":"Logic Split Node","href":"/build/conversation-flow/logic-split-node"},{"title":"SMS Node","href":"/build/conversation-flow/sms-node"},{"title":"Extract Dynamic Variable Node","href":"/build/conversation-flow/extract-dv-node"},{"title":"Agent Transfer Node","href":"/build/conversation-flow/transfer-agent-node"},{"title":"MCP node in conversation flow","href":"/build/conversation-flow/mcp-node"}]},{"title":"Transition conditions","href":"/build/conversation-flow/transition-condition"},{"title":"Reusable subflows for conversation flow agents","href":"/build/conversation-flow/components"},{"title":"Flex Mode: dynamic conversation flow execution","href":"/build/conversation-flow/flex-mode"},{"group":"Advanced features","pages":[{"title":"Global Node","href":"/build/conversation-flow/global-node"},{"title":"Finetune Examples","href":"/build/conversation-flow/finetune-examples"}]},{"title":"Debug guide","href":"/build/conversation-flow/debug-guide"}]},{"group":"Multi-prompt agents (legacy)","pages":[{"title":"Multi-prompt agents","href":"/build/single-multi-prompt/write-multi-prompt"}]},{"title":"Create chat agent","href":"/build/create-chat-agent"},{"title":"Agent workflow","href":"/agent/agent-workflow"},{"title":"Set language for your agent","href":"/agent/language"},{"title":"Configure a multilingual agent","href":"/agent/multilingual"},{"title":"Supported languages by provider","href":"/build/language-support"},{"group":"Understand user speech better","pages":[{"title":"Speech recognition providers","href":"/build/asr-providers"},{"title":"Transcription modes","href":"/build/transcription-mode"},{"title":"Handle background speech \u0026 noise","href":"/build/handle-background-noise"}]},{"group":"Generate better responses from LLM","pages":[{"title":"Agent Handbook","href":"/build/agent-handbook"},{"title":"Conversational Mode","href":"/build/conversational-mode"},{"title":"Pronunciation examples","href":"/build/prompt-situation-guide"},{"title":"LLM settings","href":"/build/llm-options"},{"title":"GPT-Live voice model","href":"/build/gpt-live"}]},{"group":"Customize the synthesized speech","pages":[{"title":"Choose a custom voice","href":"/build/voice"},{"title":"Platform voices","href":"/build/platform-voices"},{"title":"Expressive Mode: add emotion and emphasis to agent speech","href":"/build/expressive-mode"},{"title":"Add custom pronunciation","href":"/build/add-pronunciation"},{"title":"Make the agent stay silent","href":"/build/no-response"},{"title":"Speech controls","href":"/build/speech-controls"},{"title":"Set up TTS fallback","href":"/build/tts-fallback"}]},{"group":"Integrate telephony features","pages":[{"title":"Handle voicemail and IVR","href":"/build/handle-voicemail"},{"title":"Capture DTMF input from user","href":"/build/user-dtmf"},{"title":"Set \u0026 parse custom SIP headers","href":"/build/telephony/sip-headers"}]},{"group":"Provide context to the agent","pages":[{"title":"Knowledge base setup and retrieval tuning","href":"/build/knowledge-base"},{"title":"Dynamic variables","href":"/build/dynamic-variables"}]},{"title":"Guardrails","href":"/build/guardrails"},{"title":"Do-not-call requests","href":"/build/do-not-call"}]},{"group":"Test","icon":"flask-conical","pages":[{"title":"Testing overview","href":"/test/test-overview"},{"group":"LLM Playground","pages":[{"title":"Manually test your agent","href":"/test/llm-playground"},{"title":"Debug your agent response","href":"/test/llm-playground-debug"}]},{"group":"LLM Simulation Testing","pages":[{"title":"Automatically test your agent","href":"/test/llm-simulation-testing"},{"title":"Batch test your agent","href":"/test/batch-test-simulation"}]},{"group":"Audio Testing","pages":[{"title":"Web call testing","href":"/test/test-web"},{"title":"Phone call testing","href":"/test/test-phone"}]},{"title":"Testing with Conductor","icon":"https://mintlify.s3.us-west-1.amazonaws.com/retellai/images/conductor/conductor-icon.svg","href":"/test/testing-with-conductor"},{"title":"Testing pricing","href":"/test/testing-pricing"}]},{"group":"Deploy","icon":"phone","pages":[{"title":"Purchase phone number","href":"/deploy/purchase-number"},{"title":"A/B Testing","href":"/deploy/ab-testing"},{"group":"Connect to custom telephony providers via SIP","pages":[{"title":"Connect Retell voice agents to custom telephony","href":"/deploy/custom-telephony"},{"group":"Connect via SIP trunking","pages":[{"title":"Connect a Twilio number to Retell with elastic SIP trunking","sidebarTitle":"Twilio","href":"/deploy/twilio"},{"title":"Telnyx","href":"/deploy/telnyx"},{"title":"Vonage","href":"/deploy/vonage"}]},{"group":"Connect to CCaaS","pages":[{"title":"Avaya","href":"/deploy/avaya"},{"title":"Connect Genesys Cloud to Retell","href":"/deploy/genesys"},{"title":"Connect Five9 to Retell","href":"/deploy/five9"},{"title":"Amazon Connect","href":"/deploy/amazon-connect"}]}]},{"group":"Make \u0026 receive phone calls","pages":[{"title":"Make outbound calls","href":"/deploy/outbound-call"},{"group":"Inbound calls","pages":[{"title":"Receive calls","href":"/deploy/inbound-call"},{"title":"Inbound call \u0026 SMS webhook","href":"/features/inbound-call-webhook"}]},{"title":"International calling","href":"/deploy/international-call"}]},{"title":"Implement chat with create chat completion","href":"/deploy/create-chat-completion"},{"title":"Website widget","href":"/deploy/chat-widget"},{"group":"Send \u0026 receive SMS","pages":[{"title":"Enable SMS","href":"/deploy/enable-sms"},{"title":"SMS campaign application","href":"/deploy/sms-campaign-application"}]},{"title":"Agent versions and tags","href":"/agent/version"},{"title":"Compare agent versions","href":"/agent/version-comparison"},{"title":"Create and schedule batch calls","href":"/deploy/make-batch-call"},{"group":"Dialer","pages":[{"title":"Outbound call campaigns","sidebarTitle":"Overview","href":"/dialer/overview"},{"title":"Choose contacts","href":"/dialer/contacts"},{"title":"Compliance checks","href":"/dialer/compliance-checks"},{"title":"Build a sequence","href":"/dialer/sequences"},{"title":"Caller ID and pacing","href":"/dialer/phone-numbers"}]},{"group":"Increase call pickup rate","pages":[{"title":"Spam likely overview","href":"/build/telephony/call_efficiency_overview"},{"title":"Add a business profile","href":"/build/telephony/business-profile"},{"title":"Apply for verified phone number","href":"/build/telephony/verified-phone"},{"title":"Apply for branded call","href":"/build/telephony/branded-call"},{"title":"Handle application rejection","href":"/build/telephony/branded-call-rejection"},{"title":"Stop caller ID service","href":"/build/telephony/delete-service"}]},{"title":"Make a web call","href":"/deploy/web-call"},{"title":"Web calls in native apps","href":"/deploy/native-web-call"},{"title":"Understand concurrency \u0026 limits","href":"/deploy/concurrency"}]},{"group":"Data","icon":"database","pages":[{"title":"Call \u0026 chat history","href":"/features/session-history"},{"title":"Contacts","href":"/features/contacts"},{"title":"Contact memory","href":"/features/contact-memory"}]},{"group":"Monitor","icon":"square-activity","pages":[{"title":"Monitor live calls","href":"/features/live-monitoring"},{"title":"Analytics dashboard","href":"/features/analytics-dashboard"},{"title":"Alert rules for call and chat metrics","href":"/features/alerting-overview"},{"group":"Register \u0026 handle webhooks","pages":[{"group":"Call Event Webhook","pages":[{"title":"Retell webhooks overview","href":"/features/webhook-overview"},{"title":"Register and set up a Retell webhook","href":"/features/register-webhook"}]},{"title":"Secure the webhook","href":"/features/secure-webhook"}]},{"group":"Post Call Extraction","pages":[{"title":"Post Call Extraction overview and categories","href":"/features/post-call-analysis-overview"},{"title":"Define the information you want to extract","href":"/features/post-call-analysis-create"},{"title":"Consume the analysis data","href":"/features/post-call-analysis-consumption"},{"title":"Rerun Post Call/Chat Extraction","href":"/features/rerun-call-analysis"}]},{"group":"AI Quality Assurance","pages":[{"title":"Automatically evaluate call quality with AI QA","sidebarTitle":"AI Quality Assurance","href":"/ai-qa/overview"},{"group":"Create QA","pages":[{"title":"Access AI QA","href":"/ai-qa/get-started"},{"title":"Define a QA cohort","href":"/ai-qa/create-cohort"},{"title":"Define resolution criteria","href":"/ai-qa/define-resolution-criteria"}]},{"title":"View QA results","href":"/ai-qa/view-qa-results"},{"title":"AI QA metrics","href":"/ai-qa/terminologies"},{"title":"Address metric issues","href":"/ai-qa/address-metric-issues"}]}]},{"group":"Reliability \u0026 Debugging","icon":"bug","pages":[{"title":"Reliability Overview","href":"/reliability/reliability-overview"},{"group":"Latency","pages":[{"title":"Check estimated latency","href":"/reliability/check-estimated-latency"},{"title":"Check actual latency","href":"/reliability/check-actual-latency"},{"title":"Troubleshoot high latency","href":"/reliability/troubleshoot-latency"}]},{"group":"Fix agent behaviors","pages":[{"title":"Transcription accuracy","href":"/reliability/wrong-transcript"},{"title":"Debug wrong response","href":"/reliability/wrong-response"}]},{"group":"Debug phone call issues","pages":[{"title":"Debug call transfer failure","href":"/reliability/call-performance"},{"title":"Debug call disconnection","href":"/reliability/debug-call-disconnect"},{"title":"Debug outbound connection issues","href":"/reliability/debug-outbound-call"},{"title":"Debug SIP calls using PCAP file","href":"/reliability/debug-calls-pcap"}]},{"title":"Agent paused or banned","href":"/reliability/agent-paused"},{"title":"Prevent abuse","href":"/reliability/prevent-abuse"},{"title":"Fraud Protection","href":"/reliability/fraud-protection"}]},{"group":"Accounts and Workspace","icon":"circle-user-round","pages":[{"title":"Create and manage Retell workspaces","href":"/accounts/workspace"},{"title":"Manage your Retell AI account","href":"/accounts/account"},{"title":"Use your business email","href":"/accounts/business-email"},{"title":"Access Control","href":"/accounts/access-control"},{"title":"KYC Verification","href":"/accounts/kyc"},{"group":"Billing","pages":[{"title":"Retell AI billing: credits, auto recharge, and invoices","href":"/accounts/billing"},{"title":"Exceptions to Our Per-Minute Pricing","href":"/accounts/billing-exceptions"},{"title":"Add payment methods","href":"/accounts/add-payment"},{"title":"Handle failed payments","href":"/accounts/fail-payment"}]},{"group":"Keys","pages":[{"title":"API Key Overview","href":"/accounts/api-keys-overview"},{"title":"Manage API keys and permission scopes","href":"/accounts/manage-api-keys"},{"title":"Public keys","href":"/accounts/public-keys"}]},{"group":"Privacy and Compliance","pages":[{"title":"Data Storage Settings","href":"/accounts/privacy-disable"},{"title":"Data Retention Policy","href":"/accounts/data-retention"},{"title":"Opt in to secure URL","href":"/accounts/signed-secure-url"},{"title":"Security and compliance","href":"/general/compliance"}]}]},{"group":"Integrations","icon":"unplug","pages":[{"title":"Connect CRMs, calendars, and knowledge sources to Retell","sidebarTitle":"Integrations overview","href":"/integrations/overview"},{"group":"CRM","pages":[{"title":"CRM integrations","href":"/integrations/crm-overview"},{"title":"CRM data mappings","href":"/integrations/crm-mappings"},{"group":"HubSpot","pages":[{"title":"Connect HubSpot","sidebarTitle":"Connect","href":"/integrations/hubspot"},{"title":"HubSpot contact sync","sidebarTitle":"Contact sync","href":"/integrations/hubspot-contact-sync"},{"title":"HubSpot agent functions","sidebarTitle":"Agent functions","href":"/integrations/hubspot-functions"}]},{"group":"Salesforce","pages":[{"title":"Connect Salesforce","sidebarTitle":"Connect","href":"/integrations/salesforce"},{"title":"Salesforce contact sync","sidebarTitle":"Contact sync","href":"/integrations/salesforce-contact-sync"},{"title":"Salesforce agent functions","sidebarTitle":"Agent functions","href":"/integrations/salesforce-functions"}]},{"group":"Microsoft Dynamics 365","pages":[{"title":"Connect Dynamics 365","sidebarTitle":"Connect","href":"/integrations/microsoft-dynamics"},{"title":"Dynamics 365 contact sync","sidebarTitle":"Contact sync","href":"/integrations/microsoft-dynamics-contact-sync"},{"title":"Dynamics 365 agent functions","sidebarTitle":"Agent functions","href":"/integrations/microsoft-dynamics-functions"}]},{"group":"GoHighLevel","pages":[{"title":"Connect GoHighLevel","sidebarTitle":"Connect","href":"/integrations/gohighlevel"},{"title":"GoHighLevel contact sync","sidebarTitle":"Contact sync","href":"/integrations/gohighlevel-contact-sync"},{"title":"GoHighLevel agent functions","sidebarTitle":"Agent functions","href":"/integrations/gohighlevel-functions"}]},{"group":"Zoho CRM","pages":[{"title":"Connect Zoho CRM","sidebarTitle":"Connect","href":"/integrations/zoho"},{"title":"Zoho contact sync","sidebarTitle":"Contact sync","href":"/integrations/zoho-contact-sync"},{"title":"Zoho agent functions","sidebarTitle":"Agent functions","href":"/integrations/zoho-functions"}]}]},{"group":"Helpdesk","pages":[{"group":"Zendesk","pages":[{"title":"Connect Zendesk","sidebarTitle":"Connect","href":"/integrations/zendesk"},{"title":"Zendesk agent functions","sidebarTitle":"Agent functions","href":"/integrations/zendesk-functions"}]}]},{"group":"Knowledge Base","pages":[{"group":"Google Drive","pages":[{"title":"Connect Google Drive","sidebarTitle":"Connect","href":"/integrations/google-drive"},{"title":"Google Drive knowledge base sync","sidebarTitle":"Knowledge base sync","href":"/integrations/google-drive-knowledge-base"}]},{"group":"Microsoft OneDrive","pages":[{"title":"Connect OneDrive","sidebarTitle":"Connect","href":"/integrations/microsoft-onedrive"},{"title":"OneDrive knowledge base sync","sidebarTitle":"Knowledge base sync","href":"/integrations/microsoft-onedrive-knowledge-base"}]},{"group":"Notion","pages":[{"title":"Connect Notion","sidebarTitle":"Connect","href":"/integrations/notion"},{"title":"Notion knowledge base sync","sidebarTitle":"Knowledge base sync","href":"/integrations/notion-knowledge-base"}]}]},{"group":"Calendar","pages":[{"group":"GoHighLevel","pages":[{"title":"GoHighLevel agent functions","sidebarTitle":"Agent functions","href":"/integrations/gohighlevel-functions"}]},{"group":"Calendly","pages":[{"title":"Connect Calendly","sidebarTitle":"Connect","href":"/integrations/calendly"},{"title":"Calendly agent functions","sidebarTitle":"Agent functions","href":"/integrations/calendly-functions"}]},{"group":"Cal.com","pages":[{"title":"Connect Cal.com","sidebarTitle":"Connect","href":"/integrations/cal-com"},{"title":"Cal.com agent functions","sidebarTitle":"Agent functions","href":"/integrations/cal-com-functions"}]}]}]},{"group":"Marketplace","icon":"store","pages":[{"title":"Trigger Retell calls from HubSpot workflows","href":"/integrations/hubspot-marketplace"},{"title":"Trigger Retell calls from Zoho CRM workflows","href":"/integrations/zoho-marketplace"},{"title":"Trigger Retell calls from Slack","href":"/integrations/slack-marketplace"},{"title":"Trigger Retell calls from Notion","href":"/integrations/notion-marketplace"},{"title":"Trigger Retell calls from Google Sheets","href":"/integrations/google-sheets-marketplace"}]},{"group":"Other Topics","pages":[{"group":"Custom LLM","pages":[{"title":"Custom LLM overview","href":"/integrate-llm/overview"},{"title":"Set up a custom LLM WebSocket server for your Retell agent","href":"/integrate-llm/setup-websocket-server"},{"title":"Connect your LLM","href":"/integrate-llm/integrate-llm"},{"title":"Add function calling","href":"/integrate-llm/integrate-function-calling"},{"title":"Troubleshooting","href":"/integrate-llm/troubleshooting"},{"title":"Best practices","href":"/integrate-llm/llm-best-practice"}]},{"title":"Audio Basics","href":"/knowledge/audio-basics"}]}]},{"tab":"API Reference","icon":"code-xml","pages":[{"title":"API Reference","href":"/api-references/overview"}]},{"tab":"SDK","icon":"package","pages":[{"title":"SDK","href":"/get-started/sdk"}]},{"tab":"MCP","icon":"plug-zap","pages":[{"title":"MCP","href":"/get-started/mcp-server"}]},{"tab":"CLI","icon":"terminal","pages":[{"title":"CLI","href":"/get-started/cli"}]},{"tab":"Deprecations","icon":"book-alert","pages":[{"title":"Deprecations","href":"/deprecation-notice/overview"}]}]},"basePath":"","title":"Run JavaScript in a Retell conversation flow with Code node","buildId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","deploymentId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","dynamics":["07c022d89b","a74be98ba7"],"chunks":["Frame-DXXFP6nH.js","DynamicMarkdown-B54_zNBF.js","zoom-image-lightbox-BG6oD64b.js","lightbox-handle-r17bVUz3.js"]}