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);