Rules node is a multi-output node that allows to control the flow of the chatbot based on simple rules (for example “The topic is myTopic”, “The context variable myVar is not defined”). This node replace the Topic node that will deprecated soon.

The first rule that matches trigger the redirect of the incoming message to the related output and stops the chain of rules.

This node is useful to create loops in the flow, for example to keep asking some questions to the user until a list of needed information (context variables) are filled.

Rules can be created programmatically by an upstream Function node passing array of rules in the message payload:

msg.payload = [
  {
    type: 'hasNotVariable',
    variable: 'my_variable'
  },
  {
    type: 'catchAll'
  }
];
return msg;

Available parameters for the msg.payload

Name Type Description
rules array of [rule] The list of rules

The [rule] object

Name Type Description
type string Type of rule: inbound, outbound, isTopicEmpty, catchAll, isNotTopic, isTopic, hasNotVariable, hasVariable, isVariable, command, messageType, notMessageType, transport, anyCommand, environment
environment string Match the environment type, can be production or development. Required for type environment
transport string Match the transport type, can be facebook, telegram, slack or smooch. Required for type transport
topic string Match the rule if the flow topic matches/doesn’t match the specified topic. Required for isNotTopic and isTopic
variable string Match the rule if the context variable is defined/not defined. Required for hasVariable, hasNotVariable or isVariable
value string Match the rule the value of a variable. Required for isVariable
command string Match the input command. Required for command
messageType string Match the message type, if any. Required for messageType, notMessageType. Can be: message, command, audio, buttons, contact, document, dialog, inline-buttons, inline-query, location, photo, request, response, video