简体   繁体   中英

After clicking AdaptiveAction, how to enable it again

I have an AdaptiveSubmitAction button in an adaptive card, which will also check if users have selected more than 2 options; the bot will reply with a message "Max 2 nos can be selected", this all is working fine.

However, when I am clicking the button after the message comes, it is still disabled ie processing sign. I tried with returning the request with http status ok:

new AdaptiveSubmitAction
{
    Title = Constants.SUBMIT,
    Data = dictionary,
};

ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity reply = activity.CreateReply("You can select max 2 nos");
connector.Conversations.ReplyToActivity(reply);

return Request.CreateResponse(HttpStatusCode.OK);

附加按钮的图像

Could you please try this sample code snippet? You can put this in Hello World sample .

        if (activity.Value != null) // Handle action.
        {
            Activity replyMessage = activity.CreateReply("You can select max 2 nos");
            await connector.Conversations.ReplyToActivityAsync(replyMessage);
            return;
        }

        AdaptiveCard adaptiveCard = new AdaptiveCard("1.0");
        adaptiveCard.Body.Add(new AdaptiveTextInput()
        {
            Id = "Test",
            Placeholder = "enter your name here",
        });
        adaptiveCard.Actions = new System.Collections.Generic.List<AdaptiveAction>()
        {
            new AdaptiveSubmitAction()
            {
                Id = "testSubmit",
            }
        };

        Attachment attachment = new Attachment
        {
            ContentType = AdaptiveCards.AdaptiveCard.ContentType,
            Content = adaptiveCard
        };

        var reply = activity.CreateReply();
        reply.Attachments.Add(attachment);
        await connector.Conversations.ReplyToActivityAsync(reply);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM