timeBased

With this rule, you can control the Call Flow logic based on the time of day.

Structure

This rule makes use of eventHandlers so control which path the Call Flow will take depending upon the time of the day. Rules to define whether a time matches a condition, or not, must be configured in a Time Template previously stored in our system. As per other rules that use eventhandlers, there is a failure option one of the specifed time conditions is not met. You have the following XML structure:

    <timeBased id="timeBased_1" label="Time Based Rule">
    <eventHandlers>
        <timeEvent action="onMatchTime" timeTemplateLabel="TimeTemplate1">
            <!-- Rules -->
        </timeEvent>
        <timeEvent action="onMatchTime" timeTemplateLabel="TimeTemplate2">
            <!-- Rules -->
        </timeEvent>
        <failure id="failure_2" label="Failure" attempts="0">
            <failureMessage>
                <!-- messageParts -->
            </failureMessage>
        </failure>
    </eventHandlers>
</timeBased>
Attribute Description Mandatory Default
timeEvent : action onMatchTime : The matching time YES N/A
timeEvent : timeTemplateLabel Label of a previously stored Time Template YES N/A

Examples

Basic timeBased Rule with a timeTemplate

We will have a time based rule with only one Time Template matched. If the call is made between 9 until 6 from Monday until Friday it will go through, otherwise the call will be dropped. Below you have the example of this Rule.

<timeBased id="timeBased_1" label="Weekly Action">
    <eventHandlers>
        <timeEvent action="onMatchTime" timeTemplateLabel="Mon - Fri: 6pm - 9am">
            <call id="call_1"  record="false" sendCallAlert="NONE" label="Call" destinationPhoneNumber="447723468855" destinationContactId="1"/>
        </timeEvent>
    </eventHandlers>
</timeBased>

Multiple Time Events in a timeBased Rule

We will add another Time Template to the timeBased Rule. In this case if the first Time Template is not matching we will check the second Time Template. The example XML is below.

<timeBased id="timeBased_1" label="Weekly Action">
    <eventHandlers>
        <timeEvent action="onMatchTime" timeTemplateLabel="Mon - Fri: 6pm - 9am">
            <call id="call_1" label="Call Weekly Support" record="false" sendCallAlert="NONE" destinationPhoneNumber="447723468855" destinationContactId="1"/>
        </timeEvent>
        <timeEvent action="onMatchTime" timeTemplateLabel="Weekends:Sat/Sun">
            <call id="call_2" label="Call Weekend Support" record="false" sendCallAlert="NONE" destinationPhoneNumber="447723468852" destinationContactId="1"/>
        </timeEvent>
    </eventHandlers>
</timeBased>

Multiple Time Events with a Failure Event

Finally we will add a failover into our Call Flow so we can still react if the other specified Time Templates do not match the current time. The example XML is below.

<timeBased id="timeBased_1" label="Weekly Action">
    <eventHandlers>
        <timeEvent action="onMatchTime" timeTemplateLabel="Mon - Fri: 6pm - 9am">
            <call id="call_1" label="Call Weekly Support" destinationPhoneNumber="447723468855" destinationContactId="1"/>
        </timeEvent>
        <timeEvent action="onMatchTime" timeTemplateLabel="Weekends:Sat & Sun">
            <call id="call_2" label="Call Weekend Support" record="false" sendCallAlert="NONE" destinationPhoneNumber="447723468852" destinationContactId="1"/>
        </timeEvent>
        <failure id="failure_1" label="Extra Time Support" attempts="0">
            <failureMessage>
                <soundFile soundLabel="We will connect you now"/>
            </failureMessage>
            <call id="call_2" label="Extra Time Support" record="false" sendCallAlert="NONE" destinationPhoneNumber="447723468853" destinationContactId="1"/>
        </failure>
    </eventHandlers>
</timeBased>

Error Result

HTTP Code Error String Resolution
400 Rule ID Empty Set the value of the id attribute
400 Rule Label Empty Set the value of the label attribute
400 Rule ID Not Unique in timeBased The value of the id attribute is used for an other rule, change it to be unique
400 Time Template Empty Select an existing Time Template label (timeTemplateLabel)
400 Time Template does not exist Select an existing Time Template label (timeTemplateLabel)