HTTAPI document syntax

In its most basic form an XML HTTAPI document sent by the webserver in response to mod_httapi request looks like this:

<document type="text/freeswitch-httapi"> 
 <params/> 
 <variables/> 
 <work/> 
</document> 

As an example, this is the document returned from webserver when pressing "6" on the keypad while in a call to demo ivr in php httpapi, detailed later in this chapter:

<document type="text/freeswitch-httapi"> 
  <variables> 
    <IVR_variable_01>VariableValue01</IVR_variable_01> 
  </variables> 
  <params> 
    <IVR_param_01>ParamValue01</IVR_param_01> 
  </params> 
  <variables> 
    <main_menu_option>6</main_menu_option> 
  </variables> 
  <work> 
    <playback error-file="ivr/ivr-that_was_an_invalid_entry.wav" loops="3" digit-timeout="15000" file="phrase:demo_ivr_sub_menu" name="sub_menu_option"> 
      <bind>*</bind> 
    </playback> 
    <!-- session_id => 9c6f38d3-897a-44aa-9162-bf4f718c6d45 --> 
    <!-- hostname => ip-172-31-11-17 --> 
    <!-- Caller-Direction => inbound --> 
    <!-- Caller-Logical-Direction => inbound --> 
    <!-- Caller-Username => 1010 --> 
    <!-- Caller-Dialplan => XML --> 
    <!-- Caller-Caller-ID-Name => 1010 --> 
    <!-- Caller-Caller-ID-Number => 1010 --> 
    <!-- Caller-Orig-Caller-ID-Name => 1010 --> 
    <!-- Caller-Orig-Caller-ID-Number => 1010 --> 
    <!-- Caller-Network-Addr => 188.11.134.42 --> 
    <!-- Caller-ANI => 1010 --> 
    <!-- Caller-Destination-Number => 12345 --> 
    <!-- Caller-Unique-ID => 9c6f38d3-897a-44aa-9162-bf4f718c6d45 --> 
    <!-- Caller-Source => mod_sofia --> 
    <!-- Caller-Context => default --> 
    <!-- Caller-Channel-Name => sofia/internal/[email protected] --> 
    <!-- Caller-Profile-Index => 1 --> 
    <!-- Caller-Profile-Created-Time => 1498838395878804 --> 
    <!-- Caller-Channel-Created-Time => 1498838395878804 --> 
    <!-- Caller-Channel-Answered-Time => 1498838395898804 --> 
    <!-- Caller-Channel-Progress-Time => 0 --> 
    <!-- Caller-Channel-Progress-Media-Time => 1498838395898804 --> 
    <!-- Caller-Channel-Hangup-Time => 0 --> 
    <!-- Caller-Channel-Transfer-Time => 0 --> 
    <!-- Caller-Channel-Resurrect-Time => 0 --> 
    <!-- Caller-Channel-Bridged-Time => 0 --> 
    <!-- Caller-Channel-Last-Hold => 0 --> 
    <!-- Caller-Channel-Hold-Accum => 0 --> 
    <!-- Caller-Screen-Bit => true --> 
    <!-- Caller-Privacy-Hide-Name => false --> 
    <!-- Caller-Privacy-Hide-Number => false --> 
    <!-- url => http://localhost/phttapi/book/demo-ivr.php --> 
    <!-- IVR_param_01 => ParamValue01 --> 
    <!-- main_menu_option => 6 --> 
    <!-- input_type => dtmf --> 
</work> 
</document> 

An HTTAPI response must have an HTTP MIME content-type of text/xml (webserver must be configured to send this content-type). All HTTAPI responses must include the document tag with the type attribute of text/freeswitch-httapi. Then, may have any one, or all, of the following tags:

  • params: These are params (that is, "parameters") the script asks FreeSWITCH to pass back to the web server on each request. You use the <params> tag to tell FreeSWITCH to pass custom POST params.
  • variables: The <variables> tag allows you to set channel variables that can be used by the FreeSWITCH Dialplan or read back into httapi on subsequent requests.
  • work: This is where most of the interesting stuff happens. There are many different action tags that can be used as children of the <work> tag to make FreeSWITCH do just about anything with the phone call being controlled: logging a message at the console, playing a sound file, doing Automatic Speech Recognition, collecting DTMF keypresses, and so on. The available action tags and the attributes that correspond to each action are covered in detail in the next section.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.62.105