【问题标题】:How to close a buttons in bot framework after clicking it for once单击一次后如何关闭bot框架中的按钮
【发布时间】:2017-12-01 07:54:13
【问题描述】:

如果我们可以禁用机器人框架中的卡片按钮或任何其他可以满足我的以下要求的场景,请告诉我。

下面是我试图在Bot FrameworkLUIS 中执行的代码。

[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


    【解决方案1】:

    您可能想改用Suggested Actions。根据文档:

    支持因您使用的频道而异,因此您可能还想查看Channel Inspector

    【讨论】:

      猜你喜欢
      • 2011-05-30
      • 2017-11-13
      • 2021-09-18
      • 2021-11-26
      • 2022-12-21
      • 2014-04-07
      • 2015-12-08
      • 2019-09-23
      • 2011-01-08
      相关资源
      最近更新 更多