When an agent accepts a chat in the Omnichannel experience for D365 Customer Service, context information is passed from the initiated chat to the agent’s desktop. This context information includes pre chat variables, bot variables – if the chat was escalated from a bot – as well as custom variables sent via custom code.
Context Variables can be used to route incoming chat messages , auto identify customers as well as provide information which the agent can use to their benefit ultimately reducing an agents average handling time and improving customer satisfaction.
In a previous blog, I shared how it is possible to create pre chat questions enabling agents to personalise the interaction they have with customers based on the information entered by the customer at the start of the chat. However, in some cases we may wish to provide information to an agent without the use of a pre chat questionnaire. For e.g. initiating a chat in an authenticated area of a portal or website without the need to re ask the customer for their name. Another example would be where there is a need to pass information from a website or portal to the agent.
To pass custom variables to the chat widget add the customProvider function to the page. The function can return string, integer or boolean variables as below and be displayed on the conversation form’s additional details tab if the isDisplayable parameter is true.
function contextProvider() {
return {
'Name': {'value': 'Tricia Sinclair', 'isDisplayable': true},
'Checkout_Value': {'value': 12.34, 'isDisplayable': true},
'WebBasedError': {'value': true, 'isDisplayable': false}
};
}
To pass the variables to the chat, the script below must be added before the chat is initiated.
Microsoft.Omnichannel.LiveChatWidget.SDK.setContextProvider(contextProvider);
In the video below, I show how this all comes together.
Hi, this is great, thanks. I have a scenario here. I would need to pass on a dynamic parameter ( e.g. some object Id) from the website where bot is hosted, and receive it inside bot variable (e.g. bot.Object Id) how can I achieve that. In your example, I am getting variable as form of context variable, but they are nor immediately available in bot to take action upon (like triggering a flow etc. )
Please can you advice.
LikeLike
Hi Akshat
This is possible. However you’re going to need to use global bot variables and configure the bot to receive data from external source. https://docs.microsoft.com/en-us/power-virtual-agents/authoring-variables-bot#set-a-bot-variables-value-from-external-sources
Hope it helps!
LikeLike
Thank you for great article and video. While sending the extra parameter to agent conversation screen, this works great, but wondering if any of the custom parameter that we send through this script, can be utilized in Routing Rules in workstream or not?
I mean support we wants to send some Tag (for an example : Technical/Support/Purchase/General) from this script and wants to use that Tag into Routing Rules. If these is a way, please let me know.
LikeLike
Hi Nick
Any value passed through as a context can be used in Routing. If you want to do this, ensure you create a context variable and you’ll be able to refer to this in both work classification rules and routing ruleset.
LikeLike
@Tricia, are you available for some offline discussion related to Omnichannel for Customer Service -design and some technical Brainstorming? If you are, please message me on nirav.patel@spray.com
LikeLike