fb

FreeSwitch

Configuring Freeswitch for Zadarma.

Key to the information which appears in the example:

  • 111111: Your sip number from personal account.
  • Password: Your password of sip number from section "SIP-settings" personal account.
  • 1000: Freeswitch extension number that connects to the softphone / ip-phone, in order to receive incoming calls and make outgoing calls.
1. Create a file /etc/freeswitch/sip_profiles/external/zadarma.xml

<include>
<gateway name="zadarma">
<param name="username" value="111111"/>
<param name="password" value="Password"/>
<param name="realm" value="sip.zadarma.com"/>
<param name="from-user" value="111111"/>
<param name="from-domain" value="sip.zadarma.com"/>
<param name="proxy" value="sip.zadarma.com"/>
<param name="expire-seconds" value="300"/>
<param name="register" value="true"/>
<param name="register-transport" value="udp"/>
<param name="context" value="zadarma"/>
</gateway>
</include>
2. Create a configuration file Dialplan /etc/freeswitch/dialplan/zadarma.xml

<?xml version="1.0" encoding="UTF-8"?>
<include>
<context name="zadarma">

<extension name="unloop">
        <condition field="$${unroll_loops}" expression="^true$" />
        <condition field="${sip_looped_call}" expression="^true$">
        <action application="deflect" data="${destination_number}" />
        </condition>
</extension>

<extension name="in-zadarma">
    <condition field="destination_number" expression="^(111111)$">
    <action application="bridge" data="user/1000@$${domain}"/>
    <action application="hangup"/>
    </condition>
</extension>

<extension name="out-zadarma">
    <condition field="destination_number" expression="^(\d{10,15})$">
    <action application="bridge" data="sofia/gateway/zadarma/$1"/>
    <action application="hangup"/>
    </condition>
</extension>

<extension name="local">
    <condition field="destination_number" expression="^\d{4}$">
    <action application="answer" />
    <action application="sleep" data="1000" />
    <action application="bridge" data="user/${destination_number}@$${domain}" />
    <action application="hangup" />
    </condition>
</extension>


</context>
</include>
3. Create a Freeswitch extension number that connects to the softphone / ip-phone in order to receive incoming calls and make outgoing calls. Edit the file /etc/freeswitch/directory/default/1000.xml

<include>
  <user id="1000">
    <params>
      <param name="password" value="your_hard_pasword"/>
      <param name="vm-password" value="1000"/>
    </params>
    <variables>
      <variable name="toll_allow" value="domestic,international,local"/>
      <variable name="accountcode" value="1000"/>
      <variable name="user_context" value="zadarma"/>
      <variable name="effective_caller_id_name" value="Extension 1000"/>
      <variable name="effective_caller_id_number" value="1000"/>
      <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
      <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
      <variable name="callgroup" value="techsupport"/>
    </variables>
  </user>
</include>
To reload xml execute console command fs_cli reloadxml

Configuration is complete.