【发布时间】:2017-12-01 07:54:13
【问题描述】:
如果我们可以禁用机器人框架中的卡片按钮或任何其他可以满足我的以下要求的场景,请告诉我。
下面是我试图在Bot Framework 和LUIS 中执行的代码。
[LuisIntent("OrderStatus")]
public async Task Status(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
{
var message = await activity;
List<CardAction> cardButtons = new List<CardAction>();
CardAction cityBtn1 = new CardAction()
{
Title = "Laptop",
Value = "Laptop"
};
cardButtons.Add(cityBtn1);
CardAction cityBtn2 = new CardAction()
{
Title = "Smart Phone",
Value = "Smart Phone",
};
cardButtons.Add(cityBtn2);
CardAction cityBtn3 = new CardAction()
{
Title = "Pendrive",
Value = "Pendrive"
};
cardButtons.Add(cityBtn3);
CardAction cityBtn4 = new CardAction()
{
Title = "No option",
Value = "No option"
};
cardButtons.Add(cityBtn4);
var reply = context.MakeMessage();
HeroCard plCard = new HeroCard()
{
Title = "Please select from the following option?",
Buttons = cardButtons
};
Attachment plAttachment = plCard.ToAttachment();
reply.Attachments.Add(plCard.ToAttachment());
await context.PostAsync(reply);
context.Wait(MessageReceivedAsync);
}
private const string Yes = "Yes";
private const string No = "No";
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> awaitresult)
{
var selectedCard = await awaitresult as Activity;
string result = string.Empty;
var selectedText = selectedCard.Text;
if (selectedText.ToLower() == "Laptop".ToLower())
{
result = "Your laptop will be delivered by the end of this week";
}
else if (selectedText.ToLower() == "high water content".ToLower())
{
result = "Your smart phone will be delivered by the end of this week";
}
else if (selectedText.ToLower() == "Incompatible fuel or high water content".ToLower())
{
result = "Your pendrive will be delivered by the end of this week";
}
else if (selectedText.ToLower() == "No option".ToLower())
{
result = "Please visit our official website for more options";
}
await context.PostAsync(result);
PromptDialog.Choice(context, this.AfterMenuSelection, new List<string>() { Yes, No }, "Do you have any other issue?");
}
private async Task AfterMenuSelection(IDialogContext context, IAwaitable<string> result)
{
var optionSelected = await result;
switch (optionSelected)
{
case Yes:
await context.PostAsync("Please post your issue");
break;
case No:
await context.PostAsync("Thanks for contacting us");
break;
}
context.EndConversation("End");
}
所以当用户点击一个按钮时,他应该不能再点击任何一个按钮。
请帮我解决这个问题。
【问题讨论】:
标签: c# botframework microsoft-cognitive azure-language-understanding