What scripts can do
- Access the current customerβs phone number and session variables as input
- Fetch any external HTTP API and parse the response
- Return structured output data and an outcome string
- Map output fields to session variables for use in downstream nodes
Script structure
Every script exports a singleonExecute function:
Parameters
input
Contains the current session context and output from previous script nodes:
| Field | Description |
|---|---|
sessionContext.business.id | Your Connectly business ID. |
sessionContext.customer.phoneNumber | The current customerβs phone number. |
sessionContext.variables | All session variables set so far in the flow. |
SCRIPT_NODE1.outcome | The outcome returned by a previous script node named SCRIPT_NODE1. |
SCRIPT_NODE1.data | The data object returned by a previous script node. |
config
Contains secrets configured for the script node:
Return value
Scripts must return a tuple[data, outcome]:
| Return value | Type | Description |
|---|---|---|
data | object | JSON object β any fields you want to save to session variables. |
outcome | string | A string that maps to an outgoing edge in the flow. Each possible outcome must be configured as an edge in the Campaign Builder. There is no default or fallback outcome. |
Mapping output to session variables
After a script node runs, you can map its output fields to session variables for use by downstream nodes:| Raw param | Maps to session variable |
|---|---|
outcome | Any variable you configure (e.g. VARX) |
data | Any variable (receives the whole data object) |
data.FOO.1 | A specific nested field (e.g. VAR_FOO1) |
