Skip to main content

Overview

The Custom Code Node lets you run JavaScript within your conversations for advanced data processing, calculations, API calls, and business logic—all securely on Bland’s infrastructure, with fast performance and no need for outside services. Prerequisites:
  • A Bland Enterprise account with Custom Code Node access (reach out to Bland support to get access)
  • A Bland Pathway configured for your use case
  • Basic knowledge of JavaScript programming
  • Understanding of JSON data structures

Overall Call Flow

The custom code node follows this execution flow:
  1. Agent enters the custom code node during pathway execution
  2. Variables from the conversation are extracted and made available to your code
  3. Your custom JavaScript code executes with access to these variables
  4. The code processes the data and returns a JSON response
  5. Returned data becomes available as variables in subsequent pathway nodes
  6. Agent continues to the next node in the pathway

The Custom Code Node

Node Configuration

When you add a Custom Code Node to your pathway, you’ll see a comprehensive interface for configuring your code execution: Custom Code Node Configuration

Reference Variables

The first section allows you to define variables to be used within your custom code execution. These variables can be of two types:
  • Static Variables: Constants that are defined in this section, and will be the same throughout all your calls.
  • Dynamic Variables: Variables that are defined based on variables extracted previously in the pathway.

Picking pathway variables

The Value field suggests the variables your pathway produces, so you don’t have to hand-type {{variable_name}} references. Suggestions are grouped by the node that produces them and include built-in call variables such as {{from}}, {{to}}, and {{call_id}}. Selecting a suggestion inserts the {{variable_name}} reference and fills in a matching code-side name for you. Only variables from nodes that can run before the custom code node appear in the list. The field still accepts free text, so you can type a literal value or reference a variable the picker can’t know ahead of time, such as a value passed in request_data when the call starts.
A {{variable_name}} reference that doesn’t resolve during a call is passed to your code as the literal string, not as null. Picking from the suggestions instead of hand-typing avoids typos that silently pass truthiness checks in your code.
Below is an example of both: Custom Code Node Variables
Using dynamic variables allows you to build flexible custom code nodes that adapt to each user’s unique information.
For instance, in the example shown, any caller under 25 will have their request automatically rejected.
To easily generate extraction code for your pathway variables, you can click the “Generate variable extraction code” button, and it will automatically insert into the editor. In the example above, the following will be inserted:

Code Editor

The main code editor provides:
  • Syntax highlighting for JavaScript
  • Auto-completion and IntelliSense
  • Error detection and debugging support
  • Code formatting and indentation

Test Mode

The Custom Code Node includes a robust testing environment: Test Mode Toggle: Switch between normal editing and test mode
  • Normal Mode: Configure actual variables that will be extracted from conversations
  • Test Mode: Set mock values for testing your code logic Mock Test Variables: In test mode, you can provide sample data to test your code: Run Test Button: Execute your code with the mock data to see returned variables immediately
Mock values are sent to your code literally, with no variable lookup. A mistyped {{variable_name}} reference that fails on a live call can still pass in test mode.

Response Handling

The response from your custom code becomes available as variables in subsequent pathway nodes. Your code must return a JSON response using Response.json(). Example response:
These returned values (processed_total, discount_applied, final_price, customer_tier) become available as variables you can reference in later nodes using {{processed_total}}, {{discount_applied}}, etc.

For additional questions or advanced use cases, please reach out to support@bland.ai or through our support channels.

Docs for agents: llms.txt