private Activity CreateReceipt(Activity message) { Activity replyToConversation = message.CreateReply("Receipt card"); replyToConversation.Recipient = message.From; replyToConversation.Type = "message"; replyToConversation.Attachments = new List<Attachment>(); List<CardImage> cardImages = new List<CardImage>(); cardImages.Add(new CardImage(url: "https://<ImageUrl1>")); List<CardAction> cardButtons = new List<CardAction>(); CardAction plButton = new CardAction() { Value = "https://en.wikipedia.org/wiki/Pig_Latin", Type = "openUrl", Title = "WikiPedia Page" }; cardButtons.Add(plButton); ReceiptItem lineItem1 = new ReceiptItem() { Title = "Pork Shoulder", Subtitle = "8 lbs", Text = null, Image = new CardImage(url: "https://<ImageUrl1>"), Price = "16.25", Quantity = "1", Tap = null }; ReceiptItem lineItem2 = new ReceiptItem() { Title = "Bacon", Subtitle = "5 lbs", Text = null, Image = new CardImage(url: "https://<ImageUrl2>"), Price = "34.50", Quantity = "2", Tap = null }; List<ReceiptItem> receiptList = new List<ReceiptItem>(); receiptList.Add(lineItem1); receiptList.Add(lineItem2); ReceiptCard plCard = new ReceiptCard() { Title = "I'm a receipt card, isn't this bacon expensive?", Buttons = cardButtons, Items = receiptList, Total = "275.25", Tax = "27.52" }; Attachment plAttachment = plCard.ToAttachment(); replyToConversation.Attachments.Add(plAttachment); return replyToConversation; }
private void RequestLogin(Microsoft.Bot.Connector.Activity message) { var resumptionCookie = new ResumptionCookie(message); var encodedResumptionCookie = UrlToken.Encode <ResumptionCookie>(resumptionCookie); Microsoft.Bot.Connector.Activity oriMessage = resumptionCookie.GetMessage(); var reply = oriMessage.CreateReply(Messages.BOT_PLEASE_LOGIN); reply.Recipient = oriMessage.From; reply.Type = Microsoft.Bot.Connector.ActivityTypes.Message; reply.Attachments = new List <Microsoft.Bot.Connector.Attachment>(); List <Microsoft.Bot.Connector.CardAction> cardButtons = new List <Microsoft.Bot.Connector.CardAction>(); var encodedCookie = UrlToken.Encode(resumptionCookie); Microsoft.Bot.Connector.CardAction button = new Microsoft.Bot.Connector.CardAction() { Value = $"{ConfigurationHelper.GetString("AgentLogin_URL")}?cookie={encodedCookie}", Type = "signin", Title = Messages.BOT_SIGNIN_BUTTON_TEXT, Image = "https://michistorageea.blob.core.windows.net/cdn/login.png" }; cardButtons.Add(button); Microsoft.Bot.Connector.SigninCard plCard = new Microsoft.Bot.Connector.SigninCard( text: $"{Messages.BOT_PLEASE_LOGIN}", buttons: cardButtons); Microsoft.Bot.Connector.Attachment plAttachment = plCard.ToAttachment(); reply.Attachments.Add(plAttachment); ConnectorClient connector = new ConnectorClient(new Uri(message.ServiceUrl)); var response = connector.Conversations.SendToConversation(reply); }
private Activity CreateCard(Activity message) { Activity replyToConversation = message.CreateReply("Should go to conversation, with a thumbnail card"); replyToConversation.Recipient = message.From; replyToConversation.Type = "message"; replyToConversation.Attachments = new List<Attachment>(); List<CardImage> cardImages = new List<CardImage>(); cardImages.Add(new CardImage(url: "https://upload.wikimedia.org/wikipedia/commons/f/ff/Aminah_Cendrakasih%2C_c._1959%2C_by_Tati_Photo_Studio.jpg")); List<CardAction> cardButtons = new List<CardAction>(); CardAction plButton = new CardAction() { Value = "https://en.wikipedia.org/wiki/Pig_Latin", Type = "openUrl", Title = "WikiPedia Page" }; cardButtons.Add(plButton); ThumbnailCard plCard = new ThumbnailCard() { Title = "I'm a thumbnail card", Subtitle = "Pig Latin Wikipedia Page", Images = cardImages, Buttons = cardButtons }; Attachment plAttachment = plCard.ToAttachment(); // plAttachment.ContentType = "application/vnd.microsoft.card.heros"; replyToConversation.Attachments.Add(plAttachment); return replyToConversation; }
/// <summary> /// Initializes a new instance of the ThumbnailCard class. /// </summary> public ThumbnailCard(string title = default(string), string subtitle = default(string), string text = default(string), IList<CardImage> images = default(IList<CardImage>), IList<CardAction> buttons = default(IList<CardAction>), CardAction tap = default(CardAction)) { Title = title; Subtitle = subtitle; Text = text; Images = images; Buttons = buttons; Tap = tap; }
/// <summary> /// Initializes a new instance of the ReceiptItem class. /// </summary> public ReceiptItem(string title = default(string), string subtitle = default(string), string text = default(string), CardImage image = default(CardImage), string price = default(string), string quantity = default(string), CardAction tap = default(CardAction)) { Title = title; Subtitle = subtitle; Text = text; Image = image; Price = price; Quantity = quantity; Tap = tap; }
/// <summary> /// Initializes a new instance of the ReceiptCard class. /// </summary> public ReceiptCard(string title = default(string), IList<ReceiptItem> items = default(IList<ReceiptItem>), IList<Fact> facts = default(IList<Fact>), CardAction tap = default(CardAction), string total = default(string), string tax = default(string), string vat = default(string), IList<CardAction> buttons = default(IList<CardAction>)) { Title = title; Items = items; Facts = facts; Tap = tap; Total = total; Tax = tax; Vat = vat; Buttons = buttons; }
/// <summary> /// Initializes a new instance of the CardImage class. /// </summary> public CardImage(string url = default(string), string alt = default(string), CardAction tap = default(CardAction)) { Url = url; Alt = alt; Tap = tap; }
/// <summary> /// Initializes a new instance of the ReceiptItem class. /// </summary> /// <param name="title">Title of the Card</param> /// <param name="subtitle">Subtitle appears just below Title field, /// differs from Title in font styling only</param> /// <param name="text">Text field appears just below subtitle, differs /// from Subtitle in font styling only</param> /// <param name="image">Image</param> /// <param name="price">Amount with currency</param> /// <param name="quantity">Number of items of given kind</param> /// <param name="tap">This action will be activated when user taps on /// the Item bubble.</param> public ReceiptItem(string title = default(string), string subtitle = default(string), string text = default(string), CardImage image = default(CardImage), string price = default(string), string quantity = default(string), CardAction tap = default(CardAction)) { Title = title; Subtitle = subtitle; Text = text; Image = image; Price = price; Quantity = quantity; Tap = tap; CustomInit(); }
/// <summary> /// Initializes a new instance of the ReceiptCard class. /// </summary> public ReceiptCard(string title = default(string), IList <ReceiptItem> items = default(IList <ReceiptItem>), IList <Fact> facts = default(IList <Fact>), CardAction tap = default(CardAction), string total = default(string), string tax = default(string), string vat = default(string), IList <CardAction> buttons = default(IList <CardAction>)) { Title = title; Items = items; Facts = facts; Tap = tap; Total = total; Tax = tax; Vat = vat; Buttons = buttons; }
/// <summary> /// Initializes a new instance of the ThumbnailCard class. /// </summary> public ThumbnailCard(string title = default(string), string subtitle = default(string), string text = default(string), IList <CardImage> images = default(IList <CardImage>), IList <CardAction> buttons = default(IList <CardAction>), CardAction tap = default(CardAction)) { Title = title; Subtitle = subtitle; Text = text; Images = images; Buttons = buttons; Tap = tap; }
public Attachment ToAttachment() { List<CardImage> cardImages = new List<CardImage>(); cardImages.Add(new CardImage(url: this.ImageUrl)); List<CardAction> cardButtons = new List<CardAction>(); foreach (var time in AvailableTimes) { CardAction plButton = new CardAction() { Value = $"{FullName} at {time}", Type = "imBack", Title = time }; cardButtons.Add(plButton); } HeroCard plCard = new HeroCard() { Title = this.FullName, Subtitle = $"Rating: {this.Rating.ToString("#.##")}", Images = cardImages, Buttons = cardButtons }; return plCard.ToAttachment(); }
/// <summary> /// Initializes a new instance of the BasicCard class. /// </summary> /// <param name="title">Title of the card</param> /// <param name="subtitle">Subtitle of the card</param> /// <param name="text">Text for the card</param> /// <param name="images">Array of images for the card</param> /// <param name="buttons">Set of actions applicable to the current /// card</param> /// <param name="tap">This action will be activated when user taps on /// the card itself</param> public BasicCard(string title = default(string), string subtitle = default(string), string text = default(string), IList <CardImage> images = default(IList <CardImage>), IList <CardAction> buttons = default(IList <CardAction>), CardAction tap = default(CardAction)) { Title = title; Subtitle = subtitle; Text = text; Images = images; Buttons = buttons; Tap = tap; CustomInit(); }