Hi Alex,

Welcome to FreeSWITCH! We're glad you are here. As to your question, this is common for new ones. Don't worry - once you get all the pieces together you will appreciate the power of the XML dialplan.

The key to doing AND logic is to "stack" conditions. However, your situation is a bit more complex because you are checking 3 different values in addition to the destination phone number. In this case I would create a special dialplan extension whose job it is to determine if the bank is open or closed, and set a channel variable. Then, use that channel variable in a second extension:

<!-- This extension sets the chan var ${bank_open} to "false" by default -->
<extension name="Determine if bank is open" continue="true">
  <condition>
    <!-- this is an "absolute" condition - it will always be true, so this action will always take place -->
    <action application="set" data="bank_open=false" inline="true"/>
  </condition>
  <condition field="wday" expression="2-5"/>
  <condition field="${bank_holiday}" expression="false"/>
  <condition field="hour" expression"x-y">
    <!-- this action only gets set if all 3 conditions above evaluate to true -->
    <action application="set" data="bank_open=true" inline="true"/>
  </condition>
</extension>

Okay, so now you have ${bank_open} that will be true or false. It's just a matter of routing now:
<extension name="Determine if bank is open" continue="true">
  <condition field="destination_number" expression="^1?\d{10}$" break="never"/>
  <condition field="${bank_open}" expression="true">
    <action application="transfer" data="ivr_destination"/>
    <anti-action application="transfer" data="vm_destination"/>
  </condition>
</extension>

There is one catch here: At some point you have to define the variable ${bank_holiday} for this to work. :)

I hope this makes sense. Also, this topic is covered in detail in chapters 5 and 8 of the FreeSWITCH book that we wrote, so you may wish to acquire that. Let us know if you run into any trouble putting this into action.

-MC

On Tue, Jul 26, 2011 at 4:50 AM, Alex Lake <alex@digitalmail.com> wrote:
Hello all, I'm a Freeswitch newbie struggling to get my head around the
best way to do some TOD/BH routing.
I've got a LUA script that will work out whether or not we're in a bank
holiday, but I wanted to do the combinatorial logic within Freeswitch
dial plan.

Something like:

if (Weekday AND (NOT BankHoliday) AND InWorkingHours) {
    Transfer to mainIVR
} else {
    Transfer to voicemail
}

What is the most elegant way to achieve this?
The Wiki pages don't appear to explain how one can do ANDs with ELSE, as
the anti-action will only get executed if it's only the last condition
that fails.

Thanks!




_______________________________________________
Join us at ClueCon 2011, Aug 9-11, Chicago
http://www.cluecon.com 877-7-4ACLUE

FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org