[英]How do I add a user to an FAQ Plus Chat Bot as an agent in Microsoft Teams
I have 2 bots, one for the end-user which is installed in the end-users Microsoft Teams application and another bot for the experts which is installed in a channel under a team in Microsoft Teams.我有 2 个机器人,一个供最终用户使用,安装在最终用户 Microsoft Teams 应用程序中,另一个供专家使用,安装在 Microsoft Teams 团队下的频道中。
When the end-user sends an Ask An Expert command from the end-user bot, the teams channel where the expert bot is installed will receive a card saying that someone is requesting support.当最终用户从最终用户机器人发送“询问专家”命令时,安装专家机器人的团队频道将收到一张卡片,说明有人正在请求支持。 So a user (mostly an agent) will be assigned to help this end-user.因此,将分配一个用户(主要是代理)来帮助该最终用户。
Once the agent is assigned, the agent should be added to the end-user bot.分配代理后,应将代理添加到最终用户机器人。
How do I do this?我该怎么做呢? Add Agent to Bot Screen Design将代理添加到机器人屏幕设计
I tried using Direct Line API.我尝试使用直线 API。
I created a class called AgentHandler which has a method called AddUserAsAgentAsync() which takes in two arguments, botId and userId of the user that has to be added to the bot.我创建了一个名为 AgentHandler 的 class,它有一个名为 AddUserAsAgentAsync() 的方法,它接受两个 arguments,即必须添加到机器人的用户的 botId 和 userId。
Below is the code:下面是代码:
public class AgentHandler
{
private readonly string _accessToken;
public AgentHandler()
{
_accessToken = "eyJhb**";
}
public async Task AddUserAsAgentAsync(string botId, string userId)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken);
var data = new { id = userId, role = "user" };
var content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
var response = await client.PostAsync($"https://directline.botframework.com/v3/directline/conversations/{botId}/participants", content);
}
}
I then call this method during OnMessageActivitySync() in the class which extends TeamsActivity Handler.然后,我在扩展 TeamsActivity 处理程序的 class 中的 OnMessageActivitySync() 期间调用此方法。
I am not able to add the user to the bot.我无法将用户添加到机器人。 It gives 404 in the response of the AddUserAsAgentAsync()它在 AddUserAsAgentAsync() 的响应中给出 404
Have you had a look at any of the "handoff" documentation and samples?您是否看过任何“切换”文档和示例? See here as a starting point: https://learn.microsoft.com/en-us/azure/bot-service/bot-service-design-pattern-handoff-human?view=azure-bot-service-4.0请参阅此处作为起点: https://learn.microsoft.com/en-us/azure/bot-service/bot-service-design-pattern-handoff-human?view=azure-bot-service-4.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.