Need clarification on correct XML output for dynamic dialplan (with multiple gateways / failover)

sokalsondha

Member
Nov 6, 2019
40
1
8
I’m building a VoIP billing system using FreeSWITCH and the XML CURL API.

So far, SIP registration, SIP profiles, and gateways are all working dynamically from the database.

Now I’m working on the dialplan part — and I’m a bit stuck.

I want to know the correct XML format that FreeSWITCH expects my API to reply with, especially when I have one main gateway and up to three failover gateways (for example, UK numbers like 00442079460000).

Basically, I need to confirm what the XML CURL response structure should look like — how FreeSWITCH wants the dialplan reply for outbound calls with multiple gateways in sequence.

Can anyone share a small example or best-practice format for this kind of setup?
 
As you are probably aware FreeSWITCH will make the CURL call to your API and provide lots of variables that help you decide what FreeSWITCH is asking for. For example it will give to the number dialed and the domain name.
Probably the most important POST variable that you will read is "Caller-Context". The example CURL given below simulates a dialplan request from FreeSWITCH, in this case it was to help me test the DjangoPBX XML handler.

Code:
curl -d "section=dialplan&domain=test1.mydomain.uk&FreeSWITCH-Switchname=dev1.com&Caller-Context=test1.mydomain.uk&Caller-Destination-Number=*9664" -X POST http://127.0.0.1:8080/xmlhandler/dialplan/

The simplest response you can give is a "not found", FreeSWITCH will be happy with this and simply end the call with a 480. Here is what the XML would look like:

XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
  <section name="result">
    <result status="not found" />
  </section>
</document>

To return a dialplan with the failover gateways as you request, the XML result would probably look something like this:

XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
    <section name="dialplan" description="">
        <context name="test1.mydomain.uk">
         <extension name="OUTBOUND_1" continue="false" uuid="0fb7c496-1077-4e2f-a36a-3610c26dfb32">
           <condition field="${user_exists}" expression="false"/>
           <condition field="destination_number" expression="^(0044\d{10})$">
             <action application="export" data="call_direction=outbound"/>
             <action application="unset" data="call_timeout"/>
             <action application="set" data="effective_caller_id_name=${outbound_caller_id_name}"/>
             <action application="set" data="effective_caller_id_number=${outbound_caller_id_number}"/>
             <action application="set" data="inherit_codec=true"/>
             <action application="set" data="ignore_display_updates=true"/>
             <action application="set" data="callee_id_number=$1"/>
             <action application="set" data="hangup_after_bridge=true"/>
             <action application="set" data="continue_on_fail=1,2,3,6,18,21,27,28,31,34,38,41,42,44,58,88,102,111,403,501,602,607"/>
             <action application="bridge" data="sofia/gateway/1dcf1e47-fd31-4404-a1a3-c7d912fd5a61/$1"/>
             <action application="bridge" data="sofia/gateway/f0543e33-5288-4b3e-b116-c8fe9b0c8045/$1"/>
             <action application="bridge" data="sofia/gateway/aa343e46-5288-5f3ec216-d99b0c3494/$1"/>
           </condition>
         </extension>
        </context>
    </section>
</document>

The tree UUIDS in the bridge statements are your gateways, tried in turn
I hope that helps.
 
Last edited:
  • Like
Reactions: pbxgeek