The previous example illustrated the “interaction” script. This example uses the virtual phone, reads the message to the user, and responds with “Hello from Voice Device”.
Note that:
To use the interaction script, the “initial” script requires some modification. Device Filtering for the Voice Device must be enabled, and the target Device count must be increased to three. Changes to the script are shown in bolded text below:
##################################################################
#
# Script: HelloWorld/PROCESS/initial
#
# This is the main entry point for this script package.
#
##################################################################
#/////////////////////////////////////////////////////////////////
# This is the main entry point for this script. Whenever a
# message is sent to the domain that owns this script package, this
# script is called.
#/////////////////////////////////////////////////////////////////
main:
# retrieve the notification associated with this event
@alert = @event::notification()
# Set general response choices
$main.genericChoices = "Hello"
$main.genericChoices::add("Hi")
$main.genericChoices::add("Howdy")
$main.genericChoices::add("Good day")
# create a content object for this event
@genericContent = @event::createContent()
# set the content subject and message
$genericContent.message = "Hello World!"
$genericContent.subject = "Example #5"
# persist this content (as a property of main) to be
# accessible from within the presentation script later
$genericContent.choices = $main.genericChoices
# set the notification's content to the recently created content
@alert::setContent(@genericContent)
# enable delivery notifications
@alert::setHandleDeliveryEvents(true)
# tell the notification about the response handler
@alert::setHandlerScript("response")
@alert::setPresentationScript("presentation")
# this example targets all three devices
@alert::setDeviceFilter("EMAIL", TRUE)
@alert::setDeviceFilter("TEXT_PAGER", TRUE)
@alert::setDeviceFilter("VOICE", TRUE)
# for this example, three Devices will be targeted. To see how
# replies work from each Device, set a counter that indicates the
# number of Devices that are being targeted. In the response
# script, decrement this counter each time a response is
# received. When the count reaches zero, set main.continue =
# true, so that this event will complete
$main.targetDevices = 3
# tell notification which recipients to target (those contained
# in the event)
@alert::link($event.recipients)
# only log information if debug is set
IF (EXISTS($event.debug))
@script::log("Processing notifications...")
ENDIF
# notify the recipients
@alert::performNotification()
# set continue flag to false and set the timeout to wait for the
# continue flag to change to true (the response handler changes
# the flag’s value to true when it is done)
$main.continue = FALSE
$main.timeout = 86400
# wait until timeout is reached or continue flag changes to TRUE
UNTIL ($main.continue, $main.timeout)
# only log information if debug is set
IF (EXISTS($event.debug))
@script::log("...end of notification processing.")
ENDIF
# ensure that all of the recipients have been removed from the
# notification
@event::delinkAll()
### DONE: main ###
Next topic: Modifying the presentation script