Custom Code Nodes
Custom Code Nodes allow you to execute JavaScript code within your conversation pathways. Use them to call external APIs, perform calculations, transform data, and implement complex business logic.Overview
Custom Code Nodes let you:- Call external APIs and services
- Perform complex calculations
- Transform and validate data
- Implement custom business logic
- Integrate with internal systems
Creating a Code Node
In the Pathway Editor
1
Add Code Node
Drag a Code Node onto the pathway canvas
2
Write Code
Enter your JavaScript code in the editor
3
Configure Inputs/Outputs
Define what data flows in and out
4
Connect
Wire the node into your pathway
Via API
Code Environment
Available Objects
| Object | Description |
|---|---|
inputs | Data passed to the node |
context | Conversation context |
caller | Caller information |
memory | Persistent memory |
secrets | Encrypted secrets |
inputs
Data from previous nodes or collected during conversation:context
Current conversation state:caller
Information about the caller:memory
Read and write persistent memory:secrets
Access encrypted secrets (API keys, etc.):Making HTTP Requests
Use the built-infetch function:
Return Values
Return an object with output values:Error Handling
Handle errors gracefully:Common Patterns
API Integration
Data Transformation
Business Logic
CRM Lookup
Limitations
| Limit | Value |
|---|---|
| Execution timeout | 10 seconds |
| Memory (RAM) | 128 MB |
| Outbound requests | 5 concurrent |
| Code size | 50 KB |
Restricted Features
The following are not available for security:eval()andFunction()- File system access
- Process/OS access
- require/import (use built-in modules)
Debugging
Console Logging
Test Mode
Test your code in the pathway editor:- Click Test on the code node
- Provide sample inputs
- View output and logs
Sandbox Execution
Code runs in a secure sandbox:- Isolated from other customers
- No access to system resources
- Network requests logged and monitored
Secrets Management
Store sensitive values securely:1
Navigate to Secrets
Go to Settings → Secrets
2
Add Secret
Click Add Secret and enter name and value
3
Use in Code
Access via
secrets.SECRET_NAME- Encrypted at rest
- Never exposed in logs
- Scoped to workspace
Best Practices
Handle failures gracefully
Handle failures gracefully
Always have a fallback for when external APIs fail.
Keep code focused
Keep code focused
One node should do one thing well.
Use timeouts
Use timeouts
Set reasonable timeouts for external calls.
Log judiciously
Log judiciously
Log enough to debug, but don’t log sensitive data.
Test thoroughly
Test thoroughly
Test with various inputs including edge cases.
Next Steps
- Scheduling Nodes — Time-based actions
- Pathways — Conversation flow design
- Webhooks — External event handling