How to handle mentions in teams chat bot published on group chat?

Swetalina Panda 21 Reputation points
2021-11-17T10:04:00.47+00:00

While talking to a bot(developed using bot composer) through group chat, it comes along with @mention (bot name). Hence the luis utterance does not work and returns error. Also button clicks are not rendering.
Kindly suggest how can this be handled.

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,826 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,546 questions
{count} votes

Accepted answer
  1. Prasad-MSFT 8,421 Reputation points Microsoft Vendor
    2021-11-18T12:12:39.153+00:00

    You can call turnContext.Activity.RemoveRecipientMention() to remove @mention (bot name).

    public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
    {
        if (turnContext.Activity.Type == ActivityTypes.Message)
        {
            turnContext.Activity.RemoveRecipientMention();
    
            query = turnContext.Activity.Text;
    
            if (turnContext.Activity.ChannelId == "msteams")
            {
    
            }
            var qnaResponse = await _services.QnAServices[QnAMakerKey].GetAnswersAsync(turnContext);
    
            if (qnaResponse[0].Score < .70)
            {
                await turnContext.SendActivityAsync("qwertyxxxxxqwerty", cancellationToken: cancellationToken);
            }
            else
            {
                await turnContext.SendActivityAsync(qnaResponse[0].Answer, cancellationToken: cancellationToken);
            }
    
        }
    } 
    

    Thanks,

    Prasad Das


    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.