{"id":561,"date":"2011-03-10T13:19:29","date_gmt":"2011-03-10T20:19:29","guid":{"rendered":"http:\/\/www.michel2010.name\/blog\/?p=561"},"modified":"2011-03-10T13:19:29","modified_gmt":"2011-03-10T20:19:29","slug":"freeswitch-howto-configuration","status":"publish","type":"post","link":"https:\/\/blog.michel2010.name\/eric\/2011\/03\/10\/freeswitch-howto-configuration\/","title":{"rendered":"Freeswitch Howto: Configuration"},"content":{"rendered":"<p>In this section I&#8217;m going to focus\u00a0exclusively\u00a0on calling in and out over the POTS lines. \u00a0I&#8217;m doing this for two reasons. \u00a0One, this was the part I had the most trouble with, and two, the other dialplan options are (or seem to me to be) better documented. \u00a0I would suggest buying the <a href=\"https:\/\/www.packtpub.com\/freeswitch-1-0-6-build-robust-high-performance-telephony-systems\/book\" target=\"_blank\">Freeswitch book<\/a>. \u00a0It&#8217;s been very helpful to me, though some if the information is outdated.<\/p>\n<p>When setting up in-bound and out-bound analog calling (using the freetdm mod which was enabled on install) we deal with these files(these are all in the default install locations, if you installed some where else you&#8217;ll have to adjust accordingly):<\/p>\n<p>\/usr\/local\/freeswitch\/conf\/freetdm.conf<br \/>\n\/usr\/local\/freeswitch\/conf\/autoload_configs\/freetdm.conf.xml<br \/>\n\/usr\/local\/freeswitch\/conf\/dialplan\/default.xml<br \/>\n\/usr\/local\/freeswitch\/conf\/dialplan\/public\/00_inbound_did.xml<\/p>\n<p>I&#8217;ll post these, and go through the ones I know.<\/p>\n<h3>\/usr\/local\/freeswitch\/conf\/freetdm.conf<\/h3>\n<pre>[span wanpipe FXS]\nname =&gt; freetdm\ntrunk_type =&gt; fxs\ngroup =&gt; grp1\nfxs-channel =&gt; 1:7\n\ntrunk_type =&gt; fxs\ngroup =&gt; grp1\nfxs-channel =&gt; 1:8\n\n[span wanpipe FXO]\n\nname =&gt; freetdm\ntrunk_type =&gt; fxo\ngroup =&gt; grp2\nfxo-channel =&gt; 1:1\n\ntrunk_type =&gt; fxo\ngroup =&gt; grp2\nfxo-channel =&gt; 1:2\n\ntrunk_type =&gt; fxo\ngroup =&gt; grp2\nfxo-channel =&gt; 1:3\n\ntrunk_type =&gt; fxo\ngroup =&gt; grp2\nfxo-channel =&gt; 1:4\n\ntrunk_type =&gt; fxo\ngroup =&gt; grp2\nfxo-channel =&gt; 1:5\n\ntrunk_type =&gt; fxo\ngroup =&gt; grp2\nfxo-channel =&gt; 1:6<\/pre>\n<p>Now to be honest I didn&#8217;t actually configure this file, or\u00a0freetdm.conf.xml. \u00a0When \/usr\/sbin\/wancfg_fs was run it automatically set both of these files up. \u00a0I didn&#8217;t have to change either of them.<\/p>\n<h3>\/usr\/local\/freeswitch\/conf\/autoload_configs\/freetdm.conf.xml<\/h3>\n<p>&lt;analog_spans&gt;<br \/>\n&lt;span name=&#8221;FXO&#8221;&gt;<br \/>\n&lt;!&#8211;&lt;param name=&#8221;hold-music&#8221; value=&#8221;$${moh_uri}&#8221;\/&gt;&#8211;&gt;<br \/>\n&lt;param name=&#8221;dialplan&#8221; value=&#8221;XML&#8221;\/&gt;<br \/>\n&lt;param name=&#8221;context&#8221; value=&#8221;public&#8221;\/&gt;<br \/>\n&lt;!&#8211; regex to stop dialing when it matches &#8211;&gt;<br \/>\n&lt;!&#8211;&lt;param name=&#8221;dial-regex&#8221; value=&#8221;5555&#8243;\/&gt;&#8211;&gt;<br \/>\n&lt;!&#8211; regex to stop dialing when it does not match &#8211;&gt;<br \/>\n&lt;!&#8211;&lt;param name=&#8221;fail-dial-regex&#8221; value=&#8221;^5&#8243;\/&gt;&#8211;&gt;<br \/>\n&lt;\/span&gt;<\/p>\n<p>&lt;span name=&#8221;FXS&#8221;&gt;<br \/>\n&lt;!&#8211;&lt;param name=&#8221;hold-music&#8221; value=&#8221;$${moh_uri}&#8221;\/&gt;&#8211;&gt;<br \/>\n&lt;param name=&#8221;dialplan&#8221; value=&#8221;XML&#8221;\/&gt;<br \/>\n&lt;param name=&#8221;context&#8221; value=&#8221;default&#8221;\/&gt;<br \/>\n&lt;!&#8211; regex to stop dialing when it matches &#8211;&gt;<br \/>\n&lt;!&#8211;&lt;param name=&#8221;dial-regex&#8221; value=&#8221;5555&#8243;\/&gt;&#8211;&gt;<br \/>\n&lt;!&#8211; regex to stop dialing when it does not match &#8211;&gt;<br \/>\n&lt;!&#8211;&lt;param name=&#8221;fail-dial-regex&#8221; value=&#8221;^5&#8243;\/&gt;&#8211;&gt;<br \/>\n&lt;\/span&gt;<br \/>\n&lt;\/analog_spans&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>Now we get to the good stuff. \u00a0I took this from my default dial plan. \u00a0It only shows one of our five lines, but it should be enough to get you headed in the right direction.<\/p>\n<h3>\/usr\/local\/freeswitch\/conf\/dialplan\/default.xml<\/h3>\n<p>&lt;extension name=&#8221;Call out business hours(Staff)&#8221; continue=&#8221;true&#8221;&gt;<br \/>\n&lt;condition field=&#8221;ani&#8221; expression=&#8221;^(1014|1015)&#8221; break=&#8221;on-true&#8221;\/&gt;<br \/>\n&lt;condition wday=&#8221;2-6&#8243; hour=&#8221;9-18&#8243;\/&gt;<br \/>\n&lt;!&#8211; The call out prefix is 7 &#8211;&gt;<br \/>\n&lt;condition field=&#8221;destination_number&#8221; expression=&#8221;^7(.+)$&#8221;&gt;<br \/>\n&lt;action application=&#8221;set&#8221; data=&#8221;hangup_after_bridge=true&#8221;\/&gt;<br \/>\n&lt;action application=&#8221;set&#8221; data=&#8221;continue_on_fail=true&#8221;\/&gt;<br \/>\n&lt;action application=&#8221;bridge&#8221; data=&#8221;freetdm\/FXO\/2\/$1&#8243;\/&gt;<br \/>\n&lt;action application=&#8221;bridge&#8221; data=&#8221;freetdm\/FXO\/3\/$1&#8243;\/&gt;<br \/>\n&lt;action application=&#8221;bridge&#8221; data=&#8221;freetdm\/FXO\/4\/$1&#8243;\/&gt;<br \/>\n&lt;action application=&#8221;bridge&#8221; data=&#8221;freetdm\/FXO\/5\/$1&#8243;\/&gt;<br \/>\n&lt;action application=&#8221;bridge&#8221; data=&#8221;freetdm\/FXO\/1\/$1&#8243;\/&gt;<br \/>\n&lt;action application=&#8221;playback&#8221; data=&#8221;phrase:oh_gee&#8221;\/&gt;<br \/>\n&lt;\/condition&gt;<br \/>\n&lt;\/extension&gt;<\/p>\n<p>The break down:<\/p>\n<p style=\"padding-left: 30px;\">&lt;extension name=&#8221;Call out business hours(Staff)&#8221; continue=&#8221;true&#8221;&gt;<\/p>\n<p>This is simply the extension name. I have continue set to true. I didn&#8217;t think I needed it but it wouldn&#8217;t work without it.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">&lt;condition field=&#8221;ani&#8221; expression=&#8221;^(1014|1015)&#8221; break=&#8221;on-true&#8221;\/&gt;<\/p>\n<p>I have two phones that I don&#8217;t want dialing out on this extension. If phones 1014 or 1015 are dialing the number they won&#8217;t go out through this extension.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">&lt;condition wday=&#8221;2-6&#8243; hour=&#8221;9-18&#8243;\/&gt;<\/p>\n<p><!-- \t\t@page { margin: 0.79in } \t\tP { margin-bottom: 0.08in } --><span style=\"color: #000000;\"><span style=\"font-family: Verdana, sans-serif;\"><span style=\"font-size: small;\">This extension only works Monday through Friday between nine in the morning and six at night.<\/span><\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #000000;\"><span style=\"font-family: Verdana, sans-serif;\"><span style=\"font-size: small;\">&lt;condition field=&#8221;destination_number&#8221; expression=&#8221;^7(.+)$&#8221;&gt;<\/span><\/span><\/span><\/p>\n<p><!-- \t\t@page { margin: 0.79in } \t\tP { margin-bottom: 0.08in } --><span style=\"color: #000000;\"><span style=\"font-family: Verdana, sans-serif;\"><span style=\"font-size: small;\">Our \u201ccall out\u201d number is seven. If seven is dialed before the number it is an external call and will be run through this extension.<\/span><\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #000000;\"><span style=\"font-family: Verdana, sans-serif;\"><span style=\"font-size: small;\">&lt;action application=&#8221;set&#8221; data=&#8221;hangup_after_bridge=true&#8221;\/&gt;<\/span><\/span><\/span><\/p>\n<p><!-- \t\t@page { margin: 0.79in } \t\tP { margin-bottom: 0.08in } --><span style=\"color: #000000;\"><span style=\"font-family: Verdana, sans-serif;\"><span style=\"font-size: small;\">I&#8217;m not sure why this is important but I needed it.<\/span><\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #000000;\"><span style=\"font-family: Verdana, sans-serif;\"><span style=\"font-size: small;\">&lt;action application=&#8221;set&#8221; data=&#8221;continue_on_fail=true&#8221;\/&gt;<\/span><\/span><\/span><\/p>\n<p>If you remember we have five outgoing phone lines (POTS). If one of them is busy (it fails to connect) I want to try the next phone line.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">&lt;action application=&#8221;bridge&#8221; data=&#8221;freetdm\/FXO\/2\/$1&#8243;\/&gt;<\/p>\n<p>This is the good part. This actually does the calling. The \u201cfreetdm\/FXO\/2\u201d references freetdm.conf.xml. Span FXO, line 2. The \u201c$1\u201d is the number the person is calling. If line 2 is busy it \u201ccontinue_on_fail=true\u201d so it tries the next one (and so on and so forth).<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">&lt;action application=&#8221;playback&#8221; data=&#8221;phrase:oh_gee&#8221;\/&gt;<\/p>\n<p>This last line is simply a message, I recorded. If all the phone lines are in use this message gets played and the call ends.<\/p>\n<p>&nbsp;<\/p>\n<h3>Incoming Calls<\/h3>\n<p>This was by far the hardest part for me. Thanks to Steve on the Freeswitch mailing list for explaining it to me.<\/p>\n<p>First let me explain what I was trying to do. Like I said earlier, we have five POTS lines. I needed to direct incoming calls from each line individually to different phones (and or groups) on campus. Where the calls get directed depends on the time of day and the particular phone line in question (I hope that isn&#8217;t to confusing).<\/p>\n<h3>\/usr\/local\/freeswitch\/conf\/dialplan\/public\/00_inbound_did.xml<\/h3>\n<p><span>&lt;!&#8211; LINE1 328-6825&#8211;&gt;<br \/>\n&lt;!&#8211; during work hours will ring the &#8220;Administration&#8221; phones &#8211;&gt;<br \/>\n&lt;extension name=&#8221;Line 1(6825) work&#8221; continue=&#8221;true&#8221;&gt;<br \/>\n&lt;condition field=&#8221;source&#8221; expression=&#8221;mod_freetdm&#8221;\/&gt;<br \/>\n&lt;condition wday=&#8221;2-6&#8243; hour=&#8221;9-18&#8243;\/&gt;<br \/>\n&lt;condition field=&#8221;${channel_name}&#8221; expression=&#8221;^(FreeTDM\/2:1\/)$&#8221;&gt;<br \/>\n&lt;action application=&#8221;set&#8221; data=&#8221;domain_name=$${domain}&#8221;\/&gt;<br \/>\n&lt;action application=&#8221;set&#8221; data=&#8221;transfer_ringback=$${us-ring}&#8221;\/&gt;<br \/>\n&lt;action application=&#8221;transfer&#8221; data=&#8221;2020 XML default&#8221;\/&gt;<br \/>\n&lt;\/condition&gt;<br \/>\n&lt;\/extension&gt;<\/span><\/p>\n<p><span> &lt;!&#8211; During off hours goes to everyone except Kitchen and Guests &#8211;&gt;<br \/>\n&lt;extension name=&#8221;Line 1(6825) not work&#8221; continue=&#8221;true&#8221;&gt;<br \/>\n&lt;condition field=&#8221;source&#8221; expression=&#8221;mod_freetdm&#8221;\/&gt;<br \/>\n&lt;condition field=&#8221;${channel_name}&#8221; expression=&#8221;^(FreeTDM\/2:1\/)$&#8221;&gt;<br \/>\n&lt;action application=&#8221;set&#8221; data=&#8221;domain_name=$${domain}&#8221;\/&gt;<br \/>\n&lt;action application=&#8221;set&#8221; data=&#8221;transfer_ringback=$${us-ring}&#8221;\/&gt;<br \/>\n&lt;action application=&#8221;transfer&#8221; data=&#8221;2035 XML default&#8221;\/&gt;<br \/>\n&lt;\/condition&gt; &lt;\/extension&gt;<br \/>\n&lt;!&#8211; LINE1 DONE&#8211;&gt;<\/span><\/p>\n<p>Again, line by line:<\/p>\n<p style=\"padding-left: 30px;\">&lt;extension name=&#8221;Line 1(6825) work&#8221; continue=&#8221;true&#8221;&gt;<\/p>\n<p>This is simply the extension name. I have continue set to true. I&#8217;m pretty sure I need it, and it works with it enabled.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">&lt;condition field=&#8221;source&#8221; expression=&#8221;mod_freetdm&#8221;\/&gt;<\/p>\n<p>This tells Freeswitch the source of the inbound call (pretty self explanatory).<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">&lt;condition wday=&#8221;2-6&#8243; hour=&#8221;9-18&#8243;\/&gt;<\/p>\n<p>This extension only works Monday through Friday between nine in the morning and six at night.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">&lt;condition field=&#8221;${channel_name}&#8221; expression=&#8221;^(FreeTDM\/2:1\/)$&#8221;&gt;<\/p>\n<p>This tests to see what line is calling from the \u201cmod_freetdm\u201d source. My FXO ports are in the second span of my freetdm.conf, \u00a0so \u201cFreeTDM\/2:1\/\u201d is span two line 1. This is the part I got from Steve, and I couldn&#8217;t find this information any where.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">&lt;action application=&#8221;set&#8221; data=&#8221;domain_name=$${domain}&#8221;\/&gt;<\/p>\n<p>I have no idea what this does but I know I need it.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">&lt;action application=&#8221;set&#8221; data=&#8221;transfer_ringback=$${us-ring}&#8221;\/&gt;<\/p>\n<p>I&#8217;m assuming this changes depending on the country you live in.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px;\">&lt;action application=&#8221;transfer&#8221; data=&#8221;2020 XML default&#8221;\/&gt;<\/p>\n<p>This transfers the incoming call to (in my case) group 2020 in the default dial plan. It can be replaced with any valid extension number.<\/p>\n<p>The second extension (again this is just for one of our phone lines. \u00a0Each line will need an extension) is for off hours and weekends.<\/p>\n<p>&nbsp;<\/p>\n<h2>Faxing<\/h2>\n<p>We have an analog fax machine, which is why I needed the FXS modules on my Sagnoma card. \u00a0Here are the relevant dialplan parts I used to send and receive faxes.<\/p>\n<p>&nbsp;<\/p>\n<h3>Receiving a Fax<\/h3>\n<p>This gets set up in the public dialplan. \u00a0On our install \/usr\/local\/freeswitch\/dialplan\/public\/00_inbound_did.xml.<\/p>\n<p>&lt;!&#8211; LINE3 328-6982&#8211;&gt;<br \/>\n&lt;!&#8211; Always directed to the fax machine &#8211;&gt;<br \/>\n&lt;extension name=&#8221;Line 3(6982)&#8221; continue=&#8221;true&#8221;&gt;<br \/>\n&lt;condition field=&#8221;source&#8221; expression=&#8221;mod_freetdm&#8221;\/&gt;<br \/>\n&lt;condition field=&#8221;${channel_name}&#8221; expression=&#8221;^(FreeTDM\/2:3\/)$&#8221;&gt;<br \/>\n&lt;action application=&#8221;set&#8221; data=&#8221;domain_name=$${domain}&#8221;\/&gt;<br \/>\n&lt;action application=&#8221;set&#8221; data=&#8221;transfer_ringback=$${us-ring}&#8221;\/&gt;<br \/>\n&lt;action application=&#8221;bridge&#8221; data=&#8221;freetdm\/2\/3|freetdm\/1\/1&#8243;\/&gt;<br \/>\n&lt;\/condition&gt;<br \/>\n&lt;\/extension&gt;<br \/>\n&lt;!&#8211; LINE3 DONE&#8211;&gt;<\/p>\n<p style=\"padding-left: 30px;\">&lt;action application=&#8221;bridge&#8221; data=&#8221;freetdm\/2\/3|freetdm\/1\/1&#8243;\/&gt;<\/p>\n<p>This is the important one. \u00a0It takes the incoming call from span 2 line 3 and transfers it to span 1 line 1.<\/p>\n<p>&nbsp;<\/p>\n<h3>Sending a Fax<\/h3>\n<p>This gets set up in the default dialplan. \u00a0On our install \/usr\/local\/freeswitch\/conf\/dialplan\/default.xml.<\/p>\n<p>&lt;extension name=&#8221;bridge-FXS-to-FXO&#8221; continue=&#8221;true&#8221;&gt;<br \/>\n&lt;condition field=&#8221;destination_number&#8221; expression=&#8221;^7(.+)$&#8221;\/&gt;<br \/>\n&lt;condition field=&#8221;channel_name&#8221; expression=&#8221;FreeTDM\/1:1\/&#8221;&gt;<br \/>\n&lt;action application=&#8221;bridge&#8221; data=&#8221;freetdm\/1\/1\/${destination_number}|freetdm\/2\/3\/${destination_number}&#8221;\/&gt;\u00a0\u00a0 &lt;\/condition&gt;<br \/>\n&lt;\/extension&gt;<\/p>\n<p style=\"padding-left: 30px;\">&lt;condition field=&#8221;channel_name&#8221; expression=&#8221;FreeTDM\/1:1\/&#8221;&gt;<br \/>\n&lt;action application=&#8221;bridge&#8221; data=&#8221;freetdm\/1\/1\/${destination_number}|freetdm\/2\/3\/${destination_number}&#8221;\/&gt;\u00a0\u00a0 &lt;\/condition&gt;<\/p>\n<p>These are the two lines that work the magic. \u00a0I got this off the Freeswitch wiki. \u00a0Direct span 1 line 1 to span 2 line 3 and dial the number. \u00a0Presto the fax goes out.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this section I&#8217;m going to focus\u00a0exclusively\u00a0on calling in and out over the POTS lines. \u00a0I&#8217;m doing this for two reasons. \u00a0One, this was the part I had the most trouble with, and two, the other dialplan options are (or seem to me to be) better documented. \u00a0I would suggest buying the Freeswitch book. \u00a0It&#8217;s &hellip; <a href=\"https:\/\/blog.michel2010.name\/eric\/2011\/03\/10\/freeswitch-howto-configuration\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Freeswitch Howto: Configuration&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,3],"tags":[],"class_list":["post-561","post","type-post","status-publish","format-standard","hentry","category-freeswitch","category-tech"],"_links":{"self":[{"href":"https:\/\/blog.michel2010.name\/eric\/wp-json\/wp\/v2\/posts\/561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.michel2010.name\/eric\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.michel2010.name\/eric\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.michel2010.name\/eric\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.michel2010.name\/eric\/wp-json\/wp\/v2\/comments?post=561"}],"version-history":[{"count":0,"href":"https:\/\/blog.michel2010.name\/eric\/wp-json\/wp\/v2\/posts\/561\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.michel2010.name\/eric\/wp-json\/wp\/v2\/media?parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.michel2010.name\/eric\/wp-json\/wp\/v2\/categories?post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.michel2010.name\/eric\/wp-json\/wp\/v2\/tags?post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}