答案 0 :(得分:1)
使用自适应卡,您可以使用AdaptiveSubmitAction
:
new AdaptiveSubmitAction()
{
Data = "show me the next card"
};
这会生成一条新的传入消息,message.Text
的值为Data
,您可以像处理来自用户的常规消息一样处理它。
您可以使用ImBack
和PostBack
操作与其他富卡/缩略图卡实现相同的效果:
new CardAction()
{
Type = ActionTypes.ImBack,
Value = "show me the next card"
}
AdaptiveSubmitAction
还有DataJson
属性,您可以使用Data
而不是DataJson
(如果您同时使用message.Value
,则message.Text
无效)。您可以在那里放置一个json结构,最终会在传入消息的DataJson = "{ \"CardName\": \"City\", \"Name\": \"New York\" }"
中结束,而在这种情况下protected override async Task MessageReceived(IDialogContext context, IAwaitable<IMessageActivity> item)
{
var message = await item;
if (string.IsNullOrEmpty(message.Text))
{
dynamic value = message.Value;
if (value == null)
{
// empty message - show help, error etc.
}
dynamic cardName = value.CardName;
// check the name, respond with the wanted card ...
}
else
{
// process as usual
await base.MessageReceived(context, item);
}
}
将为null。
当您需要传递更多细节时,这可能很方便,例如: { "_40":0,"_65":0,"_55":null,"_72":null }
可能意味着您要为纽约开设一张城市卡。然后你可以检索这样的结构:
console.log
Here是一个使用json方法的示例项目。