FreeSWITCH is an open source softswitch launched in 2008 as an alternative to using Asterisk, supporting the main protocols used in IP telephony (VoIP), including SIP.
The SIP Pulse operator inquiry service, ATI (find out more), also works over the SIP protocol, so the integration of FreeSWITCH with the portability consultation service is perfectly possible. In this article we will see how to carry out this integration.
For FreeSWITCH, the ATI is nothing more than a gateway (or SIP trunk) that will receive cell phone calls. So, first, we must register a new gateway that will point to this service.
To register the new gateway, the ati.xml file must be created within the profile (internal or external, in the default configuration of FreeSWITCH) which will be responsible for this gateway. The content of this file should be:
<include>
<gateway name=”ATI”>
<param name=”username” value=”USUARIO”/>
<param name=”password” value=”SENHA”/>
<param name=”realm” value=”port.sippulse.com”/>
</gateway>
</include>
Where USER and PASSWORD are your ATI authentication data. In the case of the unlimited plan, you can enter any information in these fields, as authentication is done via IP. Remembering that these fields are mandatory for configuring a new gateway in FreeSWITCH, and must always have some value.
Because ATI uses the Redirect method of the SIP protocol (understand SIP Redirect), it is necessary to make a small adjustment to the profile configuration chosen for the ATI gateway, uncommenting the line <!– —> To uncomment the line, simply remove the tags .
With the configurations regarding the FreeSWITCH connection with the ATI service made, it is necessary to adapt the system's dialing plan to route cell phone calls to the ATI. Therefore, the rule that forwards the call for consultation must be inserted within the outgoing context of your extensions, following the following configuration:
<extension name=”Consulta_ATI”>
<condition field=”destination_number” expression=”^([1-9]{2}[6-9][0-9]{7}$)”>
<action application=”export” data=”sip_redirect_context=default”/>
<action application=”bridge” data=”sofia/gateway/ATI/$1″/>
</condition>
</extension>
<extension name=”Consulta_ATI_Sao_Paulo”>
<condition field=”destination_number” expression=”(^119[0-9]{8}$)”>
<action application=”export” data=”sip_redirect_context=default”/>
<action application=”bridge” data=”sofia/gateway/ATI/$1″/>
</condition>
</extension>
Note that two rules were created, one dealing with cell phone calls only for São Paulo, where numbers have 9 digits, and another for the rest of Brazil. Also note that the ATI response will be treated in the default context, through the configuration . If it is necessary for this response to be treated in a different context, simply replace default with the name of the context in question.
Once the ATI gateway and query rules have been created, simply create the rules that will handle the query response. Therefore, simply enter the following rules:
<extension name=”Rota_Tim”>
<condition field=”destination_number” expression=”(^55341)(d*$)”>
<action application=”bridge” data=”khomp/b0c0/041$2″/>
</condition>
</extension>
<extension name=”Rota_Vivo”>
<condition field=”destination_number” expression=”(^55323|55320)(d*$)”>
<action application=”bridge” data=”khomp/b0c1/020$2″/>
</condition>
</extension>
<extension name=”Rota_Claro”>
<condition field=”destination_number” expression=”(^55321)(d*$)”>
<action application=”bridge” data=”khomp/b0c2/021$2″/>
</condition>
</extension>
<extension name=”Rota_Oi”>
<condition field=”destination_number” expression=”(^55314|55331)(d*$)”>
<action application=”bridge” data=”khomp/b0c3/031$2″/>
</condition>
</extension>
For this example, the cellular interface we used was from Khomp, therefore, the data from the bridge application must be replaced according to its configuration and the lowest cost route for operators.
After carrying out these configurations, simply enter the FreeSWITCH CLI and reload the sofia (responsible for SIP) and dialplan_xml (responsible for the dial plan) modules. With this, your FreeSWITCH will already be configured to make cell phone calls via the lowest cost route through the ATI system.
If you have any questions or difficulties configuring your system, please contact our team supportpulse@sippulse.com.