* If

Overview

The If object represents a standard IF-THEN-ELSE construct as in any standard programming or scripting language. It is typically used within the dialog flow to fork it into two separate branches depending on certain business rules.

Usage examples for the If object are:

·          Processing an optional introductory tour if the caller chooses to hear it.

·          Switching between two different subdialogs depending on which of two options the caller has selected.

·          Switching between a regular menu used on weekdays and a recorded announcement used on weekends.

The Object Definition below covers the configuration of the If object with VoiceObjects Desktop. For information on how to define this object type using VoiceObjectsXML, refer to the VoiceObjectsXML Definition paragraph.

The If object belongs to the object category Logic.

Dialog Flow Scenario

The dialog flow example below presents the use of the If object within a voice shopping portal. It branches the dialog flow into two different welcome Sequence objects depending on the application visit status of the particular caller. The following dialog flow demonstrates the THEN branch where the visit counter is evaluated as greater than zero.


Object

Dialog Flow

< Connect to the back-end system to load the visit counter of the caller based on the supplied ANI
(Automated Number Identification) >

[  Music jingle ]
Hello and welcome to the voice shopping portal.

*

< Visit counter greater than 0 >   [ true ]

< Frequent Visitor >

I’m pleased to assist you again.   …

What can I do for you today?

 

The next dialog flow example demonstrates the ELSE branch of the same If object. Here, the visit counter for the particular caller is equal to zero and the If condition evaluates to false. The introduction offers a quick tour through the voice shopping portal to provide the caller with an overview of the service for better orientation. After the orientation tour the dialog flow proceeds with the main menu.


Object

Dialog Flow

< Connect to the back-end system to load the visit counter of the caller based on the supplied ANI
(Automated Number Identification) >

[  Music jingle ]
Hello and welcome to the voice shopping portal.

*

< Visit counter greater than 0 >   [ false ]

< First Time Visitor >

Since this is your first visit to the voice shopping portal,
 I’d like to give you a quick tour of how to use the system.

 If you want to skip the tour, say “main menu” now.

< Auto-advance with dialog flow after 2 seconds >

OK, let’s get started with the orientation tour.
In the music shop you will find …

Main menu! Which shop would you like to visit?  …

Object Definition

The Definition of the If object provides the following sections:

·         IF
To define the branching condition.

·         THEN
To define the object that is processed if the branching condition is true.

·         ELSE
To define the object that is processed if the branching condition is false.


 

For further details regarding additional object configuration refer to Precondition and Properties in this Object Reference.

IF

The IF section specifies the Boolean condition that is evaluated to determine whether the THEN or the ELSE portion of the object is processed. Either define an embedded condition by selecting an appropriate operator from the Function drop-down list and specifying the required arguments, or link a Variable, Expression, Collection, Script, or Layer object that returns a Boolean value. For more information on the use of functions, see the Expression object in this Object Reference.

THEN

The THEN section defines the object that is processed if the IF condition evaluates to true. The THEN object is optional if an ELSE object is defined.

ELSE

The ELSE section defines the object that is processed if the IF condition evaluates to false. The ELSE object is optional if a THEN object is defined.

VoiceObjectsXML Definition

The If object is represented by the VoiceObjectsXML element <if>. It has five groups of children.

In addition, the element has the standard attributes described in the XDK Guide.

The <if> element uses the embedded <ifItem> and <else> elements.

If

Children

·          <expression usage=”precondition”> or
<variable usage=”precondition”> or
<collection usage=”precondition”> or
<script usage=”precondition”>
Defines the precondition for the If object.

·          <sequence usage=”preprocessing”>
Defines the preprocessing sequence for the If object.

·          <ifItem>
Defines the condition and the object to be processed for the “then” case.

·          <else>
Defines the object to be processed for the “else” case.

·          <sequence usage=”postprocessing”>
Defines the postprocessing sequence for the If object.

 

Example

<if>

  <ifItem>

    <expression usage=”condition” function=”equal”>

    <!-- Checks whether the number is even -->

      <argument>

        <expression function=”mod”>

          <argument object=”#Number”/>

          <argument><value> 2 </value></argument>

        </expression>

      </argument>

      <argument><value> 0 </value></argument>

    </expression>

    <output>

      <outputItem><text>The number is even.</text></outputItem>

    </output>

  </ifItem>

  <else>

    <output usage=”else”>

      <outputItem><text>The number is odd.</text></outputItem>

    </output>

  </else>

</if>

IfItem

Children

·          <expression usage=”condition”> or
<variable usage=”condition”> or
<collection usage=”condition”> or
<script usage=”condition”>
Defines an embedded object as condition.

·          One of the following:
<module>, <input>, <output>, <sequence>, <menu>, <confirmation>, <list>, <osdm>, <plugin>, <connector>, <script>, <log>, <if>, <case>, <goto>, <loop>, <expression>, <recording>, <transfer>, <pause>, <exit>
 Defines the object to be processed if the condition evaluates to true.

 

Example

<ifItem>

  <expression usage=”condition” link=”#isLeapYear”/>

  <output>

    <outputItem><text>The year is a leap year.</text></outputItem>

  </output>

</ifItem>

Else

Children

·          One of the following:
<module>, <input>, <output>, <sequence>, <menu>, <confirmation>, <list>, <osdm>, <plugin>, <connector>, <script>, <log>, <if>, <case>, <goto>, <loop>, <expression>, <recording>, <transfer>, <pause>, <exit>
Defines the object to be processed in the “else” case (i.e. when the condition evaluates to false).

 

Example

<else>

  <output>

    <outputItem><text>The year is not a leap year.</text></outputItem>

  </output>

</else>

Object Interoperability

The following table contains all the object types that can refer to an If object:


Icon

Object Name

Use Case Example

Module

An If object can be used within the embedded sequence of a Module object.

Sequence

Most commonly, the If object is used within a Sequence object in a dialog flow.

Menu

An If object can be used as the destination object within a Menu item inside a Menu object.

Confirmation

An If object can be used as the destination object within a Correction item inside a Confirmation object.

If

An If object can be used within either the THEN or the ELSE item of another If object.

Case

An If object can be used in any WHEN item of a Case object.

Loop

An If object can be used within the embedded sequence of a Loop object.

Goto

An If object can be referenced via a Goto object.

Hyperlink

An If object can be the destination of a Hyperlink object.

Object Naming Conventions

In order to leverage the capabilities of the integrated documentation of VoiceObjects it is important to provide intuitive and self-explanatory object names and descriptions.

The name of an If object should indicate the condition that is evaluated, preferably in the form of a Yes/No question. The short description should contain a brief explanation of the different cases that may occur. The table below lists three examples:


Name

Description

* Caller wants tour

Processes the service tour if desired by the caller (answered yes).

* Call during weekdays

Switches between the normal menu used on weekdays and a recorded announcement used for weekends.

* Account balance above $10,000

Switches between service level for normal customers (account balance below $10,000) and premium customers (account balance above $10,000).