简体   繁体   中英

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.

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.

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.

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.

I am not able to add the user to the bot. It gives 404 in the response of the AddUserAsAgentAsync()

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM