When external message is delivered synchronously, an application developer decides whether the message is preserved or discarded by setting the externalevents.queue property. The property can be set to one of the following values:
externalevents.queue values |
true |
External messages are queued and set to application.lastmessage$. |
false |
An external message that is not delivered as a VoiceXML event is discarded. This is the default value. |
To receive an external message synchronously, set the externalevents.enable property to false and the externalevents.queue property to true, and use the <receive>element to pull messages off the queue. The <receive>element blocks waits until an external message is received or the timeout specified by the maxtime attribute is exceeded.
The <receive> element supports the following attributes:
The <receive> properties |
Name |
Description |
Required |
Default |
fetchaudio |
See Section 6.1 of [VXML2]. This the defaults value to the fetchaudio property described in Section 6.3.5 of [VXML2]. |
No |
N/A |
fetchaudioexpr |
An ECMAScript expression evaluating to the fetchaudio URI. If evaluation of the expression fails, the interpreter displays"error.semantic". |
No |
N/A |
maxtime |
A W3C time specifier indicating the maximum amount of time the interpreter waits to receive an external message. If the timeout is exceeded, the interpreter throws "error.badfetch." A value of "none" indicates the interpreter the blocks indefinitely. |
No |
0s |
maxtimeexpr |
An ECMAScript expression evaluating to the maxtime value. If evaluation of the expression fails, the interpreter throws "error.semantic". |
No |
0s |
You can specify any one of fetchaudio and fetchaudioexpr. Otherwise, the system returns the error.badfetch error message.
You can specify any one of maxtime and maxtimeexpr . Otherwise, the system returns the error.badfetch error message.
When present, the attributes fetchaudioexpr and maxtimeexpr are evaluated when the <receive> command is ran.
The following example demonstrates synchronously received external message. In this example, the interpreter blocks for up to 15 seconds waiting for an external message to arrive. If no external message is received during that interval, the interpreter returns the error.badfetch error message. If a message is received, the interpreter proceeds by executing the <log >element.
<vxml version="2.1"
xmlns="http://www.w3.org/2001/vxml">
<property name="externalevents.queue" value="true"/>
<form>
<catch event="error.badfetch">
<log>timed out waiting for external message</log>
</catch>
<block>
Hold on ...
<receive maxtime="15s"
fetchaudio="http://www.example.com/audio/fetching.wav"/>
<log>got <value expr="application.lastmessage$.content"/></log>
</block>
</form>
</vxml>