Search code examples
carouselskypebotframework

BotFramework Carousel CardAction Button Doesn't OpenUrl


I have a carousel, but it is not opening the URL when the CardAction button is clicked in Skype. It is working in Emulator though. Is there a reason for this?

        foreach(var botAmazonItem in botAmazonItems)
        {
            List<CardImage> cardImages = new List<CardImage>();
            cardImages.Add(new CardImage(url: $"{botAmazonItem.imageUrl}"));
            List<CardAction> cardButtons = new List<CardAction>();
            CardAction plButton = new CardAction()
            {
                Value = botAmazonItem.detailsPageUrl,
                Type = ActionTypes.OpenUrl,
                Title = botAmazonItem.title
            };
            cardButtons.Add(plButton);
            HeroCard plCard = new HeroCard()
            {
                Title = $"{botAmazonItem.title}",
                Subtitle = $"{botAmazonItem.formattedPrice}",
                Images = cardImages,
                Buttons = cardButtons
            };
            Attachment plAttachment = plCard.ToAttachment();
            replyToConversation.Attachments.Add(plAttachment);
        }

Solution

  • Try changing your "value" links to https:// rather than http://. Skype requires all external links to be https://

    The following code (based on yours) works:

            var botAmazonItems = new List<AmazonBotItem>();
            botAmazonItems.Add(new AmazonBotItem() { imageUrl = "http://placekitten.com/200/300", title = "Microsoft", formattedPrice = "$8.95", detailsPageUrl = "https://www.microsoft.com" });
            botAmazonItems.Add(new AmazonBotItem() { imageUrl = "http://placekitten.com/300/300", title = "Bot Framework", formattedPrice = "$2.95", detailsPageUrl = "https://www.botframework.com" });
    
            var reply = activity.CreateReply();
            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            reply.Attachments = new List<Attachment>();
    
            foreach (var botAmazonItem in botAmazonItems)
            {
                List<CardImage> cardImages = new List<CardImage>();
                cardImages.Add(new CardImage(url: $"{botAmazonItem.imageUrl}"));
                List<CardAction> cardButtons = new List<CardAction>();
                CardAction plButton = new CardAction()
                {
                    Value = botAmazonItem.detailsPageUrl,
                    Type = ActionTypes.OpenUrl,
                    Title = botAmazonItem.title
                };
                cardButtons.Add(plButton);
                HeroCard plCard = new HeroCard()
                {
                    Title = $"{botAmazonItem.title}",
                    Subtitle = $"{botAmazonItem.formattedPrice}",
                    Images = cardImages,
                    Buttons = cardButtons
                };
                Attachment plAttachment = plCard.ToAttachment();
                reply.Attachments.Add(plAttachment);
            }