<Gosub>

The <Gosub /> element provides for creating complex workflows similar to <Goto /> but the execution will return to previous execution block after being called.

Element Attributes

Attribute

Description

label required

The name/identifier that execution of InboundXML. The name/identifier set here is the location that InboundXML will execute. This element is similar to <Goto /> except that execution returns back to original position after executing. The hangup attribute is not applicable here.

  • Valid value: a string value

Nesting

The Gosub can contain nested elements but must be placed inside the default Response element.

&lt;Response&gt;
  &lt;Gosub label="FirstBlock" /&gt;
  &lt;Block label="FirstBlock"&gt;
    &lt;Say&gt;This is spoken first.&lt;/Say&gt;
    &lt;Gosub label="SayThis" /&gt;
    &lt;Say&gt;This is spoken after the Gosub element.&lt;/Say&gt;
  &lt;/Block&gt;
  &lt;Gosub label="SayThis" /&gt;
  {/* other tags hidden for brevity */}
  &lt;Block label="SayThis"&gt;
    &lt;Say&gt;Press 1 for billing. Press 2 for customer service. Press 3 for communication options.&lt;/Say&gt;
  &lt;/Block&gt;
  &lt;Say&gt;This statement will never be spoken.&lt;/Say&gt;
&lt;/Response&gt;

Block, Goto and Gosub Example

The following code sample contains all three elements to demonstrate how they can be put together.

&lt;Response&gt;
  &lt;Goto label="M360Test_1" /&gt;
  &lt;Say&gt;This text will never execute.&lt;/Say&gt;
  &lt;Block label="M360Test_1"&gt;
    &lt;Say&gt;Hello. This is First block.&lt;/Say&gt;
    &lt;Gosub label="M360Test_2"/&gt;
  &lt;/Block&gt;
  &lt;Block label="M360Test_2"&gt;
    &lt;Say&gt;Hello. This is Second block.&lt;/Say&gt;
    &lt;Gosub label="M360Test_3"/&gt;
    &lt;Say&gt;This is spoken after gosub.&lt;/Say&gt;
  &lt;/Block&gt;
  &lt;Goto label="M360Test_2" /&gt;
  &lt;Block label="M360Test_3"&gt;
    &lt;Say&gt;Hello. This is Third block.&lt;/Say&gt;
  &lt;/Block&gt;
  &lt;Say&gt;This text will never be spoken.&lt;/Say&gt;
&lt;/Response&gt;