Split by Flow Result

This Split Action is designed to assess a series of values separated by a space ( ), period (.), or plus sign (+).

For instance, to record a child’s birth, you might request messages in the format: “birth [gender]+[name]+[mother’s birth year]”. A contact might then respond with: “birth f+Noel+1985”.

In this scenario, the word “birth” functions as a keyword trigger to launch the flow.

The example below illustrates a flow that gathers and processes a sequence of values for GenderName, and Mother’s Birth Year.

  1. After sending an introductory message, establish a Wait for Response action. Use an open-ended response rule like has any of the words to capture all messages containing the “birth” keyword. Save the outcome as “Message”.

 

Note: This response rule must be open-ended to collect every message with the “Birth” keyword. After extracting the keyword from the initial message, each field can be evaluated using a sequence of Split by Flow Result actions.

  1. To isolate the submission as the flow variable @results.message (as Split by Flow Result actions can only assess flow results variables), remove the keyword trigger. Achieve this by creating a Split Action that divides the initial message by expression. Apply the @(REMOVE_FIRST_WORD()) function to the incoming message (referenced as @input.text). The final expression should be @(REMOVE_FIRST_WORD(input.text)).

  1. Save the resulting flow variable as “Fields” to obtain only the values separated by a plus sign. The submitted values follow the structure [gender]+[name]+[mother’s birth year], where each bracketed term represents a distinct field: Gender is the first, Name the second, and Mother’s Birth Year the third.

  1. Introduce a Split by Flow Result action to evaluate Gender, the first field delimited by a plus sign. Create a response rule for each gender that classifies the abbreviated values “m” or “f” into their full forms, and save the resulting flow variable as “Gender”.

Note: You must select the “Advanced” tab at the top of the node to delimit the result for every Split by Flow Result action you create.

  1. Add a Send Message action to handle incorrectly formatted “Gender” values and prompt the contact to resubmit.

  1. In the example above, the error message is formatted to reiterate the contact’s original input using the @results.fields variable. This allows them to compare their response to the expected format before trying again.

  1. Include a second Split by Flow Result action to assess “Name”, the second delimited field (the child’s name). Implement an is not empty response rule to confirm the field contains a value, categorize it as “Has Name”, and save the result as the “Name” flow variable. Remember to check the Delimit Result box in the Advanced tab.

  1. Add another Send Message action to address improperly formatted “Name” values and request a new submission.

  1. Incorporate a third Split by Flow Result action to evaluate “Birth Year“, the third field. Apply a has a number between response rule to validate that the field contains a legitimate birth year, and save the outcome as the “Birth Year” flow variable.

  1. Include a Send Message action to manage invalid “Birth Year” entries and ask for resubmission.

  1. Complete the flow with a Send Message action that confirms the form submission by echoing the values provided by the contact.

The finished flow should resemble the example below.

Require more than nine fields? Utilize the Split by Expression action with the following function:

FIELD(text, index, [delimiter])

This function references a field in a delimiter-separated string, for example:

@(field(results.field, 1, "+"))