public static async Task ReplyWithChart(IDialogContext context, string workbookId, string worksheetId, WorkbookChart chart) { try { // Create and save user nonce var userNonce = (Guid.NewGuid()).ToString(); context.ConversationData.SetValue <ChartAttachment>( userNonce, new ChartAttachment() { WorkbookId = workbookId, WorksheetId = worksheetId, ChartId = chart.Id }); await context.FlushAsync(context.CancellationToken); // Reply with chart URL attached var reply = context.MakeMessage(); reply.Recipient.Id = (reply.Recipient.Id != null) ? reply.Recipient.Id : (string)(HttpContext.Current.Items["UserId"]); var image = new Microsoft.Bot.Connector.Attachment() { ContentType = "image/png", ContentUrl = $"{RequestHelper.RequestUri.Scheme}://{RequestHelper.RequestUri.Authority}/api/{reply.ChannelId}/{reply.Conversation.Id}/{reply.Recipient.Id}/{userNonce}/image" }; reply.Attachments.Add(image); await context.PostAsync(reply); } catch (Exception ex) { await context.PostAsync($"Sorry, something went wrong getting the **{chart.Name}** chart ({ex.Message})"); } }
// Mandatory: you should have this ctor as it is used by the recognizer public MyAwaitableImage(Microsoft.Bot.Connector.Attachment source) : base(source) { }
// Optional: here you can define your custom logic to get the attachment data or add custom logic to check it, etc.. protected override async Task <Stream> ResolveFromSourceAsync(Microsoft.Bot.Connector.Attachment source) { var result = await base.ResolveFromSourceAsync(source); return(result); }