page_type | description | products | languages | extensions | urlFragment | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
This sample app shows the interaction between teams bot and SharePoint List, Bot saves the specified details in SharePoint List as back-end |
|
|
|
officedev-microsoft-teams-samples-bot-sharepoint-list-csharp |
Bot Framework v4 SPListBot sample.
This bot has been created using Bot Framework, it shows how to create a simple bot that accepts input from the user and save it into sharepoint's List.
-
.NET Core SDK version 6.0
# determine dotnet version dotnet --version
-
Clone the repository
git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
-
Run the bot from a terminal or from Visual Studio:
A) From a terminal, navigate to
samples/bot-sharepoint-list/csharp
folder# run the bot dotnet run
B) Or from Visual Studio
- Launch Visual Studio
- File -> Open -> Project/Solution
- Navigate to
samples/bot-sharepoint-list/csharp
folder - Select
SPListBot.csproj
file - Press
F5
to run the project
You need to register a new addin/app in your Sharepoint site, this will generate a ClientID and a Client Secret, which we will use to authenticate. Lets see how to do it.
Go to
_layouts/15/appregnew.aspx
under the SP Online site which you want to use as document repository.It is very important to know your tenant ID for triggering any kind of service calls. You can get your Tenant ID, Resource Id by following below points:
- Navigate to
https//{SharePointDomain}/_layouts/15/appprincipals.aspx
- You will see Site Collection App Permissions under site settings.
- You can check your any App and get the Tenant Id and Resource Id from
App Identifier
. The part after "@" is yourtenant ID
and the part before @ isResource ID
.
MicrosoftAppId:
<<Your Microsoft Bot_Id>>
"MicrosoftAppPassword":
<<Your Microsoft Bot_Secret>>
"BaseUrl":
<<Bot_endpoint_url>>
"TenantID":
<<Sharepoint Tenant Id>>
"ResourceID":
<<SP_Resource_ID>>
"TenantName":
<<sahrepoint Tenant Name>>
"SiteName":
<<Shareppint site name>>
"ListName":
<<Custom list name which created at site>>
"AppClientID":
<<Custom Client App ID created at sharepoint App>>
"AppSecret":
<<App Secret Id for sharepoint App>>
New Client app has been created in SP Online site, now its time to decide what permissions this app should have on your site. You can grant Site collection, web or even at list level read or write permissions.
Go to
/_layouts/15/appinv.aspx
and serach with ClientID we generated earlier. The application will fetch all other details based on your ClientID.
- Navigate to
AppManifest
folder - Select the
Manifest.json
and update it with yourYour Bot Id
- Now zip the manifest.json along with icons
- Go to teams and do
Upload a Custom App
- Add the Bot to Microsoft Teams
- Start the conversation with Bot
- Ping the bot in 1:1 or channel scope
- Bot will send an Adaptive card having two fields name and address.
- Enter the values in Adaptive Card and click on Save button.
- Bot will save the card data in SharePoint List.
Note: If you are facing any issue in your app, please uncomment this line and put your debugger for local debug.
Upload the custom app in Teams
Interaction with the Bot
Ping the Bot