private static AlexaCard CreateAlexaCardFromHeroCard(Attachment attachment) { if (!(attachment.Content is HeroCard heroCardContent)) { return(null); } AlexaCard alexaCard = null; if (heroCardContent.Images != null && heroCardContent.Images.Any()) { alexaCard = new AlexaCard() { Type = AlexaCardType.Standard, Image = new AlexaCardImage() { SmallImageUrl = heroCardContent.Images[0].Url, LargeImageUrl = heroCardContent.Images.Count > 1 ? heroCardContent.Images[1].Url : null } }; if (heroCardContent.Title != null) { alexaCard.Title = heroCardContent.Title; } if (heroCardContent.Text != null) { alexaCard.Content = heroCardContent.Text; } } else { alexaCard = new AlexaCard() { Type = AlexaCardType.Simple }; if (heroCardContent.Title != null) { alexaCard.Title = heroCardContent.Title; } if (heroCardContent.Text != null) { alexaCard.Content = heroCardContent.Text; } } return(alexaCard); }
public static void AlexaSetCard(this ITurnContext context, AlexaCard card) { context.TurnState.Add("AlexaCard", card); }