Provider Configuration: VoipCheap

From FreeSWITCH Wiki
Jump to: navigation, search

About VoipCheap

Voipcheap is one of the VoIP wholesale labels of a German company called Betamax GmbH & Co.Kg.. See wikipedia for more info on their labels. Voipcheap offers low cost PSTN termination all over the world and even to some countries for free. Besides SIP they also provide their own softphone.

To make SIP working with freeswitch make sure the contact field include the username. For example, if my username is USER1, the contact field will look like:

Contact: <sip:USER1@IPADDRESS:5080;transport=udp;gw=voipcheap.com>

If you don't include the username in the contact field you will NOT be able to get incoming calls from their DIDs or the voipcheap network. To make this work add the following param in you gateway configuration:

<param name="extension-in-contact" value="true"/>

Working example

Below is a copy of a fully (incoming and outgoing) working configuration. Replace USERNAME and PASSWORD with your own. Gateway configuration: conf/sip_profiles/external/voipcheap.xml

<include>
  <gateway name="voipcheap">
    <param name="username" value="USERNAME"/>
    <param name="realm" value="sip.voipcheap.com"/>
    <param name="password" value="PASSWORD"/>
    <param name="register" value="true"/>
    <param name="extension-in-contact" value="true"/>
    <param name="context" value="public"/>
  </gateway>
</include>

Incoming dialplan: conf/dialplan/public/0_voipcheap_did.xml

<include>
  <extension name="public_did">
    <condition field="destination_number" expression="^(USERNAME)$">
      <action application="set" data="domain_name=$${domain}"/>
      <!-- This example maps the DID 5551212 to ring 1000 in the default context -->
      <action application="transfer" data="1000 XML default"/>
    </condition>
  </extension>
</include>

Outgoing dialplan: conf/dialplan/default.xml

<extension name="voipcheap_out" continue="true">
  <condition field="source" expression="mod_sofia"/>
  <condition field="${domain_exists(${sip_req_host})}" expression="false"/>
  <condition field="${sip_req_host}" expression="voipcheap.com">
    <action application="bridge" data="sofia/gateway/voipcheap/${sip_to_user}@sip.${sip_to_host}"/>
  </condition>
</extension>

The outgoing dialplan compares the domainname (the name after the @ sign) against the local domainname. If it's not true (what should always be) it passes the condition. The variabele domainname comes from ${sip_req_host}. Since the invite needs to go to the Voipcheap proxy server (sip.voipcheap.com) you have to insert sip. otherwise it connects NOT to the proxy. So instead of calling USER@DOMAIN, we're gonna call to USER@sip.DOMAIN.