1
ボットフレームワークまたは以下の要件を満たすことができる他のシナリオでカードボタンを無効にできるかどうかお知らせください。ボットフレームワーク内のボタンを一度クリックした後にボタンを閉じる方法
以下は、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");
}
ユーザーが1つのボタンをクリックしたときに、彼は二度目のボタンのいずれかをクリックできないようにする必要があり。
この問題を手伝ってください。