[Freeswitch-users] Have you seen FreeSWITCH's Tips and Tricks?

Kathleen King marketing at cluecon.com
Wed Jan 25 06:09:20 MSK 2017


​

Hello FreeSWITCHers!
The FreeSWITCH team is working hard on getting version 1.8 ready for
release. While you wait, we thought you might be interested in learning a
few FreeSWITCH tricks you can try yourself. We had a look into our cookbook
and found a few recipes you may be interested in. Have a look and don't
forget you can learn even more about FreeSWITCH and other open source
projects at ClueCon 2017 http://cluecon.com
<http://freeswitch.us13.list-manage.com/track/click?u=73f7dcee16e0a87ece76c372d&id=14ace00040&e=a45f2f7d64>
Don't miss our early bird pricing available for only a short time!
*Simple Call Failover*


​
How often do you miss a customer’s phone call? It always seems like the
phone rings at the most inconvenient time and ends just before you can get
to it. Wouldn’t it be great if instead of going to voicemail it just rang
your co-worker? Well, FreeSWITCH has a solution for you. What if you didn’t
have to answer those calls by yourself? In the FreeSWITCH dialplan you can
configure something called Simple Call Failover. What this means is a call
comes in and rings multiple endpoints (two separate desk phones in this
example, one right after the other) and the person that answers is
connected to the call. That way if you are busy someone else can answer
that call and keep the customers happy.

To set this up open up your dialplan, in this example we will use the
default located at conf/dialplan/default.xml in a text editor in our
terminal. Navigate to the extension you would like to use and add these
lines:
<extension name="failover_example">
 <condition field="destination_number" expression="^(1000)$">
    <action application="bridge" data="{ignore_early_media=
true}sofia/internal/first at domain.com|sofia/internal/second at domain.com"/>
 </condition>
</extension>

By adding a pipe between your endpoints you are telling FreeSWITCH to dial
those endpoints sequentially. The first one that is successfully connected
will get the call and FreeSWITCH will cease dialing the additional
endpoints. Now, to do this FreeSWITCH needs to ignore any early media like
ringing so we added ignore_early_media=true at the beginning to tell
FreeSWITCH to only connect the call when it is answered. It is as easy as
that.
*Time of Day Routing*

​​
Did you know you can configure FreeSWITCH to route to certain extensions
based on the time of day? This is particularly convenient if you want to
play a different greeting based on your office’s hours. To configure this
you first need to define some variables for FreeSWITCH to use as a
reference. For this example, we will assume our office is open 8:00 a.m. to
4:00 p.m. We start by adding this extension to the beginning of your
dialplan context:

<extension name="Time of day, day of week example" continue="true">
 <condition wday="2-6" hour="8-15" break="never">
  <action application="set" data="office_status=open" inline="true"/>
  <anti-action application="set" data="office_status=closed"
inline="true"/>
 </condition>
</extension>
Now you can use the previously defined variables to set your extensions. In
the example below FreeSWITCH will first check to see if the office is open
or closed based on the first condition we defined. After that, FreeSWITCH
will then execute whichever dialplan extension is necessary depending on
the value of ‘office_status’ in the first condition. This configuration
allows you to set specific actions depending on the time of day and what
you would like your IVR to do. In this example we are initiating a
particular IVR depending on whether the office is open or closed.

<extension name="Office_Hours, 2001_X">
 <condition field="destination_number" expression="^(2001)$">
  <action application="execute_extension" data="2001_${office_status}"/>
 </condition>
</extension>
<extension name="Open">
 <condition field="destination_number" expression="^(2001_open)$">
  <action application="answer"/>
  <action application="sleep" data="1000"/>
  <action application="sleep" data="500"/><!-- Open IVR -->
 </condition>
</extension>
<extension name="Closed">
 <condition field="destination_number" expression="^(2001_closed)$">
  <action application="answer"/>
  <action application="sleep" data="1000"/>
  <action application="sleep" data="500"/><!-- Closed IVR -->
 </condition>
</extension>
We have also added continue=”true” and break=”never” in our conditions.
These tell FreeSWITCH to keep looking for more matches and without them
FreeSWITCH would stop. Additionally, it should be noted that by setting
variables we can easily allow for more conditions. If we were to set the
“open” and “closed” extensions in an action tag and anti-action tag we are
limited by only two options. In our current example you could go on to add
things like lunch or holiday hours.

*Manipulating SIP Request URIs*


Another cool feature in FreeSWITCH is the ability to manipulate SIP To:
Headers. You can use customized SIP To: Headers when routing calls to
endpoints registered within your setup. This lets you send the DID in cases
where a single registration is representing multiple DIDs. There isn’t a
single flag to set in order to do this so you will have to configure your
dialplan to grab the user’s registration information and parse out the
username, replacing it with your custom setting. Be sure to only replace
the username to prevent issues with things like NAT traversal.

For this example, we have configured DID 123-456-7890, a username of
user01, and domain of example.com. Our example extension will look like
this:
<extension name="call_1234567890">
 <condition field="destination_number" expression="^(?:\+1|1)?1234567890$"/>
 <condition field="${sofia_contact(user01 at example.com)}"
expression="^[^\@]+(.*)">
  <action application="bridge" data="sofia/external/123457890$1"/>
 </condition>
</extension>
This example shows the extension grabbing the user01 dial string and
replacing the username with the preferred DID. In the first condition we
are matching the determined DID and only if the incoming call matches that
DID will the extension execute the actions. The second condition uses the
results of an API, sofia_contact, to return the results as a value. This
puts everything after the @ into the $1 variable which is then called
during the bridge after our custom header. This preserves all the
information required for contacting the server and sending the call to the
correct destination.


Be sure to register at https://cluecon.com
<http://freeswitch.us13.list-manage.com/track/click?u=73f7dcee16e0a87ece76c372d&id=ff3d693fbf&e=a45f2f7d64>
for
ClueCon 2017 to see all the latest and greatest the open-source community
has to offer!
<http://freeswitch.us13.list-manage.com/track/click?u=73f7dcee16e0a87ece76c372d&id=9b55e81853&e=a45f2f7d64>
For other tips like these, subscribe to our YouTube channel at
https://youtube.com/freeswitch
<http://freeswitch.us13.list-manage2.com/track/click?u=73f7dcee16e0a87ece76c372d&id=3e6b4f94a7&e=a45f2f7d64>
or
check for our books at https://freeswitch.org
<http://freeswitch.us13.list-manage.com/track/click?u=73f7dcee16e0a87ece76c372d&id=85f249dbd7&e=a45f2f7d64>

<http://freeswitch.us13.list-manage.com/track/click?u=73f7dcee16e0a87ece76c372d&id=ca614c2d5e&e=a45f2f7d64>
<http://freeswitch.us13.list-manage2.com/track/click?u=73f7dcee16e0a87ece76c372d&id=8869b95b17&e=a45f2f7d64>
<http://freeswitch.us13.list-manage2.com/track/click?u=73f7dcee16e0a87ece76c372d&id=3d15cc459f&e=a45f2f7d64>
*Copyright © 2017 FreeSWITCH Solutions, All rights reserved.*
This is a mailing list for all things ClueCon! You have been subscribed to
this list because you subscribed to the FreeSWITCH Users mailing list. If
you would like to unsubscribe please follow the directions.

*Our mailing address is:*
FreeSWITCH Solutions
17345 Civic Drive #2531
Brookfield, WI 53045

Add us to your address book
<http://freeswitch.us13.list-manage.com/vcard?u=73f7dcee16e0a87ece76c372d&id=8de1531556>


Want to change how you receive these emails?
You can update your preferences
<http://freeswitch.us13.list-manage.com/profile?u=73f7dcee16e0a87ece76c372d&id=8de1531556&e=a45f2f7d64>
or unsubscribe from this list
<http://freeswitch.us13.list-manage.com/unsubscribe?u=73f7dcee16e0a87ece76c372d&id=8de1531556&e=a45f2f7d64&c=ab22542a17>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170124/799591fa/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clock.png
Type: image/png
Size: 33527 bytes
Desc: not available
Url : http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170124/799591fa/attachment-0004.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cluecon new logo.jpg
Type: image/jpeg
Size: 322893 bytes
Desc: not available
Url : http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170124/799591fa/attachment-0002.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: failover.png
Type: image/png
Size: 204591 bytes
Desc: not available
Url : http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170124/799591fa/attachment-0005.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fs_books.png
Type: image/png
Size: 112508 bytes
Desc: not available
Url : http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170124/799591fa/attachment-0006.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeswitch_youtube.jpg
Type: image/jpeg
Size: 95721 bytes
Desc: not available
Url : http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170124/799591fa/attachment-0003.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RURI.png
Type: image/png
Size: 633180 bytes
Desc: not available
Url : http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170124/799591fa/attachment-0007.png 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list