Ennova
Ennova

Reputation: 672

A generic FileCard attachment for Microsoft Teams Bot Framework based bots for self-hosted files?

https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/bots-filesv4 describes a consent-based file sending process where a bot receives a users consent to upload a file to their onedrive and is able to send a FileAttachment card which renders a nice File chicklet view in the users Teams client. The chicklet view lets the user view the file in the Teams built in browser or download it or save it etc. More sample code here: https://techcommunity.microsoft.com/t5/microsoft-teams-blog/working-with-files-in-your-microsoft-teams-bot-preview/ba-p/199441

The final file attachment JSON looks like this

    {
  "attachments": [{
    "contentType": "application/vnd.microsoft.teams.card.file.info",
    "contentUrl": "https://contoso.sharepoint.com/personal/johnadams_contoso_com/Documents/Applications/file_example.txt",
    "name": "file_example.txt",
    "content": {
      "uniqueId": "1150D938-8870-4044-9F2C-5BBDEBA70C8C",
      "fileType": "txt",
    }
  }]
}

The rendering on the Teams client looks like this (taken from a different file send). Clicking on the icon opens the Teams built in File Viewer and

enter image description here

In our case our bot is already hosting a set of files that it needs to send a user. We can obviously just send a URL to the file location using Markdown but that causes the Teams client to download the file, user then has to go locate the file in their Downloads folder, and then view the file. (A multi-step process to view the file)

We are hoping to find an attachment type that has the same UX as the built in FileAttachment above i.e does not rely on first uploading to user's onedrive etc. When we try to use the same FileCard format but use our own contentURL , the click actions, unsurprisingly, fail.

Q: Is there a similar attachment type available in the Bot Framework for Teams which will generate a similar experience for the user (nice chicklet view, leverage built in Teams viewer, with option to open in browser or download) but with a file that is hosted by the bot at a reachable web URL (rather than first uploading to a user's One Drive)? Anyone attempted to do this using an adpative card?

(p.s sending image files has a work around which causes images to render inline, so this is about other file types such as PDF or Powerpoint)

Upvotes: 0

Views: 723

Answers (1)

Scott Perham
Scott Perham

Reputation: 2470

Unfortunately, there isn't a built-in card (or a version of the File info card) that supports downloading from arbitrary urls - this can only be used for files hosted in OneDrive or SharePoint (depending on the context).

One possible option is to display a "regular" adaptive card with an action that launches a task module and then handle the file download yourself from there using JS and the Teams SDK.

Upvotes: 1

Related Questions