我在bot中有一个对话流程,以便在收到用户消息后,我们显示来自QnAMaker的相关答案,然后要求用户选择类别。 在机器人聊天窗口中,用户选择一个按钮后,我应该能够显示“您已选择XYZ”,然后继续进行操作。由于我在卡片操作中使用“ imback”,因此现有流程会显示选定的选项。
代码:
private List<CardAction> CreateButtons(out List<string> ids)
{
var ds = new List<string> { "operating group", "geo", "technology", "themes" };
ids = new List<string>();
List<CardAction> cardButtons = new List<CardAction>();
foreach (var keyword in ds)
{
ids.Add(keyword);
CardAction CardButton = new CardAction()
{
Type = "imBack",
Title = keyword,
Value = keyword
};
cardButtons.Add(CardButton);
}
return cardButtons;
}
调用:
var replyMessage = context.MakeMessage();
List<string> ids = new List<string>();
List<CardAction> cardButtons = CreateCategoryButtons(out ids);
var GeoCard = new HeroCard(text: "Are you interested in searching through the file? Please select the Category you would like to refine Credentials for:")
{
Buttons = cardButtons
};
replyMessage.Attachments.Add(GeoCard.ToAttachment());
replyMessage.AttachmentLayout = AttachmentLayoutTypes.List;
context.PrivateConversationData.SetValue<List<string>>("ids", ids);
await context.PostAsync(replyMessage);
context.Wait(CategoryValidate);
// context.Wait(optionCategoryValidate);
context.Done(true);