0

I have a requirement for a bot to send a file as a downloadable to the users in Skype. The files are in physical path.

Below is the code:

public async Task SelectedOptionAsync(IDialogContext context, IAwaitable<string> argument) 
{ 
 var message = await argument; 
 var replyMessage = context.MakeMessage(); 
 Attachment attachment = null; 
 attachment = GetLocalAttachment(); 
 replyMessage.Attachments = new List<Attachment> { attachment }; 
 await context.PostAsync(replyMessage); 
 await this.DisplayOptionsAsync(context); 
} 

private static Attachment GetLocalAttachment() 
{ 
 var Path = HttpContext.Current.Server.MapPath("~/images/demo.pdf"); 
 var pdfdata = Convert.ToBase64String(File.ReadAllBytes(Path)); 
 return new Attachment 
 { 
 Name = "demo.pdf", 
 ContentType = "application/pdf", 
 ContentUrl = $"data:application/pdf;base64,{pdfdata}" 
 }; 
}

In the above code I am trying to attach the contents of the file in the Message attachment. When I checked the Skype Channel, it displays "MIME type is Invalid"

Note: this is working in the Emulator. I am not using Skype for Business. Also I am aware that this functionality does not work in the Skype for Business.

Also I need to send the location of the file as Hyperlink URL to the user. Currently we were only able to send as String and not as URL. For this functionality we are using Hero Cards.

halfer
  • 19,824
  • 17
  • 99
  • 186
Naveen Prasath
  • 539
  • 1
  • 3
  • 23

1 Answers1

1

Sending PDFs like this is not supported by skype bots at this time. I ran into this issue as well and this is the response I got from the Skype team. "Bots in Skype can send only media attachments (video, audio) due to security concerns with sending potentially dangerous files."

for your follow up question have you tried markdown? [text](https://example.com)?

D4RKCIDE
  • 3,439
  • 1
  • 18
  • 34
  • Thanks for your response. Also i want to send the url from bot. I have tried to sending it in the postAysnc method. But the user received the url message as text. Any ideas on it? – Naveen Prasath Mar 08 '18 at 13:56
  • Can you please share the code you are using to send the URL? – D4RKCIDE Mar 08 '18 at 19:21