Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
page_type description products languages extensions
sample
This sample demos a bot with capability to upload files to SharePoint site and same files can be viewed in Teams file viewer.
office-teams
office
office-365
csharp
contentType createdDate
samples
16-11-2021 00:15:13

Bot with SharePoint file to view in Teams file viewer

Using this C# sample, a bot with capability to upload files to SharePoint site and same files can be viewed in Teams file viewer

Key features

upload file card

Upload file

View file card

view file in teams

Prerequisites

Setup

1 Clone the repository

```bash
git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
```

2 In a terminal, navigate to samples/bot-sharepoint-file-viewer/csharp

3 Run ngrok - point to port 3978

# ngrok http -host-header=rewrite 3978
  1. Create a Bot Registration In Azure portal, create a Bot Framework registration resource.

    Add this permission to app registration

Permissions

  1. SharePoint site configuration

    • Login to sharepoint
    • Click on Create site and select Team site

    Team Site

    • Enter site name and description of site.

    Site name.

  2. Modify the manifest.json in the /AppManifest folder and replace the <<Microsoft-App-Id>> with the id from step 2.

  3. Zip the contents of AppManifest folder into a manifest.zip, and use the manifest.zip to deploy in app store or add to Teams as in step 6.

  4. Modify the /appsettings.json and fill in the {{ Bot Id }},{{ Bot Password }},{{ Connection Name }} with the id from step 2 and {{Sharepoint tenant name}},{{Sharepoint site name}} from step 5 and {{Appbase-url}}.

  5. Upload the manifest.zip to Teams (in the Apps view click "Upload a custom app")

    • Go to Microsoft Teams. From the lower left corner, select Apps
    • From the lower left corner, choose Upload a custom App
    • Go to your project directory, the ./appPackage folder, select the zip folder, and choose Open.
    • Select Add in the pop-up dialog box. Your tab is uploaded to Teams

To try this sample

  • In a terminal, navigate to BotWithSharePointFileViewer

    # change into project folder
    cd # BotWithSharePointFileViewer
  • Run the bot from a terminal or from Visual Studio, choose option A or B.

    A) From a terminal

    # run the bot
    dotnet run

    B) Or from Visual Studio

    • Launch Visual Studio
    • File -> Open -> Project/Solution
    • Navigate to samples/bot-sharepoint-file-viewer/csharp folder
    • Select BotWithSharePointFileViewer.csproj file
    • Press F5 to run the project

Deploy the bot to Azure

To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.