Sending messages from a voice application

Last Updated : Jun 05, 2026 |

To send a message from a VoiceXML application to a remote endpoint, use the <send> element.

The <send> element supports the following attributes:

The <send> attributes

Name

Description

Required

Default

async

A boolean indicating whether to block until the final response to the transaction created by sending the external event is received, or a timeout.

No

true

asyncexpr

An ECMAScript expression evaluating the value of the async attribute. If evaluation of the expression fails, the interpreter displays "error.semantic".

No

N/A

body

A string representing the data to be sent in the body of the message.

No

N/A

bodyexpr

An ECMAScript expression evaluating the body of the message to be sent. If evaluation of the expression fails, the interpreter displays "error.semantic".

No

N/A

contenttype

A string indicating the media type of the body being sent, if any. The set of content types might be limited by the underlying platform. If an unsupported media type is specified, the interpreter displays "error.badfetch.<protocol>.400." The interpreter is not required to inspect the data specified in the body to validate that it conforms to the specified media type.

No

text/plain

contenttypeexpr

An ECMAScript expression evaluating the media type of the body. If evaluation of the expression fails, the interpreter displays "error.semantic".

No

N/A

event

The name of the event to send. The value is a string which only includes alphanumeric characters and the "." (dot) character. The first character must be a letter. If the value is invalid, then an "error.badfetch" event is displayed.

No

N/A

eventexpr

An ECMAScript expression evaluating the name of the event to be sent. If evaluation of the expression fails, the interpreter displays "error.semantic".

No

N/A

fetchaudio

See Section 6.1 of [VXML2]. This is a default valueto the fetchaudio property described in Section 6.3.5 of [VXML2].

No

N/A

fetchaudioexpr

An ECMAScript expression evaluating the fetchaudio URI. If evaluation of the expression fails, the interpreter displays "error.semantic".

No

N/A

namelist

A list of zero or more whitespace-separated variable names to send. By default, no variables are submitted. Values for these variables are evaluated when the <send> element is ran. Only declared variables can be referenced. Otherwise, error.semantic is displayed. Variables must be submitted to the server with the same qualification used in the namelist. When an ECMAScript variable is submitted to the server, its value must be converted first into a string before being sent. If the variable is an ECMAScript object, the mechanism by which it is submitted is platform specific. Instead of submitting an ECMAScript object directly, the application developer can explicitly submit the individual properties of the object. For example, date.month date.year.

No

N/A

target

The attribute that specifies the URI to which the event is sent. If the attribute is not specified, the event is sent to the component which started the VoiceXML session.

No

Invoking component

targetexpr

An ECMAScript expression evaluating the target URI. If evaluation of the expression fails, the interpreter displays "error.semantic".

No

N/A

timeout

See 6.13.2.1 sendtimeout. This defaults to the sendtimeout property.

No

N/A

timeoutexpr

An ECMAScript expression evaluating the timeout interval for a synchronous <send>. If evaluation of the expression fails, the interpreter displays "error.semantic"

No

N/A

You can specify any of the following items. Otherwise, the system returns the error.badfetch error message:

  • async or asyncexpr

  • event or eventexpr

  • contenttype or contenttypeexpr

  • fetchaudio or fetchaudioexpr

  • target or targetexpr

  • timeout or timeoutexpr

Additionally, only one of the following attributes must be specified. Otherwise the system returns the error.badfetch error message:

body, bodyexpr, or namelist.

For synchronous <send>, if time-out occurs, the interpreter returns the error.badfetch error message. If the interpreter encounters an error upon sending the external message, the system returns the error.badfetch.<protocol>.<status_code> output.

The following example demonstrates the use of <send> synchronously:

<vxml version="2.1"
  xmlns="http://www.w3.org/2001/vxml">

  <form>
  <field name="user_id" type="digits">
    <prompt>please type your five digit i d</prompt>
    <filled>
      <send async="false" 
            bodyexpr="'<userinfo><id>' + user_id + '</id></userinfo>'" 
            contenttype="text/xml" timeout=”5s”/>
      <goto next="mainmenu.vxml"/>
    </filled>
  </field>
  </form>
</vxml>

Upon executing an asynchronous <send>, the interpreter continues execution of the voice application immediately and disregards the disposition of the message that was sent.

The following example demonstrates the use of <send> asynchronously:

<vxml version="2.1"
  xmlns="http://www.w3.org/2001/vxml">

  <form>
    <var name="tasktarget" expr="'http://www.example.com/taskman.pl'"/>
    <var name="taskname" expr="'cc'"/>
    <var name="taskstate"/>
    <block>
      <assign name="taskstate" expr="'start'"/>     
      <send async="true" 
            targetexpr="tasktarget" 
            namelist="taskname taskstate"/>
    </block>
    <field name="ccnum"/>
    <field name="expdate"/>
    <block>
      <assign name="taskstate" expr="'end'"/>     
      <send async="true" 
            targetexpr="tasktarget" 
            namelist="taskname taskstate"/>
    </block>
  </form>
</vxml>