Hi Alex, <br><br>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.<br>
<br>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:<br>
<br><span style="font-family: courier new,monospace;"><!-- This extension sets the chan var ${bank_open} to "false" by default --></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"><extension name="Determine if bank is open" continue="true"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <condition></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <!-- this is an "absolute" condition - it will always be true, so this action will always take place --></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <action application="set" data="bank_open=false" inline="true"/></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </condition></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <condition field="wday" expression="2-5"/></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <condition field="${bank_holiday}" expression="false"/></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <condition field="hour" expression"x-y"></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <!-- this action only gets set if all 3 conditions above evaluate to true --></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <action application="set" data="bank_open=true" inline="true"/></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
</condition></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></extension></span><br style="font-family: courier new,monospace;"><br>Okay, so now you have ${bank_open} that will be true or false. It's just a matter of routing now:<br>
<span style="font-family: courier new,monospace;"><extension name="Determine if bank is open" continue="true"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <condition field="destination_number" expression="^1?\d{10}$" break="never"/></span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <condition field="${bank_open}" expression="true"></span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> <action application="transfer" data="ivr_destination"/></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <anti-action application="transfer" data="vm_destination"/></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> </condition></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></extension></span><br><br>There is one catch here: At some point you have to define the variable ${bank_holiday} for this to work. :)<br><br>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.<br>
<br>-MC<br><br><div class="gmail_quote">On Tue, Jul 26, 2011 at 4:50 AM, Alex Lake <span dir="ltr"><<a href="mailto:alex@digitalmail.com">alex@digitalmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello all, I'm a Freeswitch newbie struggling to get my head around the<br>
best way to do some TOD/BH routing.<br>
I've got a LUA script that will work out whether or not we're in a bank<br>
holiday, but I wanted to do the combinatorial logic within Freeswitch<br>
dial plan.<br>
<br>
Something like:<br>
<br>
if (Weekday AND (NOT BankHoliday) AND InWorkingHours) {<br>
Transfer to mainIVR<br>
} else {<br>
Transfer to voicemail<br>
}<br>
<br>
What is the most elegant way to achieve this?<br>
The Wiki pages don't appear to explain how one can do ANDs with ELSE, as<br>
the anti-action will only get executed if it's only the last condition<br>
that fails.<br>
<br>
Thanks!<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Join us at ClueCon 2011, Aug 9-11, Chicago<br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a> 877-7-4ACLUE<br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br>