Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: update formatting, use variable page includes

...

Expand
titleClick here to expand Table of Contents
Panel
borderColorlightgray
bgColor#f7f7f7
borderWidth1
borderStyledotted

Table of Contents
maxLevel3
outlinetrue
indent1em
excludeAbout
stylenone
printablefalse

Variables

...

AttributeAcceptable ValuesDescription
year0 - 9999

...

calendar year
yday1 - 366

...

day of year
mon1 - 12month (Jan = 1, etc.)
mday

...

1 - 31day of month

...

week1 -

...

53week

...

of year

...

mweek1 -

...

6

...

week of month

...

wday1 -

...

7

...

day of week,

...

numeric (

...

sun = 1,

...

mon = 2, etc.)

...

sun

mon

tue

wed

thu

fri

sat

day of week

hour0 - 23

...

hour
minute0 - 59minute (of the hour)

...

minute-of-day

...

1-1440minute of the day

...

(

...

midnight = 1, 1am = 60, noon = 720, etc

...

)
time-of-day

...

hh:mm

...

-hh:mm

...

time range

Example:

...

08:00-17:00

...

hh:mm:ss-hh:mm:ss

time range, with seconds

date-time

...

YYYY-MM-DD hh:mm

...

~YYYY-MM-DD hh:mm

...

date time range, note the ~ delimiter

Example: 2010-10-01 00:00:

...

01~2010-10-15 23:59:59

YYYY-MM-DD hh:mm:ss~YYYY-MM-DD hh:mm:ssdate time range, with seconds, note the ~ delimiter

 

These can be combined in the same condition, e.g:

Code Block
languagexml
themeConfluence
<condition wday="6" hour="8-12"> 

Wrap-Around

Time and date variables support wrap-around to span the changing of the days, months, or years.<condition :

Code Block
languagexml
themeConfluence
<condition mon="10-2"> <!-- from October of year 1 to February of year 2 -->
Code Block
languagexml
themeConfluence
<condition time-of-day="17:00:00-07:00:00"> <!-- from 5PM of day 1 to 7AM of day 2 -->

Note: (warning) If you use wrap-around then the from and to date/time need to be one value lower so "5:00:00-5:00:00" will read as 0 and needs to be "5:00:00-4:59:59" which would then read as 5am 5AM from today to 4:59am 59AM tomorrow.

Blocks

Comma–separated values allow discrete blocks of time to be specified.<condition :

Code Block
languagexml
themeConfluence
<condition time-of-day="08:00-12:00,13:00-17:00"> <!-- from 8AM to 12AM and 1PM to 5PM -->
Code Block
languagexml
themeConfluence
<condition date-time="2015-03-01 00:00:00~2015-03-01 23:59:59,2015-06-05 00:00:00~2015-07-01 23:59:59"> <!-- day 2015-03-01 and range from 2015-06-05 to 2015-07-01 -->

Note (warning) the tilde ~ character between the start and end values of the range.is used to delimit the starting date time and the ending date time

Time Zone Manipulation

By default, time–based routing uses the local time kept by FreeSWITCH. If you want to use a different time zone, you have 2 options (as of 2012-11-01 in master, see 

JIRA
serverJira
columnskey
serverIdc4b15fa3-ad57-3c05-af05-8c167cb92266
keyFS-4741
).

variable tod_tz_offset

Include Page
timezone
timezone

Include Page
tod_tz_offset

...

NOTE: the variable must actually be set before the comparison, so either set it inline, transfer, or set it in the user's directory entry.

variable timezone

Alternatively, you can use the Timezone name and FS will lookup the correct offset to apply to TOD routing.

...

tod_tz_offset

...

Usage

The examples presented here can be added to the conf/dialplan/default.xml file or you can create a new file in conf/dialplan/default/ to be included in the default dialplan (see the bottom of the vanilla default dialplan).

Provision an internal extension # for Sales to route calls dialed for 2002.

Code Block
languagexml
themeConfluence
titleconf/dialplan
   <extension name="RS-Sales-x2002">
     <condition field="destination_number" expression="^2002$">
       <action application="transfer" data="RS-Sales"/>
     </condition>
   </extension>

Setup variables prior to transferring to call handler for sales. This sets the variables so that they will be available to the condition test during the next pass through the dialplan initiated by the transfer app.

Code Block
languagexml
themeConfluence
titleconf/dialplan
   <extension name="RS-Sales" continue="true">
     <condition field="destination_number" expression="^RS-Sales$"/>
     <condition wday="2-6"/>
     <condition minute-of-day="540-1020">
       <action application="set" data="RS-Sales_open=true"/>
       <action application="transfer" data="xfer-to-sales"/>

       <anti-action application="set" data="RS-Sales_open=false"/>
       <anti-action application="transfer" data="xfer-to-sales"/>
     </condition>
   </extension>

...

If Sales is open then route to extension first, then vMail; else send call directly to vMail. In this example, Sales have their own mailbox (#2001) - the configuration of that box forwards all vMail to email and does not store a local copy.

Code Block
languagexml
themeConfluence
titleconf/dialplan
   <extension name="xfer-to-sales">
     <condition field="destination_number" expression="^xfer-to-sales$"/>
     <condition field="${RS-Sales_open}" expression="^true$">
       <action application="bridge" data="user/1001@${domain_name}"/>
       <action application="answer"/>
       <action application="sleep" data="2000"/>
       <action application="voicemail" data="default ${domain_name} 2001"/>

       <anti-action application="voicemail" data="default ${domain_name} 2001"/>
     </condition>
   </extension>

VoiceMail Config (in conf/directory/default/2001.xml)

Code Block
languagexml
themeConfluence
titleVoicemail config
 <user id="2001" number-alias="2001">
   <params>
     <param name="password" value="2001"/>
     <param name="vm-password" value="2001"/>
     <param name="vm-email-all-messages" value="true"/>
     <param name="vm-notify-email-all-messages" value="true"/>
     <param name="vm-attach-file" value="true"/>
     <param name="vm-mailto" value="sales@foo.com"/>
     <param name="vm-notify-mailto" value="chris@foo.com"/>
     <param name="vm-keep-local-after-email" value="false"/>
   </params>
   <variables>
     <variable name="toll_allow" value="domestic,international,local"/>
     <variable name="accountcode" value="2001"/>
     <variable name="user_context" value="default"/>
     <variable name="effective_caller_id_name" value="sales"/>
     <variable name="effective_caller_id_number" value="2001"/>
     <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
     <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
     <variable name="callgroup" value="fga"/>
   </variables>
 </user>

...

Has inbound DID routed to extension 5001. Because the office_status variable is set with the inline attribute, the variable takes effect immediately with no need to transfer to another extension definition. The following dialplan extension will always be executed and continue after matching.

Code Block
languagexml
themeConfluence
titleTime and day evaluation
 <extension name="Time of day, day of week setup" continue="true">
   <condition wday="2-6" minute-of-day="540-960" break="never">
      <action application="set" data="office_status=open" inline="true"/>
      <anti-action application="set" data="office_status=closed" inline="true"/>
   </condition>
 </extension>

This extension will be evaluated if 5001 is the destination number and will build a final destination consisting of 5001_open or 5001_closed.

Code Block
languagexml
themeConfluence
titleExt. 5001
 <extension name="tod route, x5001">
   <condition field="destination_number" expression="^(5001)$">
       <action application="execute_extension" data="5001_${office_status}"/>
    </condition>
 </extension>

Now the call is handled.

Code Block
languagexml
themeConfluence
titleOpen/closed call handler
 <extension name="office is open">
   <condition field="destination_number" expression="^(5001_open)$">
       <action application="set" data="domain_name=$${domain}"/>
       <action application="answer"/>
       <action application="playback" data="/usr/local/freeswitch/recordings/welcome_message.wav"/>
       <action application="set" data="hangup_after_bridge=true"/>
       <action application="set" data="continue_on_fail=NORMAL_TEMPORARY_FAILURE,USER_BUSY,NO_ANSWER,TIMEOUT,NO_ROUTE_DESTINATION"/>
       <action application="set" data="ringback=local_stream://moh"/>
       <action application="set" data="transfer_ringback=local_stream://moh"/>
       <action application="pre_answer"/>
       <action application="bridge" data="{ignore_early_media=true,origination_caller_id_number=XXXXXXXX}sofia/gateway/<gateway name>/XXXXXXXX,sofia/gateway/<gateway name>/XXXXXXXX"/>
   </condition>
 </extension>

 <extension name="office is closed">
  <condition field="destination_number" expression="^(5001_closed)$">
     <action application="answer"/>
     <action application="sleep" data="1000"/>
     <action application="playback" data="/usr/local/freeswitch/recordings/9-16.wav"/>
     <action application="sleep" data="500"/>
     <action application="hangup" data="NORMAL_CLEARING"/>
  </condition>
 </extension>

...

Often these holidays fall on consistent dates and you can use the mday and mon attributes to detect them. Here is Christmas for example:

Code Block
languagexml
themeConfluence
titleFixed date
 <!-- Christmas day -->
 <condition mday="25" mon="12">

However, some holidays don't fall on consistent dates and are instead something like 'the third Monday in February'. You can use the mweek (week of month) condition parameter (added in r15723) to help with this:

Code Block
languagexml
themeConfluence
titleThird Monday
 <!-- president's day is the 3rd Monday in February -->
 <condition wday="2" mweek="3" mon="2">

Sometimes, again, a holiday is specified as something like the 'last Monday in October' and you have to do something like this:

Code Block
languagexml
themeConfluence
 <condition wday="2" mon="10" mday="25-31">

...

Using these three patterns you can match almost any holiday date, however, there are complicated ones like Easter and Inauguration Day that are more complicated and would require some custom coding to detect.

Memorial Day

Code Block
languagexml
themeConfluence
titleMemorial Day
 <extension name="2012_memorial_day_weekend_routing">
   <condition date-time="2012-05-25 17:00:01~2012-05-29 08:00:00"/>
   <condition field="destination_number" expression="^1(2135551212)$">
     <action application="bridge" data="sofia/external/18185551212@1.2.3.4"/>
   </condition>
 </extension>

...