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. |
|
|
|
Using this C# sample, a bot with capability to upload files to SharePoint site and same files can be viewed in Teams file viewer
-
.NET Core SDK version 3.1
# determine dotnet version dotnet --version
-
Publicly addressable https url or tunnel such as ngrok or Tunnel Relay
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
-
Create a Bot Registration In Azure portal, create a Bot Framework registration resource.
- Ensure that you've enabled the Teams Channel
Add this permission to app registration
-
SharePoint site configuration
- Login to sharepoint
- Click on
Create site
and selectTeam site
- Enter site name and description of site.
-
From site address eg: 'https://m365x357260.sharepoint.com/sites/SharePointTestSite'
m365x357260.sharepoint.com
- value is sharepoint tenant name. -
Click on next. (optional step)Add aditional owner and member.
-
Click on Finish.
-
Modify the
manifest.json
in the/AppManifest
folder and replace the<<Microsoft-App-Id>>
with the id from step 2. -
Zip the contents of
AppManifest
folder into amanifest.zip
, and use themanifest.zip
to deploy in app store or add to Teams as in step 6. -
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}}
. -
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
-
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
To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.