Sending a list of Hero Cards to attachment in Bot Framework

Viewed 1060

I want to show Sessions a particular doctor have in a Hero Card and send it to the bot.

Here is the Code

private async Task ShowSessionsHeroCard(IDialogContext context)
    {
        var replyToConversation = context.MakeMessage();
        replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel;
        replyToConversation.Attachments = GetSessionHeroCard();
        await context.PostAsync(replyToConversation);
    }

private Attachment GetSessionHeroCard()
    {
        var heroCard = new HeroCard();
        foreach (var sessionDetails in scheduleList)
        {
            string[] session = GetSplittedDetails(sessionDetails);

            string hospitalName = session[0]; //Hospital Name: {0}
            string availableDay = session[1]; //Available Day: {1}
            string appointmentNo = session[2]; // Appoinment No: {2}
            string sessionAvailable = session[3]; // Session: {3}

            heroCard.Title = hospitalName;
            heroCard.Subtitle = availableDay;
            heroCard.Text = sessionAvailable + appointmentNo;
        }
        return heroCard.ToAttachment();
    }


private string[] GetSplittedDetails(string sessionDetails)
    {
        return sessionDetails.Split(',');
    }

When i do replyToConversation.Attachments = GetSessionHeroCard();

I get the following error

Cannot implicitly convert type 'Microsoft.Bot.Connector.Attachment' to 'System.Collections.Generic.List<Microsoft.Bot.Connector.Attachment>'

Please help me with this. Am struggling for Hours. Thanks in Advance :)

1 Answers
Related