Tag : {Choice}
- Choice Tag Summary
- How is the Choice Tag Used?
- Conditions & Restrictions
- Examples of Using the {Choice} Tag in Cyara Test Cases
- Optional Parameters & Operators for the Choice Tag
Choice Tag Summary
The {Choice} Tag can be used when matching a prompt that has at least two known alternatives, for an IVR that has a different opening voice message during different times of day for example. {Choice} Tags can specify multiple phrases and Cyara will attempt to match the prompt against each provided phrase within the Tag.
Choice Tags also have an advanced application where the result of a choice outcome can determine what response the Cyara Test Case makes in subequent Test Case Steps. For more information read the Optional Parameters & Operators for the Choice Tag
How is the {Choice} Tag used?
The {Choice} Tag is inserted in the Test Case Expect to Hear field or a CX Model Prompt field, representing multiple alternate phrases that can be matched by the Cyara speech recognition engine.
Hello, this is {Choice Adam|Barry|Charlie} speaking.
In this example above, we expect to hear "Hello, this is" and then either the name "Adam, Barry or Charlie", any of these three names being spoken by the IVR would result in this step having a successful outcome.
Conditions & Restrictions
There are a few key points with the {Choice} Tag to be aware of;
- The reply variable is only allowed in the Reply With field of the same or subsequent Steps
- Only one use of any reply variable is allowed in any single Reply With field
- A Step’s Reply With field can only contain 1 Choice variable reference (for example, you can not include {$Var1} {$Var2} or {$Var1} {$Var1})
- If no reply variable value is specified by a Choice, the variable is assigned the value of the choice prompt.
- In this example, {Choice $Var1=Adam:1|Barry:2|Charlie:3}, the variable is called “Var1” and the variable values are 1, 2, and 3. If the Reply With field contains {$Var1} then the Step will reply with the value assigned in the Expect to Hear Step (1, 2, or 3). However if the Expect to Hear Step instead contains {Choice Var1=Adam|Barry|Charlie} (that is, without the optional variable values), the variable “Var1” is assigned the literal choice option (for example, “Adam, “Barry”, or “Charlie”).
- Choice Tag reply variables must only be assigned once but may be referenced many times in separate Test Case Reply With steps.
- Choice tags cannot contain other nested tags except for the {EndCall} or {SetStepResult} tag.
- A Choice prompt can be set to blank or set to a "." (a single period/full stop), both of which will match nothing.
- {Choice Hello|} how are you" and "{Choice Hello|.} how are you" have equivalent meaning, and will successfully match against "Hello how are you" and "how are you".
- A Choice Tag reply variable should not be used in Cruncher load testing Campaigns
Examples of Using the {Choice} Tag in Cyara Test Cases.
The following examples show how the {Choice} Tag can be used to handle multiple business scenarios on the same Cyara Test Case. In the examples below we will increase the complexity of using the {Choice} Tag, starting with a basic prompt matching moving on to more advanced Choice Tag Reply Variables.
Scenario 1.
In this example we want to build a Test Case that can handle two slightly different prompts at different times of the day (A normal operating hours and an Out of Hours message) and how you would use the Choice tag to handle either scenario in the same Test Case.
Actual Audio Heard | Expect to Hear | Step Outcome |
(During Business Hours) (After Business Hours) |
Welcome. For telephone banking, press 1. To report a stolen card, press 2. |
Successful: This single Expect to Hear prompt will match both of the potential audio sets heard. The Choice Tag offers the "Our Office is Closed" prompt, as well as a "." to match with no additional prompt. |
Scenario 2.
Now we can build a more complex Test Case Step where we set a Variable to be used in a later Test Case Reply With Step. In this scenario an IVR is performing a validation task by asking the caller to enter a random digit from their PIN (Either the First, Second, Third, or Fourth Digit). We want to be able to accept any of these four options, and change the reply with text of a later Test Case step based on what was entered by the caller (a security validation pass/failure for example).
Actual Audio Heard | Expect to Hear | Step Outcome |
Please enter the second digit of your PIN | Please enter the {Choice pin1=first:6|second:5|third:4|fourth:3} digit of your PIN | Successful: The prompt will be matched using choice “second”. This will set a value of “5” into the variable named “pin1”. The variable pin1 can be used in Step Reply With field as {$pin1} |
Scenario 3.
An advanced application of using the Choice Tag is to reply with an amount of silence in the Reply With field. This is achieved by setting a Choice Tag Reply with Variable to either a "." (A period/Full Stop), or a "," (a Comma). A Period/Full stop will reply with 2.0 seconds of Silence, While a Comma will reply with 0.2 seconds of silence. This method only works if the Reply With step is set to the DTMF Reply Type. Assuming the Reply With field is set to {$Var1}, then the following would apply.
Actual Audio Heard | Expect to Hear | Reply With |
Hello, this is Adam speaking. | Hello, This is {Choice Var1=Adam:.|Barry:,} speaking. | 2.0 Seconds of Silence |
Hello, this is Barry speaking. | Hello, This is {Choice Var1=Adam:.|Barry:,} speaking. | 0.2 Seconds of Silence |
Optional Parameters & Operators for the Choice Tag
An optional extension of the tag allows a return value based on the phrase that was matched within the {Choice} Tag, and this return value can be used to alter subsequent Step replies.
The extended form of the choice tag also matches several alternatives, but will also return a value that can then be used in subsequent steps. For Example;
Hello, this is {Choice VariableName=Adam:1|Barry:2|Charlie:3}
This example above, the prompt will still match for either of the three available names (Adam, Barry or Charlie), but in this instance the VariableName variable will be assigned a value of 1 for Adam, 2 for Barry and 3 for Charlie. This VariableName can then be used in subsequent reply with fields by using {$VariableName}
Comments
1 comment
Hi Daniel Haynes, can you please add also a sample for usage in a web/chat testcase. I am struggling in picking up the same scenario (time dependent messages) in a bot journey. THX in advance!
Please sign in to leave a comment.