我在自适应卡中有一个AdaptiveSubmitAction
按钮,它还会检查用户是否选择了2个以上的选项;机器人将回复一条消息“最多可以选择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);
你能试试这个示例代码片段吗?你可以把它放在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);