The Code action provides you with a method for scripting advanced functionality within a Flow step, using Lua .

For more information on Flow Builder coding methods, please see the Advanced Methods for Flow Builder.

The following is a list of standard LUA functions.

Get the user's message

Context.get("currentMessage")

📘

Description

This gets the last message sent by the user. By default this is saved as a String.

Get the user's ID

Context.get("userId")

For WhatsApp, the userID is the user's phone number.

Save a variable

Context.set("variableName", value)

📘

Description

This variable is saved in the context of the Flow, for the duration of a session. This session is defined in the settings of every Flow — by default, this is set for 12 hours.

Evaluate user input

Input contains keywords

Input.match('contains', 'keyword1|keyword2', Context.get('currentMessage'), {})

Input is exactly

Input.match('isEqualTo', 'value', Context.get('currentMessage'), {})

Input matches a regex

Input.match('regex', 'regex expression here', Context.get('currentMessage'), {})

Invoke a webhook

Invoke.webhook("url", "method", "body", "headers")

Invoke a cloud function

Invoke.cloudFunction("name", "keyNames", "params", "outputAttr", "conf")

📘

Description

Currently support only Lambdas hosted in Yalo's AWS account.

Go to a step

Flow.branch(stepID)

📘

Description

Once there's a valid Go To action, the Flow will branch to a new step and none of the actions below in that step will execute. Logic now moves to the new step.

Check if a variable exists

Context.check("variableName")

This will return a boolean (TRUE or FALSE) if the variable exists in the context.

Print a debug message

Debug.print("message")

This behaves similar to sending a Message of type text to a user, but the intention is for you to use this in the Actions section to debug when something is not behaving as expected.

Clean a string to remove accents

cleanText("value")

This removes any accents in the input value. E.g. "cómo estás" → "como estas"

( + match case)

Convert a string to only numbers

onlyNumbers("value")

-- casting
tonumber(83)

Extracts only the numbers in a string. "My weight is 84.2 Kgs" → 84.2