Rate this page:

Function for determining working hours

In the below example, you will create an inbound scenario that company A will use to handle customer requests during and after working hours.

Company А provides support services to international mobile network customers. The company's agents work on weekdays from 09:00 to 21:00, and on weekends from 10:00 to 19:00. Subscribers can call support any time, regardless of business hours, and it is important for the company to deliver best customer experience.

You need to add a function to the call scenario. The function will receive the call date and time, compare it with working hours, and write the result in a variable. Depending on the result, the call will go to a queue (working hours) or to the Text-to-speech block (non-working hours), where a bot will inform the customer that an agent will contact them later.

  1. Go to Administration > Functions > Management.
  2. Click New function.
New function
  1. Copy the following code and paste it into the function on the Code tab.
Function for determining working hours

Function for determining working hours

Function code
  1. Click Create.
  2. Go to Administration > Automation > Inbound scenarios and click the Blank scenario button.
  3. Connect the Function request block. In the block settings, select the created function.
Function request
  1. Connect the Data verification block to the Function request block. The block will verify the variable returned by the function.
  2. Add the is_working variable, define the conditions and respective values for port 1 (working hours) and port 2 (non-working hours).
Data verification
  1. Connect the Call to queue block to port 1 so that during workings hours calls go to agents, and the Text-to-speech block to port 2 so that during working hours a bot informs customers that an agent will contact them later.
Scenario
Note

Please note that the callback logic is determined by your company's workflows and scenario settings.