Learn FreeSWITCH part 6 SIP Profile, Directory and Dialplan - luanrFreitas/freeswitch GitHub Wiki

Video on Youtube: https://www.youtube.com/watch?v=nSj1htnz4vE

Defining a SIP profile in FreeSWITCH:

vim /etc/freeswitch/sip_profiles/omid.xml

<profile name="omid">
        <aliases></aliases>
        <domains>
                <domain name="all" alias="true" parse="false"/>
        </domains>
        <settings>
                <param name="sip-ip" value="139.59.210.202"/>
                <param name="rtp-ip" value="139.59.210.202"/>
                <param name="sip-port" value="5070"/>
                <param name="context" value="public"/>
                <param name="auth-calls" value="true"/>
        </settings>
</profile>

Note: Change the IP address to the IP address of your server

Starting a SIP profile in FreeSWITCH:

fs_cli
sofia profile omid start

Checking if profile is running

We can check if the server is listening on the port specified in the omid.xml sip profile by netstats command

netstats -na | grep 5070


Defining Users in FreeSWITCH

vim /etc/freeswitch/directory/company-a.xml

<include>
        <domain name="company-a.omid.blog">
    <params>
      <param name="dial-string" value="{^^:sip_invite_domain=${dialed_domain}:presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(*/${dialed_user}@${dialed_domain})},${verto_contact(${dialed_user}@${dialed_domain})}"/>
      <param name="jsonrpc-allowed-methods" value="verto"/>
    </params>

    <variables>
      <variable name="record_stereo" value="true"/>
      <variable name="default_gateway" value="$${default_provider}"/>
      <variable name="default_areacode" value="$${default_areacode}"/>
      <variable name="transfer_fallback_extension" value="operator"/>
    </variables>

    <groups>
      <group name="company-a">
        <users>
          <X-PRE-PROCESS cmd="include" data="company-a/*.xml"/>
        </users>
      </group>
      </groups>
  </domain>
</include>

mkdir /etc/freeswitch/directory/company-a

vim /etc/freeswitch/direcotry/company-a/1000.xml

<include>
  <user id="1000">
    <params>
      <param name="password" value="abc.1000"/>
    </params>
    <variables>
      <variable name="user_context" value="company-a"/>
    </variables>
  </user>
</include

vim /etc/freeswitch/directory/company-a/1001.xml

<include>
  <user id="1001">
    <params>
      <param name="password" value="$${default_password}"/>
      <param name="vm-password" value="1001"/>
    </params>
    <variables>
      <variable name="toll_allow" value="domestic,international,local"/>
      <variable name="accountcode" value="1001"/>
      <variable name="user_context" value="company-a"/>
      <variable name="effective_caller_id_name" value="Extension 1001"/>
      <variable name="effective_caller_id_number" value="1001"/>
      <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>

DialPlan for company-a

-- INSERT --                                                                                 7,2-9         All
<?xml version="1.0" encoding="utf-8"?>
<include>
  <context name="company-a">

   <extension name="hello_world">
    <condition field ="destination_number" expression "^(123456)$">
     <action application="log" data="------ ${caller_id_number} from Comapny A called  ${destination_number}  ------"/>
     <action application="playback" data="misc/misc-fss_contact_us.wav"/>
    </condition>
   </extension>

   <extension name="extension-intercom">
    <condition field="destination_number" expression="^(100[0-1])$">
     <action application="set" data="dialed_extension=$1"/>
     <action application="bridge" data="user/${dialed_extension}@${domain_name}"/>
    </condition>
   </extension>

   </context>
</include>
⚠️ **GitHub.com Fallback** ⚠️