Controlling State Transitions with Regular Expressions

You can control state transitions by defining regular expressions. When expressions match user-input strings, the state transitions to the follow-up state.

Some states expect user input to control the transition to follow-up states. Input can be provided either by consumers in response to the Send SMS state, or as dynamic output from either a Brand Mobiliser state, or a third-party custom state. Dynamic values allow external systems to communicate specific context information back to the application.

A regular expression can contain any combination of characters. The Brand Mobiliser expression tester enables you to test regular expressions during application development. Sample regular expressions are:

Regular Expression Matches
.* Any value in the Expression field.
(.*) Any value in the Expression field; assigns the expression to a session variable.

In more complex cases, you can break a regular expression into multiple regular-expression groups and assign them to separate session variables.

For a complete description of regular expressions, see: http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html.


Agent Code Regular Expression

In the state editor, Target identifies the state that follows the current state if its Expression value matches the input. If the input matches more than one Expression value, a list of matches is created. The first entry in the list is the first matching pattern, continuing with other states in the order in which they appear in the state editor. For example, if the input is 0, the follow-up state is Goto Application Main Menu, even though 0 also matches the second expression. If the input is anything other than 0, it matches the second expression, and the value is assigned to the session variable AGENT_CODE, because the value of Expression is surrounded by parentheses. To move an expression up or down in the Follow-up States list, use the arrows on the left side of the editor.