如何使用C#在客户端上获取建议的Cardaction内容

时间:2019-01-27 03:24:36

标签: c# xamarin.forms botframework

我正在使用Microsoft BotFramework,并且当漫游器返回建议的CardAction时,内容未显示在客户端中。

BotCode

private static async Task SendSuggestionOptionAsync(ITurnContext turnContext, CancellationToken cancellationToken)
{
    var reply = turnContext.Activity.CreateReply("Please choose anyone of this!");
    reply.Type = ActivityTypes.Message;
    reply.TextFormat = TextFormatTypes.Plain;
    reply.SuggestedActions = new SuggestedActions()
    {
        Actions = new List<CardAction>()
        {
            new CardAction() { Title = "Fourm", Type = ActionTypes.ImBack, Value = "Fourm" },
            new CardAction() { Title = "KB", Type = ActionTypes.ImBack, Value = "KB" },
        },
    };
    await turnContext.SendActivityAsync(reply, cancellationToken);
}

客户代码

var messagesReceived = await _httpClient.GetAsync(conversationUrl);
var messagesReceivedData = await messagesReceived.Content.ReadAsStringAsync();
var messagesRoot = JsonConvert.DeserializeObject<BotMessageRoot>(messagesReceivedData);

仅显示“请选择其中任何一个!”在messgesReceivedData上,但不显示建议的CardAction内容。有人可以帮忙找出我在哪里出错吗?我想将建议的CardAction内容绑定到我的客户端。

启动输出

{
   "id": "QYhDOe6oulCoU55XIoXc5|0000003",
   "conversationId": "QYhDOe6oulCoU55XIoXc5",
   "created": "2019-01-28T04:56:37.1646158Z",
   "from": "sync-test-bot",
   "text": "Please choose anyone of this!",
   "images": [],
   "attachments": []
}

没有论坛,并且KB在这里显示。

1 个答案:

答案 0 :(得分:1)

不确定答案,但是您检查了响应头吗?在Outlook可操作的邮件中,卡片内容作为JavaScript对象位于http标头中。