Skip to content

A Microsoft Teams search-based messaging extension using SSO with Microsoft Graph and Azure App Configuration

Notifications You must be signed in to change notification settings

mmsharepoint/msgext-graph-srch-config-csharp

Repository files navigation

msgext-graph-srch-config-csharp

A Microsoft Teams search-based messaging extension using SSO with Microsoft Graph and Azure App Configuration

Summmary

This sample is a search-based messaging extension created using the Teams Toolkit with Visual Studio 2022. It authenticates against Microsoft Graph via SSO and receives documents to be posted as adaptive card to the message compose box of a channel or conversation. The essential thing is that it is configurable and persists it's configuration to an Azure App Configuration resource.

Configuration Page

Configuration of a search-based Teams Message extension ...

Message Extension

Message extension in action...

For further details see the author's blog post

Applies to

This sample was created using the Teams Toolkit with Visual Studio 2022. Nearly the same sample was also realized with the Yeoman Generator for Teams and can be found here.

Version history

Version Date Author Comments
1.0 April 12, 2023 Markus Moeller Initial release

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.


Minimal Path to Awesome

  • Clone the repository
    git clone https://github.com/mmsharepoint/tab-sso-graph-upload-pdf-csharp.git
  • Open msgext-graph-search-config.sln in Visual Studio
  • Perform first actions in GettingStarted.txt (before hitting F5)
  • Copy .\msgext-graph-action-config-csharp\MsgextGraphActCfg.fx\states\state.local.json to .\msgext-graph-action-config-csharp\MsgextGraphActCfg.fx\states\state.dev.json Nevertheless, even when debugging locally Bot Emulator does not support SSO with OAuthConnection so a Bot Service is needed
  • So execute Teams Toolkit \ Provision in the Cloud
  • This should provison a Bot in Azure
  • Ensure there is an app registration for the bot
    • with redirect uri https://token.botframework.com/.auth/web/redirect
    • with SignInAudience multi-tenant
    • with client secret
    • with delegated permission Sites.Read.All
    • With exposed Api "access_as_user" and App ID Uri api://YourNgrokUrl/
    • With the client IDs for Teams App and Teams Web App 1fec8e78-bce4-4aaf-ab1b-5451cc387264 and 5e3ce6c0-2b1f-4285-8d4b-75ee78787346
  • Find/Add the app registration ClientId, ClientSecret as BOT_ID, BOT_PASSWORD to your appsettings.json (or a appsettings.Development.json)
  • Also add to .\msgext-graph-action-config-csharp\MsgextGraphActCfg.fx\states\state.dev.json
  • Generate an Azure App Configuration resource and copy the Primary Key Connection String to appsettings.json (or a appsettings.Development.json) as "AZURE_CONFIG_CONNECTION_STRING":
  • Execute Teams Toolkit \ ZIP App Package \ For Azure
  • Press F5
  • When Teams opens in Browser and tries to add the app, skip that
  • Instead manually upload .\msgext-graph-action-config-csharp\MsgextGraphActCfg\build\appPackage\appPackage.dev as app to a Team
  • In channel conversation open "Messaging extensions ..."
  • Right click the app icon and configure with valid siteID, listID to a document library of your choice
  • Left click app icon to retrieve and select document as Adaptive Card

Features

This is a simple search-based messaging extension. It offers documents retrieved from Microsoft Graph for selection and to be posted to the current Team's news channel.

  • SSO access token generation to access Microsoft Graph
    • Retrieves documents either via listItems from site / list or
    • Uses search to retrieve them independently from sites / lists Blog post
  • Post an adaptive card
  • A configuration page to offer self service configuration of the SiteID and ListID where the documents reside
  • Configuraton storage in Azure App Configuration
  • Secret Storage and consumption in Azure Key Vault

About

A Microsoft Teams search-based messaging extension using SSO with Microsoft Graph and Azure App Configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published