'I want to escalate the conversation to the agent portal i.e. Dynamaics omnichannel customer service. But I didn't get the response from agent portal
Actually, I have built a bot and registered it with the azure service and Dynamics 365 omnichannel customer service. I want to escalate the conversation to the human agent from dynamics omnichannel customer service. I have a code snippet from Microsoft but that is in C#. I have written the logic according to the reference code in JavaScript but I didn't get a response from the agent side. Below is the C# code snippet but I want it in JavaScript. can anyone help me to solve this issue?
if (turnContext.Activity.Text.Contains("agent") | conversation.EscalationDictionary.ContainsKey(turnContext.Activity.Text))
{
Dictionary<string, string> endConversationContext = new Dictionary<string, string>();
if (conversation.EscalationDictionary.ContainsKey(turnContext.Activity.Text)) { endConversationContext = conversation.EscalationDictionary[turnContext.Activity.Text]; }
await turnContext.SendActivityAsync("Transferring to an agent, who can help you with this. Please remain online…");
Dictionary<string, object> handOffContext = new Dictionary<string, object>()
{
{ "BotHandoffContext", "Specialist request" },
{ "skill", "service" }
};
var handoffevent = EventFactory.CreateHandoffInitiation(turnContext, new
{
MessageToAgent = "Issue Summary: billing question",
Context = handOffContext
}); // Transcript is persisted by Omnichannel
await turnContext.SendActivityAsync(handoffevent);
}
this is a JavaScript code that I have written. But I didn't get a response from agent portal end.
async function handoffMiddleware(context, next) {
if (context.activity.text == "agent") {
await context.sendActivity("Transferring conversation to the agent")
// let activities = GetRecentActivities()
let handoffContext = {
botHandoffContext: "specialist request",
}
console.log(handoffContext)
let handoffEvent = EventFactory.createHandoffInitiation(context, {
message: "summary:fine",
context: handoffContext,
})
handoffEvent.type = ActivityTypes.Message
handoffEvent.text = "agent can handle this issue"
console.log(handoffEvent)
await context.sendActivity(handoffEvent)
}
await next()
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
