Share via

Qna Maker Multi-turn conversations don't work on Teams

Sam Gooderham 1 Reputation point
May 20, 2022, 8:04 AM

I am making a chatbot using QnAMaker that contains multi-turn prompts, which work fine when tested in Bot Framework Composer, Web Chat, and QnAMaker itself:

203965-1.png

When testing the bot in Teams, however, the prompts don't appear:

203948-3.png

I have tried using the Teams channel in the bot resource, as well as connecting it to a Teams app through the App Studio, and neither of them produce the prompts. I can't find anything specific to multi-turn integration with Teams in the documentation so am unsure why this would be happening? Any help would be appreciated.

I've found a few old Github tickets on this (#45926, #44260, #31126) but all provided links are dead. Same for this Stack Overflow question - stackoverflow.com/questions/58605202/qna-maker-doesnt-show-buttons-when-deployed-in-ms-teams - the top-voted answer is irrelevant and the other one has deadlinks.

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,895 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,728 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Lee, Steven Hong Sing 1 Reputation point
    May 24, 2022, 3:53 AM

    Hi @Sam Gooderham , base on my understanding, you may need to convert the Prompts in the context. Something like below

                   var response = await qnaMaker.GetAnswersAsync(turnContext);  
      
                    if (response != null && response.Length > 0)  
                    {  
                        //List<string> prompts = response[0].Context.Prompts.Select(item => item.DisplayText).ToList();  
                        List<QnaMakerPrompt> prompts = response[0].Context.Prompts.ToList();  
                        if (prompts.Count > 0)  
                        {  
                             // Create Hero Card  
                            var actions = new List<CardAction>();  
                            prompts.ForEach(x =>  
                            {  
                                actions.Add(  
                                    new CardAction(  
                                        ActionTypes.MessageBack,  
                                        x.DisplayText,  
                                        null,  
                                        x.DisplayText,  
                                        x.DisplayText,  
                                        value: $@"{{ QnaId: {x.QnaId}}}")  
                                    );  
                            });  
                            var card = new HeroCard()  
                            {  
                                Text = response[0].Answer,  
                                //Subtitle = response[0].Answer,  
                                Buttons = actions  
                            };  
                            // Create Attachment  
                            var message = MessageFactory.Attachment(card.ToAttachment());  
                            await turnContext.SendActivityAsync(message);  
                        }  
                        else  
                            await turnContext.SendActivityAsync(MessageFactory.Text(response[0].Answer), cancellationToken);  
    

    Currently i am having some issue with the response once i choose the option in Ms Teams although the correct QnaId has been captured. However this is working fine in webchat. In Ms Team, it always response to the same result no matter which option i choose. Anyone got this issue?

    On each turn, i get the QnaId and pass it into the default QnAMakerOptions

                var options = new QnAMakerOptions { Top = 1 };  
                if (turnContext.Activity.Value != null)  
                {  
                    JObject o = JObject.Parse(turnContext.Activity.Value.ToString());  
                    options.QnAId = o.Value<int?>("QnaId") ?? options.QnAId;  
                }  
                var qnaMaker = new QnAMaker(new QnAMakerEndpoint  
                {  
                    KnowledgeBaseId = userProfile.selectedKB.ID,  
                    EndpointKey = _configuration["QnAEndpointKey"],  
                    Host = _configuration["QnAEndpointHostName"]  
                },  
                options,  
                httpClient);  
    
    
     
    

  2. Duncan Webb 1 Reputation point
    Jun 15, 2022, 2:21 AM

    Hi @Prasad-MSFT
    I'm in the same situation as @Sam Gooderham , using the composer rather than the SDK.
    As a result the code from @Lee, Steven Hong Sing doesn't help.
    It seems Teams doesn't recognise the Prompts: part of the QnA db.
    Is this something to be raised with the BFC team on GitHub?
    Regards

    0 comments No comments

  3. Filipe Oliveira 1 Reputation point
    Jul 14, 2022, 12:43 PM

    HI @Prasad-MSFT , i have the same problem with a bot built with the framework composer, everything works fine in webchat, but in MS Teams the prompts doesn't show!
    Regards


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.