How to create a new function?#

You can add a new function to write your custom logic in code in the code section of the studio. To execute these functions in a flow, you can attach function action node.

Format of cloud functions

return new Promise(resolve => {
// Your logic goes here

Useful args you can access in code#

argdata typeUse
data.variables.<variable_name>Key : String, Value: anyTo access any bot variable in code.
data.channelStringTo access channel names like whatsapp, yellowmessenger, facebook etc
data.profileObjectContains user profile values like name, number, email, city , country, language
data.senderStringUser ID
data.botStringBot ID
data.messageStringTo access Last/latest user message in the conversation
data.event.<event_name>ObjectTo access events in code
ymLib.args.apiResponseanyTo access API response in API transformation function
ymLib.args.loggerObjectCan be used to add logs
context.historyObjectContains history of nodes visited by user
prediction.intentsTo get Intents predicted from user message
prediction.entitiesTo get entities predicted from user message