chatleadr Docs

Variables in a Workflow

A variable is a value one node collects and a later node uses: written as {{variable}} in any text field, chosen in a Decision, and read as a property on flow inside a Function node.

Stop a Variable Printing as Curly Braces#

A reference that matches nothing is sent to the visitor as its own text. {{Missing.value}} arrives in the chat as the characters {{Missing.value}}. Three things produce it, and the repair differs:

CauseHow to recognise itThe repair
The name was typed by hand and does not matchIt has never worked, on any runDelete it and insert the variable from the picker
The producing node is not upstream of this oneThe picker does not offer it hereProduce the value before the paths split, or move the node
The producing node was renamedIt worked until the rename, and the braces hold the old nameUpdate the reference, or rename the node back
Scope runs forwards along the connections, and only forwards Ask for details writes .email, .phone Is it a big order? reads .email ✓ Send the quote reads .email ✓ true Book a call writes .slot false Confirm the quote reads .slot ✗ No forward path from “Book a call” to a node on the other branch, so {{Book_a_call.slot}} is not offered in the picker and stays literal text if typed. Always in scope, anywhere in the workflow channel · chatId · the workflow’s parameters · the Start node’s initialisation variables
A variable exists only on the paths that lead away from the node producing it. The two branches of a Decision can never read each other.

A node reads only what the nodes before it produced. A Form node's fields are not available to a Message node sitting beside it on the canvas; they are available to every node you reach by following the connections forward from that Form. The picker offers exactly that set, and a text field accepts anything you type, so insert from the picker where you can.

Two consequences follow:

  • Branches do not share. A node on a Decision's true path cannot read a value produced on the false path. Produce it before the Decision instead.
  • Reordering changes scope. Moving a node above the node it reads from removes the value without changing the text that refers to it.

Rename a Node Before You Build on It#

Everything a node produces is namespaced under that node's label, stripped to letters, numbers and underscores. A Form node labelled Ask for details with a field id of email writes Ask_for_details.email.

What each node produces:

NodeProduces
Form<Label>.<fieldId> for each field. A number field adds <Label>.<fieldId>_formatted, carrying the value with its prefix applied
Delay set to User Response<Label>.userResponse, plus <Label>.userFile when the reply carried an attachment
API Request<Label>.status_code, plus one variable per mapped response field or header. Map nothing and the whole body lands in <Label>.apiResponse, which a message would send to the visitor in full
Webhook<Label>.<name> for each mapped body path or header, or <Label>.payload with nothing mapped
Function<Label>.<name> for each setExport("name", value) call

Set the Lead Fields so the Lead Arrives Filled In#

Your lead destinations read three bare names: name, email and phone. A value namespaced under a node label, such as Ask_for_details.email, does not match email. On a Form node the Field ID sets the name rather than the label the visitor reads, so a field labelled "Your email address" fills the Email column only when its id is email.

A field the workflow never sets is sent to your lead integrations as the text Not provided. On the leads table the row saves with the name Unknown and the address unknown@example.com. The lead still sends either way. Saving a workflow that dispatches a lead without setting those fields opens a dialog reading "Saved, but this lead will arrive empty", and it names them. See how a lead is captured.

What Every Node Can Read#

Four sources are in scope everywhere, whatever the node's position:

VariableContentsWhere you set it
channelweb, whatsapp or instagram. A widget on a WordPress site reports webNowhere. Chatleadr fills it
chatIdThe conversation this run belongs toNowhere. Chatleadr fills it
Workflow variablesWhat the assistant collected from the visitor before the workflow startedThe workflow's settings, on the bot's Workflows tab
Initialisation variablesA fixed value the run begins withThe Start node's panel

Give the Workflow a Value the Visitor Will Never Say#

An account identifier, a default region, the name of the price list to quote from: none of these come out of a conversation. Open the Start node and under Custom Initialization Variables add a name and the value to hold. A variable declared there is readable from every node, including one on a branch nothing earlier could have filled.

The value is a literal you type, or one of three macros Chatleadr fills in when the run starts:

MacroHolds
$TIMESTAMPThe moment the run started, in milliseconds
$FLOW_IDThe workflow being run
$EXECUTION_IDThis one run, for matching a lead against an execution log

Use a File a Visitor Uploaded#

A Form field of type file holds an object rather than a plain value, so the bare variable in a message sends the object. Write .referenceUrl for the link to the stored file and .originalName for the filename the visitor uploaded. The same applies to any variable whose name contains file, image, document, pdf, attachment or avatar.

Read State Inside a Function Node#

A Function node receives everything the workflow holds as an object called flow, with Ask_for_details.email readable as flow.Ask_for_details.email. It is a snapshot: values leave the node only through setExport. See custom code in a workflow.

Common Questions#

Why Is My Variable Not in the Picker?#

The node producing it is not upstream of the node you have open. Follow the connections: there has to be an unbroken path forward from the producing node to the one reading it.

Do Variables Survive a Form or a Delay?#

Yes. State is stored with the paused run and restored when the visitor answers, so everything collected before the pause is still readable after it.

Are Lead Fields Automatically Available?#

No, and this is deliberate. Lead fields are a contract the workflow has to fulfil, not values the bot supplies. A lead field appears in the picker once something in the workflow sets it. See how a lead is captured.