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.
- Go to Administration > Functions > Management.
- Click New function.
- Copy the following code and paste it into the function on the Code tab.
- Click Create.
- Go to Administration > Automation > Inbound scenarios and click the Blank scenario button.
- Connect the Function request block. In the block settings, select the created function.
- Connect the Data verification block to the Function request block. The block will verify the variable returned by the function.
- Add the is_working variable, define the conditions and respective values for port 1 (working hours) and port 2 (non-working hours).
- 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.
Please note that the callback logic is determined by your company's workflows and scenario settings.