jeudi 27 avril 2017

Exception while sending CardImage from Bot

I have written code for sending the message based on the intent matching using LUIS in bot framework. Here is my code.

[LuisIntent("Skype for Business")]
    public async Task Skype4Business(IDialogContext context, LuisResult result)
    {
        var connector = new ConnectorClient(new Uri(context.Activity.ServiceUrl));
        try
        {
            // return our reply to the user
            List<CardImage> cardImageList = new List<CardImage>();
            List<CardAction> buttons = new List<CardAction>();

            CardImage cardImage = new CardImage { Alt = "SpeechPic", Url = @"C:\Users\Rock\Documents\Visual Studio 2015\Projects\Text Analytics\Text Analytics\Resources\Skype-for-business-2.jpg" };
            cardImages = new List<CardImage>();

            cardImages.Add(cardImage);

            CardAction skypeButton = new CardAction()
            {
                Value = "example.com/",
                Type = "openUrl",
                Title = "Skype for Business"
            };
            buttons.Add(skypeButton);

            HeroCard heroCard = new HeroCard()
            {

                Title = "Skype For Business",

                Images = cardImages,
                Buttons = buttons

            };

            var message = context.MakeMessage();
            message.Attachments = new List<Attachment>();
            message.AttachmentLayout = AttachmentLayoutTypes.List;
            message.Attachments.Add(heroCard.ToAttachment());


            await context.PostAsync(message);

            context.Wait(MessageReceived);
        }

So whenever I am sending the reply from the bot if the intent is matched e.g: Skype for business. So I am replying by making card and adding cardimage and button in it. It send without any error but after sending successfully it shows me the exception too. Snapshot of exception

I'm stuck here even i have added the try/catch clause too to handle the exception but still i am getting the exception. How to resolve this? Any help or guidance would be appreciated.




Aucun commentaire:

Enregistrer un commentaire