0
votes

NodeJS BotBuilder SDK version: 3.15.0 My code:

var pdf = {
  name: '<file_name>.pdf',
  contentType: 'application/pdf',
  contentUrl: '<https url to public pdf file>'
};
var reply = new builder.Message(session).addAttachment(pdf);
session.send(reply);

This code is the same in few online examples. The issue I have is that I always get error:

Error: POST to 'https://smba.trafficmanager.net/emea/v3/conversations/a%3A1TwHmhoGuZP2Mf9P0TTnjv8HkcaXzEHryv0sYCvDDUI-qrMitJtHRlAnIcedcDH_v3IfMBXtg_zo5MDVcS0-8hDCQ4sJzpJhrewBPK8uWJXYeShgmd-s7uh5o8kW4ebAP/activities/1543588440246' failed: [400] Bad Request

For image/png this code works fine.

What I want to achieve is this: (image is taken from Bot Framework Emulator) File from the web sent from bot to user

The file is sent from bot without uploading it to users's one drive. This works also when I tested the feature in test section of https://dev.botframework.com/bots. It doesn't work only in ms teams.

1
Did you have a look at the Send and receive files through your bot documentation? It looks like the flow on Microsoft Teams is different and you have to enable it in your manifest.Mick
Yes, I did. I have enabled the flow in the manifest and did everything according to the documentation, and that part is perfectly fine. What I want to achieve is just to be able to send user a pdf file without having to ask for permission and to upload file to user's one drive. I will edit my post to explain a little better. @MickBojan Todorovic

1 Answers

0
votes

The behaviour for sending files can differ per channel. Microsoft Teams doesn't support the direct upload method, like the WebChat / Emulator does. This is due to compliance reasons, as Bill Bliss stated.

You can post messages with card attachments referencing existing SharePoint files using the Microsoft Graph APIs for OneDrive and SharePoint. Using the Graph APIs requires obtaining access to a user's OneDrive folder (for personal and groupchat files) or the files in a team's channels (for channel files) through the standard OAuth2 authorization flow. This method works in all Teams contexts.

Have a look at Send and receive files through your bot for the full documentation and how to implement.


An alternative option would be to use an AdaptiveCard where you can use an image thumbnail of the document combined with a button to directly download the PDF file from your public accessible URL.