Reputation: 11
Please let me know if we can disable the card buttons in bot framework or any other scenario through which my below requirement can be fulfilled.
Below is the code which I am trying to execute in Bot Framework
and 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");
}
So when the user click on one button, he should not be able to click any of the buttons for the second time.
Please help me with this issue.
Upvotes: 1
Views: 607
Reputation: 14787
You might want to try Suggested Actions instead. Per the docs:
The support varies depending the channel you are using, so you might want to check the Channel Inspector too.
Upvotes: 1