How can I attach file to message with Microsoft Bot Framework?
<p>I have Web API service:</p>

<pre><code>[ActionName("download")]
[HttpGet]
public HttpResponseMessage Download()
{
    var stream = new FileStream(HostingEnvironment.MapPath("~/tmp/") + "doc.pdf", FileMode.Open);
    var result = new HttpResponseMessage(HttpStatusCode.OK)
    {
        Content = new StreamContent(stream)
    };
    result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
    {
        FileName = document.Name + "." + document.AssociatedApplication.Extension
    };

    result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
    return result;
}
</code></pre>

<p>Bot's code:</p>

<pre><code>if (message.Text.StartsWith("/d"))
{
    var contentType = "application/pdf";
    var attachment = new Attachment(contentType, "https://localhost/api/documents.download");
    var response = await client.GetAsync("https://localhost/api/documents.download");

    var data = await response.Content.ReadAsByteArrayAsync();
    System.IO.File.WriteAllBytes(HostingEnvironment.MapPath("~/tmp/") + document.Name + "." + document.Extension, data);

    var stream = System.IO.File.ReadAllBytes(HostingEnvironment.MapPath("~/tmp/") + document.Name + "." + document.Extension);
    attachment.Content = stream;

    var msg = message.CreateReplyMessage("This is your document: ");
    msg.Attachments = new[] { attachment };

    await context.PostAsync(msg);
}
</code></pre>

<p>If I change content type on the server and client to "image/png" and send PNG image from server to client then this sample works perfect - in the Bot Framework Emulator I got text "This is your document: " and received image.</p>

<p>But if I try to send PDF document with content type "application/pdf" or "application/octet-stream" and get it on the client with content type "application/pdf" then on the Bot Framework Emulator I got message like that:</p>

<blockquote>
  <p>This is your document: (<a href="https://localhost/api/documents.download" rel="nofollow noreferrer">https://localhost/api/documents.download</a>)</p>
</blockquote>

<p>Is this possible to get in the conversation "real" document instead of link for download (how it works with images)?</p>

<p>PS: <a href="https://stackoverflow.com/questions/36349631/ability-to-receive-files-with-the-ms-bot-framework/36355638#36355638">This question</a> works only for "image/png" or similar content types.</p>