Use this RuleSet to evaluate a sequence of values separated by a space ( ), period (.) or plus sign (+).
As an example, you might record the birth of a child by soliciting messages in the following format:
"birth [gender]+[name]+[mother's birth year]," which could yield the result "birth f+Noel+1985".
In the case above, the term "birth" acts as a keyword trigger, initiating the flow.
To create a flow that collects and evaluates a sequence of values:
1. Click the "gear" icon and select the "Edit" option in the drop-down menu to create the "birth" keyword trigger that will direct messages to this flow.
2. Begin the flow by creating a Wait for Response RuleSet with an open-ended response rule to collect messages directed to this flow via the "birth" keyword trigger. Save the result as "Message."
Note: This split step must remain open-ended, as it will collect all messages that contain the keyword we've designated, "birth". Once we've stripped the initial message of its keyword, we can go about evaluating each field using a series of Split by Message Form RuleSets.
3a. Remove the keyword trigger to isolate the submission as the flow variable @flow.message (Split by Message Form RuleSets may only evaluated flow variables). To do so, create a RuleSet that splits the initial message by expression. In the example pictured below, we apply the @(REMOVE_FIRST_WORD()) function to the incoming message (referenced using @step.value). The resulting expression should read @(REMOVE_FIRST_WORD(step.value)).
3b. Save the resulting flow variable as "Fields" to yield only the values delimited by a plus sign. To review, the values we'll submit will follow the format [gender]+[name]+[mother's birth year]. Each bracket value is assigned its own field. Gender is the first field, name the second and mother's birth year the third.
4. Add a Split by Message Form RuleSet to evaluate gender, the first field delimited by a plus sign. Create a response rule for each gender that categorizes the short form values "m" or "f" as their long form counterparts, and save the resulting flow variable as "Gender."
5a. Add a Send an SMS response ActionSet that addresses incorrectly formatted "Gender" values and asks the contact to resubmit the message.
5b. In the example pictured below, we've formatted the error message to repeat the contact's initial message using the @flow.fields variable, so they can see how their response compares to the expected format, and ask them to resubmit.
6. Add a second Split by Message Form RuleSet to evaluate name, the second field delimited by a plus. This time, it's the name of the child. You can create an "is not empty" response rule to ensure the second field has a value, then categorize it as "Has Name" and save the resulting flow variable as "Name."
7. Add a Send an SMS response ActionSet that addresses incorrectly formatted "Name" values and asks the contact to resubmit.
8. Add a third Split by Message Form RuleSet to evaluate birth year, the third field delimited by a plus. Add a "has a number between" response rule to ensure the third field contains a valid birth year and save the resulting flow variable as "Birth Year."
9. Add a Send an SMS response ActionSet that addresses invalid "birth year" values and asks the contact to resubmit.
10. Finish the flow by adding a Send an SMS response ActionSet that confirms the message form submission by referencing the values submitted by the contact.
To the contact, a successful exchange will look like this:
The resulting flow should look similar to the example pictured below.