单击AdaptiveAction之后,如何再次启用它

时间:2019-04-17 11:37:14

标签: c# botframework microsoft-teams adaptive-cards

我在自适应卡中有一个AdaptiveSubmitAction按钮,该按钮还将检查用户是否选择了两个以上的选项;机器人会回复一条消息“最多可以选择2个”,这一切都很好。

但是,当我在消息出现后单击按钮时,它仍处于禁用状态,即正在处理标志。我尝试返回http状态为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);

Attaching image of the button

1 个答案:

答案 0 :(得分:0)

能否请您尝试以下示例代码段?您可以将其放在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);