For the complete documentation index, see llms.txt. This page is also available as Markdown.

Dynamic Node

The Dynamic Node is used to create dynamic nodes based on some logic written in JavaScript.

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",
}

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>",
}

Last updated

Was this helpful?