Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Microsoft Bot Framework将卡附件添加到邮件_C#_Bots_Botframework_Azure Language Understanding - Fatal编程技术网

C# 使用Microsoft Bot Framework将卡附件添加到邮件

C# 使用Microsoft Bot Framework将卡附件添加到邮件,c#,bots,botframework,azure-language-understanding,C#,Bots,Botframework,Azure Language Understanding,问题: 将卡附加到响应对话框,以下代码主要取自bot示例,但在我使用的显示逻辑的关键部分的响应对话框中不显示卡。 我在一个路易斯意图的任务中做附件有困难 目标 让用户提出LUIS不认识的问题,然后在代码跳入负责处理未识别问题的LUIS意图任务后,使用帮助卡进行回答。还有一些其他的结构,我可以考虑,仍然使用卡的帮助窗口? 代码 我的卡应该从哪里显示 [LuisIntent("None")] public async Task NoneHandler(IDialogContext conte

问题:

将卡附加到响应对话框,以下代码主要取自bot示例,但在我使用的显示逻辑的关键部分的响应对话框中不显示卡。 我在一个路易斯意图的任务中做附件有困难

目标

让用户提出LUIS不认识的问题,然后在代码跳入负责处理未识别问题的LUIS意图任务后,使用帮助卡进行回答。还有一些其他的结构,我可以考虑,仍然使用卡的帮助窗口? 代码

我的卡应该从哪里显示

[LuisIntent("None")]    
public async Task NoneHandler(IDialogContext context, LuisResult result) {
        string worriedFace = "\U0001F61F";
        string smilingFace = "\U0001F642";

        await context.PostAsync("I'm sorry, I didn't get that " + worriedFace + '.');
        await context.PostAsync("Here are some things I know how to talk about!" + smilingFace);

        var message = context.MakeMessage();

        var attachment = new CardDialog().ReceiptCard();
        message.Attachments.Add(attachment);

        await context.PostAsync(message);
    }
我创建的视图对象的Card类,我正在尝试显示它

namespace LUISBankingBot.Views
{
    using System.Collections.Generic;
    using Microsoft.Bot.Connector;
    using Microsoft.Bot.Builder.Dialogs;
    using System;
    using System.Threading.Tasks;

    public class CardDialog : IDialog<object>
    {
        public Task StartAsync(IDialogContext context)
        {
            throw new NotImplementedException();
        }

        public Attachment ReceiptCard()
        {
            var receiptCard = new ReceiptCard
            {
                Title = "John Doe",
                Facts = new List<Fact> { new Fact("Order Number", "1234"), new Fact("Payment Method", "VISA 5555-****") },
                Items = new List<ReceiptItem>
                {
                    new ReceiptItem("Data Transfer", price: "$ 38.45", quantity: "368", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/traffic-manager.png")),
                    new ReceiptItem("App Service", price: "$ 45.00", quantity: "720", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/cloud-service.png")),
                },
                Tax = "$ 7.50",
                Total = "$ 90.95",
                Buttons = new List<CardAction>
                {
                    new CardAction(
                        ActionTypes.OpenUrl,
                        "More information",
                        "https://account.windowsazure.com/content/6.10.1.38-.8225.160809-1618/aux-pre/images/offer-icon-freetrial.png",
                        "https://azure.microsoft.com/en-us/pricing/")
                }
            };

            return receiptCard.ToAttachment();
        }        
    }
}

有几件事。首先,当您试图添加附件时,可能会出现null ref异常,因为附件数组尚未初始化

message.Attachments = new List<Attachment>();
此外,您不需要创建CardDialog。下面是一个有效的示例:

    [LuisIntent("None")]
    public async Task NoneHandler(IDialogContext context, LuisResult result)
    {
        string worriedFace = "\U0001F61F";
        string smilingFace = "\U0001F642";

        await context.PostAsync("I'm sorry, I didn't get that " + worriedFace + '.');
        await context.PostAsync("Here are some things I know how to talk about!" + smilingFace);

        var message = context.MakeMessage();

        var receiptCard = new ReceiptCard
        {
            Title = "John Doe",
            Facts = new List<Fact> { new Fact("Order Number", "1234"), new Fact("Payment Method", "VISA 5555-****") },
            Items = new List<ReceiptItem>
            {
                new ReceiptItem("Data Transfer", price: "$ 38.45", quantity: "368", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/traffic-manager.png")),
                new ReceiptItem("App Service", price: "$ 45.00", quantity: "720", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/cloud-service.png")),
            },
            Tax = "$ 7.50",
            Total = "$ 90.95",
            Buttons = new List<CardAction>
            {
                new CardAction(
                    ActionTypes.OpenUrl,
                    "More information",
                    "https://github.com/amido/azure-vector-icons/raw/master/renders/traffic-manager.png",
                    "https://azure.microsoft.com/en-us/pricing/")
            }
        };

        message.Attachments = new List<Attachment>();
        message.Attachments.Add(receiptCard.ToAttachment());

        await context.PostAsync(message);
    }

和什么您遇到的问题是什么?我面临的问题是将卡连接到响应对话框,以下代码主要取自bot示例,但在响应对话框中不显示卡。RU使用哪个通道?逐通道是指Microsoft.bot.Connector吗?否;你在模拟器中尝试这个吗?在Facebook?Skype?只发生在收据卡上,或者例如英雄卡也没有显示出来?就像一个符咒