Code
Overview
The JavaScript Executable Code Component (internally identified as code) is an advanced action node designed to extend the platform's native capabilities through active programming. Its main function is to execute custom scripts in an isolated environment (sandbox), allowing complex mathematical calculations, cleaning or reformatting text strings, manipulating data arrays, and integrating with external systems.
Mandatory Development Rules: 1. External API Consumption: Whenever there is a need to make HTTP/HTTPS requests (such as methods GET, POST, PUT or DELETE) to third-party servers within the script, the use of the library Axios (natively injected into the node's global scope).
Data Persistence in the Flow: The use of the instruction
returnis strictly mandatory at the end of the script. Without the explicit return of an object or variable, the execution engine discards the processing and does not pass the calculated data on to subsequent automation blocks.
Configuration Parameters
The node's parameterization is simplified and concentrated in the direct coding window:
Code: Highlighted syntax area (syntax highlighting) where the developer or administrator types the JavaScript script block (modern ECMAScript) that will be submitted to engine compilation.
Visual Builder
The graphical interface focuses on isolation and the developer's technical autonomy within the flow builder:
Embedded Code Editor: The builder offers a clean text terminal containing line numbering and quick snippets to facilitate pasting and validation of algorithms. It dispenses with channel selectors or media files, operating purely in the system's logical core.
Payload Output Mapping: In the visual automation map, the block presents one input port and one continuous output port. When saving the structured script with the
return,
Special Operators
The logical properties of this component manage the capture of local variables and asynchronous calls:
Global Context Injection (
$data): The component's JavaScript interpreter grants full access to the object$data. This allows the code to read any variable previously stored in the flow (e.g.:$data.nome,$data.telefone, or payloads from previous question responses) directly within the script expressions.Asynchronous Resolution via Promises (
async/await): To ensure the correct processing of external requests without freezing the engine, the node is prepared to interpret asynchronous scopes. The developer can structure functions withasyncand use theawaitoperator in Axios calls, ensuring that thereturnfinal waits for the external API response.
Practical Examples
The table below demonstrates classic component application scenarios using the correct syntax with Axios and data return:
Script Objective
Configured JavaScript Code in the Builder
Platform Engine Behavior
Practical Use Case
Local String Manipulation
const nome = $data.nome; const nomeMaiusculo = nome.toUpperCase(); return { nome_formatado: nomeMaiusculo };
Captures the CRM variable, turns the letters into uppercase using native JS, and returns the new format to the flow.
Standardize lead names in the database before sending a formal email notification.
External Integration with Axios
const cep = {cep}/json/`); return { endereco: resposta.data };
Performs an external synchronous call using Axios based on the customer's ZIP code and returns the complete address object.
Locate a customer's street and neighborhood completely autonomously after they enter the ZIP code in Webchat.
Conditional Mathematical Calculation
const valorTotal = $data.total_carrinho; const desconto = valorTotal * 0.10; return { valor_desconto: desconto, total_final: valorTotal - desconto };
Performs mathematical equations in server memory and injects the two results as usable variables in the flow.
Dynamically calculate a 10% discount in the journey and pass the exact amount to the customer's payment link.
Last updated
Was this helpful?

