Freeswitch IVR Originate

From FreeSWITCH Wiki

Jump to: navigation, search

Contents

IVR originate data syntax

Call a normal channel

Default pattern for originating calls:

endpoint_name/endpointdata

Originating by profile:

sofia/${profile_name}/1234@domain.com

Or by gateway(the sofia/gateway/ has special meaning make sure you include it when dialing via a gateway):

sofia/gateway/${gateway_name}/1234

If you want to set variables on the originated call, see the description at the top of the Channel Variables page.

Multiple destinations in outbound calls

This means any dialstring may contain a '|' and/or ',' separated list of call URLs. The "|" calls one call at a time, the "," calls multiple calls simultaneously.

The example below will call 2 locations and connects the first to answer

<extension name="3002">
  <condition field="destination_number" expression="^3002$">
    <action application="bridge" data="iax/guest@somebox/1234,sofia/test-int/1000@somehost"/>
  </condition>
</extension>

If you have a problem with one of the destinations causing the others to stop ringing, insert this into the bridge application: {ignore_early_media=true} like so:

<extension name="3002">
  <condition field="destination_number" expression="^3002$">
    <action application="bridge" data="{ignore_early_media=true}sofia/test-int/1001@somebox,sofia/test-int/1000@somehost"/>
  </condition>
</extension>

If only one destination has the problem, use square brackets instead of curly brackets. Channel variables set within curly brackets (braces) apply to all the call destinations, whereas channel variables set within square brackets apply only to the call destination immediately following it.

And this example will first call 1 location and if that results in a failure, try 2 at once on the next go

<extension name="3002">
  <condition field="destination_number" expression="^3002$">
    <action application="bridge" data="sofia/test-int/3920@10.3.3.104|sofia/test-int/3910@10.3.3.104,sofia/test-int/3920@10.3.3.104"/>
  </condition>
</extension>

Enterprise originate

The so called 'enterprise originate' syntax is a way to simultaneously originate multiple calls in several threads (regular simultaneous originate is single threaded). To use it simply separate valid dial strings by :_: . Each dial string can have its own {} and [] blocks and can themselves be simultaneous or sequential (containing ',' or '|') as above.

This can be helpful, for example, when dealing with call forwarding. Without it, FreeSWITCH™ would drop the simultaneous dial and transfer to the forwarded extension.

Answer confirmation

It is possible to map a certain key as required indication of an accepted call. You may also supply a filename to play possibly instructing the call recipient to press the desired key etc...

The example below will call 2 locations playing prompt.wav to any who answer and completing the call to the first off-hook recipient to dial "4"

<extension name="3002">
  <condition field="destination_number" expression="^3002$">
    <action application="set" data="call_timeout=60"/>
    <action application="set" data="group_confirm_file=/path/to/prompt.wav"/>
    <action application="set" data="group_confirm_key=4"/>
    <action application="bridge" data="iax/guest@somebox/1234,sofia/test-int/1000@somehost"/>
  </condition>
</extension>

The following is the equivalent but the confirm data is passed via the bridge parameters (This is for situations where there is no originating channel to set variables on). It can also be used from the FreeSWITCH command line with the dial string in double quotes (e.g. the originate command).

<extension name="3002">
  <condition field="destination_number" expression="^3002$">
    <action application="bridge" data="{group_confirm_file=/path/to/prompt.wav,group_confirm_key=4,call_timeout=60} iax/guest@somebox/1234,sofia/test-int/1000@somehost"/>
  </condition>
</extension>

This logic should be permitted in anything that establishes an outgoing call with switch_ivr_originate(). That means even in the originate API command you can call multiple targets and send whoever answers first to an extension that calls more multiple targets. You should be able to do the same in the mod_conference dial and dynamic conference features.

Note that setting group_confirm_file without group_confirm_key makes no effect. If you want to just playback an audio prompt to the callee before bridging the call, without asking any confirmation, here's an example:

<extension name="3002">
  <condition field="destination_number" expression="^3002$">
    <action application="bridge" data="{group_confirm_file=playback /path/to/prompt.wav,group_confirm_key=exec,call_timeout=60} iax/guest@somebox/1234,sofia/test-int/1000@somehost"/>
  </condition>
</extension>

exec in answer confirm

Instead of requiring locations to press a certain key to accept the call, you can require them to complete a script. This is done by setting 'group_confirm_key=exec' and 'group_confirm_file=application script <args>'. In the example below, the test.js script is run for each location that is dialed. Whichever location finishes the script first gets the call.

<extension name="3002">
  <condition field="destination_number" expression="^3002$">
    <action application="set" data="call_timeout=60"/>
    <action application="set" data="group_confirm_key=exec"/>
    <action application="set" data="group_confirm_file=javascript test.js arg1 arg2"/>
    <action application="bridge" data="sofia/test-int/1000@domain.com,sofia/test-int/1001@mydomain.com"/>
  </condition>
</extension>

Remember that when making a parallel dial in bridge, the script will be executed for all the end (which answers) but finally bridges with the one who completed the script successfully.

See Also

Personal tools
Community
Support FreeSWITCH