Dynamic Node
The Dynamic Node is used to create dynamic nodes based on some logic written in JavaScript.
This is an advanced node. You need have the knowledge of Javascript to use this node.
You need to write body of a function which takes user as parameter and returns list of nodes or actions as a response. Below is the format of function.
function(user) {
//your logic goes here
return {
nodes:[]
};
}
You need to write only body of the function. To refer to the complete user object with all of the fields please check go to this link.
the function should return nodes in required JSON format. Below is the format of json for each type of nodes. Please note that all nodes are not supported here. Below are nodes which are supported.
Add and send data
{
"node_type": "TEXT",
"txt": "<desired text>",
}
{
"node_type": "IMAGE",
"txt": <null or String>,
"img": "<url of image",
}
{
"node_type": "LINKS",
"txt": "<text message before links>",
"links": [//array of links as per the requirement. At least one obect is required in the array
{
"link_type": "EMAIL",//To show email link
"open_in_new_tab": true,
"title": "<text of button such as Email us>",
"email": "<email>"
},
{
"link_type": "PHONE",//To show click to call button
"open_in_new_tab": true,
"title": "<text of button such as Call us>",
"phone": "<phone number with ISD code"
},
{
"link_type": "WHATSAPP",//To show click to whatsapp
"open_in_new_tab": true,
"title": "<text of button such as Whatsapp us>",
"phone": "<phone number with ISD code"
},
{
"link_type": "LINK",//To show another link
"open_in_new_tab": true,//where you would like to open link on new tab on click
"title": "<text of button such as click here",
"url": "<full URL starting with https:// or http://"
},
{
"link_type": "PLAYBOOK",//To show another link
"open_in_new_tab": false,
"title": "<text of button such as click here",
"playbook": "5d78c366380d7b0c67bb6230"//playbook id
}
]
}
{
"node_type": "YOUTUBE",
"url": "<URL of youtube video such as ",
"autoplay": true,//whether you would like to autoplay video
"txt": "<desired text before the video>",
}
{
"node_type": "CAROUSEL",
"elements": [// array of card templates, at least one is required
{
"title": "<card title>",
"subtitle": "<card subtitle>",
"image_url": "<card img url>",
"buttons": [// array of links node, up to three
{
"link_type": "EMAIL",//To show email link
"open_in_new_tab": true,
"title": "<text of button such as Email us>",
"email": "<email>"
},
{
"link_type": "PHONE",//To show click to call button
"open_in_new_tab": true,
"title": "<text of button such as Call us>",
"phone": "<phone number with ISD code"
},
{
"link_type": "WHATSAPP",//To show click to whatsapp
"open_in_new_tab": true,
"title": "<text of button such as Whatsapp us>",
"phone": "<phone number with ISD code"
},
{
"link_type": "LINK",//To show another link
"open_in_new_tab": true,//where you would like to open link on new tab on click
"title": "<text of button such as click here",
"url": "<full URL starting with https:// or http://"
},
{
"link_type": "PLAYBOOK",//To show another link
"open_in_new_tab": false,
"title": "<text of button such as click here",
"actions":[],//actions to run when this button is selected. can be found on https://docs.intelliticks.com/ai-builder/nodes/additional/actions (see actions(after first json), not the action node json)
"playbook": "5d78c366380d7b0c67bb6230"//playbook id
}
]
}
]
}
{
"node_type": "GO_TO_PLAYBOOK",
"playbook_id": "5d78c366380d7b0c67bb6230"//plabook id
}
Collect User Data
{
"node_type": "QUICK_REPLY",
"actions_on_response": [],
"text": "<text before quick reply>",
"responses": [//array of responses
{
"txt": "<option 1>"
},
{
"txt": "<option 2>"
},
{
"txt": "<option 3>"
}
],
"option_display_mode": "",// one of "HORIZONTAL" "VERTICAL" "DROPDOWN"
"placeholder": "<placeholder in case of dropdown such as Type to search..>"
}
{
"node_type": "QUESTION_FORM",
"questions": [
{
"text": "<label for the field>",
"failMsg": "<Error msg when validation fails>",
"input_type": "NAME",//used when asking for name
"actions": [//array of actions to run after getting response
{
"type": "SET_NAME"//this action sets name to user's profile
}
],
"skip": false//whether user can skip this field
},
{
"text": "<label for the field>",
"failMsg": "<Error msg when validation fails>",
"input_type": "REGEX",//used to take single line input with regex based validation
"actions": [//array of actions to run after getting response
],
"skip": false,//whether user can skip this field
"regex_pattern": "^[a-zA-Z ]*$"//regex to validat the input
},
{
"text": "<label for the field>",
"failMsg": "<Error msg when email validation fails>",
"input_type": "EMAIL",//used to take email as input
"actions": [//array of actions to run after getting response
{
"type": "SET_EMAIL"//action to set email to user's profile
}
]
},
{
"text": "<label for the field>",
"failMsg": "<Error msg when email validation fails>",
"input_type": "PHONE",//used to take phone as input
"actions": [//array of actions to run after getting response
{
"type": "SET_PHONE"//action to set phone to user's profile
}
]
},
{
"text": "<label for the field>",
"failMsg": "<Error msg when email validation fails>",
"input_type": "TEXT",//used to take input using multi-line text area
"actions": []//array of actions to run after getting response
}
],
"txt_b4_questions": "<message before the form or null>",
"txt_after_questions": "<message after the form or null>",
}
{
"node_type": "DATEPICKER",
"actions_on_response": [],
"text": "<text before asking date",
"allow_old_dates": true//whether to allow selecting past dates
}
{
"node_type": "RATING",
"txt": "<message before rating>"
}
{
"node_type": "SLIDER",
"actions_on_response": [],
"txt": "<text before slider>",
"unit": "<units to show for slider input such as kg, years etc.",
"sliderType": "RANGE",//SINGLE(for single input) RANGE(for selecting range)
"defaultMin": 30,//default value shown(default min value in case of range slider)
"defaultMax": 60,//default max value in case of range slider.
"min": 10,//min allowed value
"max": 300,//max allowed value
"step": 1,//interval between each value user can select.
"title": "<title to show above the slider>"
}
{
"node_type": "TEXT_RESPONSE",
"actions_on_response": [],
"text": "<text for the question>"
}
{
"node_type": "MULTI_SELECTION_REPLY",
"text": "wegewgew",
"skip": false,//whether user can skip without selecting anything
"responses": [
{
"txt": "gewg"
},
{
"txt": "ggg"
}
]
}
Last updated