Rule Set

Kayalla Barreto Updated by Kayalla Barreto

Rule Set are connection points on a flow. They are conditional declarations allowing to direct your contacts using:

  • A message received or recorded
  • A contact field
  • A flow variable
  • A form field
  • An expression
  • Rule Set Anatomy

Rule Sets comprehends 5 entries that allow building a powerful conditional instruction:

  1. The type of rule set that you would like to create:

“Wait for response”: wait for a user response, after that, evaluate according to the created rules.

“Call WebHook”: call a URL, passing for the flow context*, and saves the JSON answer to refer it using the @extra variable.

“Split by flow field”: executes response rules from a value collected for a previous ruleset referred using @flow.variable[variable-name], for example, @Flow.city.

“Split by contact field”: executes response rules from a value saved on a contact field (name, phone number, etc.), referred using the @contact.variable[variable name], for example, @contact.State.

“Split by expression”: execute rulesets about the expression result, as @(REMOVE_FIRST_WORD(step.value)), that includes a function removing the first word from the last received message, representing for @step.variable.value. Expressions can include just one variable, one function or a combination of both.

“Split by message form”: executes response rules about a value split for a delimiter (a space, symbol, etc.), for example, 1 + 2 + 3 + 4 + 5 (+ is the delimiter, while 1 is the first value, 2 is the second, 3 is the third, etc.).

*Flow contact comprehends the available variables on a determined flow. These are flow variables using action sets, but you can also include associated contacts variables from a contact associated with a contact through a flow, or obtained data from an external font through a webhook.

  1. According to the selected command, this is the value that the rules are evaluated. This value, call an operator, represented for a variable or expression. The ruleset on the picture above, “if the response message ..” indicates that the operator is @step.value or a received message.
  2. Response Rules: evaluate the selected operator. Response rules are executed from left to right. The first rule that corresponds is used and not the other rules, that will be evaluated after that. RapidPro combines each word just once and just to an individual rule in the original string order.

  1. The response from your values rules will try to correspond to the operator. On the example above, we create a ruleset trying to correspond to the name of each city from Alagoas. Using the “Wait for response” ruleset the selected answer from “has any of these words”, the received answer will be located on a category called “Alagoas” if it corresponds to any listed word. This allows us to write the answer “I live in Maceió” on the category “Alagoas” because the word “Maceió” is on the rule. Notice that, a flow will always correspond at least a response rule.
  2. The category where your contacts are located with the answer corresponds to the correspondent response rule. The categories are ways where the connections can the guided to the new step.

  1. The name gave to the created flow variable is filled for a ruleset. On the example above, the ruleset will save the evaluation result for the flow variable @flow.state. The entries above result on the following conditional declaration: When somebody arrives at this point on your flow, wait for a response. If the response has any of these -. Maceió, Maragogi, Arapiraca, etc. - classify as Alagoas every response with a flow variable called ‘State’.

Active vs Passive Splitter

You can look that the dialog box from the split response set is blue, while the rest of then is grey:

Actives:

Split responses are actives. They need a contact response, with a value to be evaluated (contact response) is not initially knew.

Passives:

Passives steps don't require contacts response, because the values to be evaluated are already know. So, the contacts passed for a series of passives splits will not count as a credits relationship. The passives steps include: Calling a Webhook; Split by flow field; Split by contact field; Split by expression; Split by message form.

How did we do?

Creating a Flow in Different Languages

Response Rule

Contact