Omnichannel for Customer Service is a robust application that extends the power of Dynamics 365 Customer Service to enable organizations to instantly connect and engage with their customers via channels like Live Chat and SMS.
When a customer initiates a chat with any of the mode, the chat directly lands in Omnichannel dashboard. Once the chat is initiated in Omnichannel dashboard, a human agent takes it up. We can reduce the involvement of human agents by adding a Power virtual agent so that human agents can deal with more complex cases and enquiries.
We can design a power virtual agent bot and bring it to Omnichannel. The bot can take care of basic enquiries like working hours, price enquiry etc and more. For most of the customer services there will be a working hour. In our case the human agent will be available in the working hours which is between 9 AM and 5 PM. In this blog we are dealing with a specific scenario that the Power virtual agent must look for a human agent before transferring. In order to do that the enquiry time must be captured and should be checked if it is between the available time interval.
The transferring of chat from bot to agent takes place when there is a trigger. Once the customer invokes the trigger phrase, before transferring to human agent a Power automate flow can be called. In this flow the time conditions can be checked and necessary decisions can be taken.
How to Transfer the chat to live agent only if the agent is available
Step 1: Create a chat bot and specify the escalation topics.
When the customer demands to speak with a human agent, before transferring to agent add ‘call an action’ step and add a power automate flow.
Step 2: Create a Power automate flow to check if the current time is between working hours.
Initialise a variable to store agent status.
Add an action ‘Current Time’ as shown in the below figure.
The time obtained from this step will not be Indian standard time, so it must be converted to IST.
Convert the time obtained to IST
For that add a step called ‘Convert Time Zone’.
Give the output from the previous step as Base time input, we need the time in 24Hr format hence ‘HH:mm’ is given in Format string field. Source time zone can be selected as Coordinated Universal Time from the dropdown. And the Destination time zone can be selected as IST from the dropdown.
Initialize a variable to store current time.
The time obtained will be of the format ‘HH:mm’ (24Hr) but in string datatype. In order to perform comparison operation, integer datatype would be a better option.
Add compose action to get only the hour value.
In the inputs, add the given expression ‘formatDateTime(variables(‘varCurrenttime’),’HH’)’ which extracts only the hour from the ‘HH:mm’ format.
For example if the current time is 2:15 PM, which is 14:15 in 24 Hr format, then the output will be “14”.
Add compose action to convert hour to integer format.
Give the expression ‘mul(int(outputs(‘Get_Hour’)),100)’. It converts the hour in string format to integer format. The result is multiplied with 100 for easier comparison of time.
If current time is 1 PM, which is 13:00 in 24 Hr format, then the output after this step will be 1300.
Add compose action to get only the minute value.
In the inputs, add the given expression ‘formatDateTime(variables(‘varCurrenttime’),’mm’)’ which extracts only the minute from the ‘HH:mm’ format.
For example if the current time is 2:15 PM, which is 14:15 in 24 Hr format, then the output will be “15”
Add compose action to convert minute to integer format.
Give the expression ‘int(outputs(‘Get_Minute’))’. It converts the minute in string format to integer format.
Add compose action to get the time in integer format.
In the inputs give the expression ‘add(outputs(‘Convert_hour_to_Integer’),outputs(‘Convert_min_to_integer’))’ which adds the hour and minute and output the result. For example if the current time is 2:35 PM then the output obtained after this step will be 1435.
Add a condition action
In our case the working time is 9AM to 5PM. So, the condition will be true only if the current time is between 9 AM and 5 PM and in all other times the condition will be false.
Set variables for both True and False conditions
Already a variable was declared to store the status of agent. If the condition is true then set “Will fetch an agent” to the variable. If the condition is false then set “No agents are available” to the variable.
Return the variable to Power virtual agent
In the final step add an output and pass the variable. Here ‘agentOutput’ is the variable passing to the bot.
Step 3: Select the previously created flow as action.
From above figure (Fig. 16) it is clear that the power automate is returning a variable agentOutput. On checking the value present in the variable ‘agentOutput’ further decisions can be made.
Step 4: Add a condition to check the value of the variable returned by power automate flow.
If the string present in the variable ‘agentOutput’ is “Will fetch an Agent” it implies that the enquiry is within the working hours hence it can be transferred to a human agent. Else if the string present in the variable ‘agentOutput’ is “No agent available now” then the chat must be ended.
In the figure below (Fig. 18) we can see that the enquiry is made at 1:28 PM which is within the working hours, therefore the chat will be transferred to a queue.
In the below figure (Fig. 19) the enquiry is made at 6:39 pm which is after working hours. So, the chat bot displays “Sorry Agent is not available currently” message.