The Code integration lets advanced users run small JavaScript snippets inside automation flows or live agent actions. Use it for last-mile customization when built-in steps almost solve the workflow but you need to transform, validate, format, or calculate something first. Examples:Documentation Index
Fetch the complete documentation index at: https://docs.thoughtly.com/llms.txt
Use this file to discover all available pages before exploring further.
- Normalize phone numbers before dialing.
- Convert a webhook response into fields an agent can use.
- Calculate a lead score.
- Choose a local-presence number based on area code.
- Route by date, time window, or custom business rules.
How it works
A Code step receives prior node outputs through aninputs object. Your script returns a JSON-serializable value. That return value becomes the step output and can be mapped into later steps or agent actions.
Configuration
| Field | Required | Description |
|---|---|---|
| Code | Yes | JavaScript to execute. Must return a JSON-serializable value. |
| Timeout | No | Maximum execution time. Shorter limits apply during live calls to protect call quality. |
Use variables from prior steps
Use the data picker to insert references to previous outputs. References are inserted asinputs['nodeId'].fieldName paths.
Example:
Limits
Typical limits include:| Limit | Why it exists |
|---|---|
| Execution timeout | Prevents slow scripts from blocking workflows or live calls. |
| Memory cap | Protects platform stability. |
| Code size cap | Keeps snippets small and reviewable. |
| Console output cap | Prevents excessive logs. |
| Concurrency cap | Prevents one workspace from consuming all runner capacity. |
Blocked capabilities
The sandbox blocks risky or platform-level operations, including:- Network calls such as
fetch,XMLHttpRequest, orWebSocket - Node.js built-ins such as
requireorprocess - Code generation such as
eval,new Function, or dynamicimport() - Known sandbox escape patterns
- Obvious infinite loops
Examples
Validate an email address
Calculate a lead score
Route by area code
Best practices
- Keep scripts short and focused.
- Return structured JSON objects, not long strings.
- Use webhooks or CRM steps for external API calls.
- Test with realistic sample data before going live.
- Avoid putting secrets in code.