SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Creating Time-of-Day Routing in Twilio Studio Using Liquid Variables

Objective

This article aims to guide you through the process of setting up time-of-day routing in Twilio Studio using Liquid variables. This setup allows you to direct incoming calls based on specific time periods and days, enhancing your call management efficiency.

Product

Twilio Studio

User Account Permission/Role(s) Required

  • Access to Twilio Console
  • Permissions to create and modify Studio Flows

Procedure

1. Create a New Studio Flow

  1. Log in to Twilio Console and navigate to the Studio section.
  2. Create a new Studio Flow by clicking on the "Create new Flow" button.
  3. Name your flow and select "Start from scratch."

2. Set Up Variables

  1. Add a 'Set Variables' Widget to your flow.
  2. Define the following variables using Liquid syntax:
    • day: {{'now' | date: "%A"}} - This captures the current day of the week.
    • time: {{'now' | date : "%l %M %p "}} - This captures the current time.
    • hour: {{'now' | date: "%k"}} - This captures the current hour in 24-hour format.

Warning

When using the now keyword, the resulting time will be output in US Pacific Time, not UTC.

3. Implement Time-Based Logic

  1. Add a 'Split Based On' Widget to evaluate the hour variable.
  2. Set conditions to route calls based on business hours. For example:
    • Use a regex condition to match business hours: \b(1[8-9]|2[0-3]|0[0-5])\b for hours between 6 PM and 6 AM.
    • Route calls to a "Closed" message outside business hours and to an "Open" message during business hours.

4. Configure Call Routing

  1. Add 'Say/Play' Widgets to handle different call outcomes:
    • A widget for "We are open" during business hours.
    • A widget for "We are closed" after business hours.

5. Test Your Flow

  1. Publish your flow and configure your Twilio phone number to use this flow.
  2. Test by calling the number to ensure calls are routed correctly based on the time of day.

Additional Considerations

  • Time Zone Management: Ensure your server's time zone aligns with your business hours. You may need to adjust the regex to match your local time zone.
  • Liquid Variables: Liquid syntax is powerful for dynamic content but may require some learning. Refer to Twilio's Liquid documentation for more details.
  • Studio Time Zone: The time zone in Studio is set to San Francisco Time, observing San Francisco's time zones. 

Additional Information

By following these steps, you can effectively manage call routing based on the time of day, enhancing customer satisfaction and operational efficiency.

 

Have more questions? Submit a request
Powered by Zendesk