Skip to content

Latest commit

 

History

History
224 lines (134 loc) · 8.57 KB

File metadata and controls

224 lines (134 loc) · 8.57 KB
page_type sample
description Microsoft Teams sample app for demonstrating deeplink from Bot chat to Tab consuming Subentity ID
products
office-teams
office
office-365
languages
csharp
extensions
contentType createdDate
samples
07/07/2021 01:38:27 PM
urlFragment officedev-microsoft-teams-samples-tab-deeplink-csharp

DeepLink

This sample displays how to consume SubEntity Id to DeepLink from Bot to Tab and Tab to Tab.

  • Interaction with bot
Welcome Card Flow

bot-conversations

Deeplink Tab Flow

bot-conversations

Prerequisites

  • Microsoft Teams is installed and you have an account (not a guest account)

  • .NET Core SDK version 6.0

    # determine dotnet version
    dotnet --version
  • ngrok or equivalent tunneling solution

  • M365 developer account or access to a Teams account with the

Setup

Note these instructions are for running the sample on your local machine, the tunnelling solution is required because the Teams service needs to call into the bot.

  1. Register a new application in the Azure Active Directory – App Registrations portal.

  2. Setup for Bot

  • Register a AAD aap registration in Azure portal.

  • Also, register a bot with Azure Bot Service, following the instructions here.

  • Ensure that you've enabled the Teams Channel

  • While registering the bot, use https://<your_ngrok_url>/api/messages as the messaging endpoint.

    NOTE: When you create your app registration, you will create an App ID and App password - make sure you keep these for later.

  1. Setup NGROK
  • Run ngrok - point to port 3978

    # ngrok http -host-header=rewrite 3978
  1. Setup for code
  • Clone the repository

    git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
  • Update channelID placeholer <AddYourTeamsChannelId> value in your DeepLinkBot.cs file with your particular channel id from any Team in Teams. (You can get it manually by clicking on 3 dots in any team's channel and fetch it's link and extract the channel id ) like General channel) Example: 19:cbe3683f25094106b826c9cada3afbe0@thread.skype

  • Update the appsettings.json configuration for the bot to use the MicrosoftAppId, MicrosoftAppPassword, BaseURL , ChannelEntityId is a unique identifier ,TabEntityId as EntityId from Manifest file ,MannifestAppId as manifest ID from manifest file, generated in Step 1 (App Registration creation). (Note the App Password is referred to as the "client secret" in the azure portal and you can always create a new client secret anytime.) - Also, set MicrosoftAppType in the appsettings.json. (Allowed values are: MultiTenant(default), SingleTenant, UserAssignedMSI)

  • If you are using Visual Studio

    • Launch Visual Studio
    • File -> Open -> Project/Solution
    • Navigate to samples/Tab-deeplink/csharp folder
    • Select DeeplinkBot.csproj or DeeplinkBot.slnfile
    • Run your bot, either from Visual Studio with F5 or using dotnet run in the appropriate folder.
  1. This step is specific to Teams.
    • Edit the manifest.json contained in the Manifest folder to replace your Microsoft App Id (that was created when you registered your bot earlier) everywhere you see the place holder string <<YOUR-MICROSOFT-APP-ID>> value(depending on the scenario the Microsoft App Id may occur multiple times in the manifest.json and {{domain-name}} with base Url domain. E.g. if you are using ngrok it would be 1234.ngrok.io)
    • Edit the manifest.json for validDomains with base Url domain. E.g. if you are using ngrok it would be https://1234.ngrok.io then your domain-name will be 1234.ngrok.io. Note: If you want to test your app across multi hub like: Outlook/Office.com, please update the manifest.json in the tab-deeplink\csharp\DeepLinkBot\Manifest_Hub folder with the required values.
    • Zip up the contents of the Manifest folder to create a Manifest.zip or Manifest_Hub folder into a Manifest_Hub.zip. (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
    • Upload the manifest.zip to Teams (In Teams Apps/Manage your apps click "Upload an app". Browse to and Open the .zip file. At the next dialog, click the Add button.)
    • Add the app to personal/team/groupChat scope (Supported scopes)

Running the sample

You can interact with this bot in Teams by sending it a message, or selecting a command from the command list. The bot will respond to the following strings.

  1. Show Welcome
  • Result: The bot will send the welcome card for you to interact with

  • Valid Scopes: personal, Team, chat, Meeting

    • Personal Scope Interactions:

      Adding bot UI:

      personal-AddBot

      Added bot UI:

      personal-AddedBot

      Show Welcome command interaction:

      personal-WelcomeCard-Interaction

      Show Deeplink Tab:

      personal-WelcomeCard-Interaction

    • Teams Scope Interactions:

      Adding bot UI:

      Team-AddBot

      Team Selection for app:

      Team-AddedBot

      App Setup for the specific Team:

      Team-AddedBot

      Show instraction for the team:

      Team-WelcomeCard-Interaction

      Show Deeplink Tab:

      Team-WelcomeCard-Interaction

    • Chat Scope Interactions:

      Adding bot UI:

      Chat-AddBot

      Chat User Selection:

      Chat-AddedBot

      App setup for the specific chat user:

      Chat-AddedBot

      Show user instraction tab:

      Chat-WelcomeCard-Interaction

    • Meeting Scope Interactions:

      Adding bot UI:

      Meeting-AddBot

      Meeting Selection:

      Meeting-AddedBot

      App setup for the specific chat sser:

      Meeting-AddedBot

      Show user instraction tab:

      Meeting-WelcomeCard-Interaction

Outlook on the web

  • To view your app in Outlook on the web.

  • Go to Outlook on the weband sign in using your dev tenant account.

On the side bar, select More Apps. Your sideloaded app title appears among your installed apps

InstallOutlook

Select your app icon to launch and preview your app running in Outlook on the web

AppOutlook

Note: Similarly, you can test your application in the Outlook desktop app as well.

Office on the web

  • To preview your app running in Office on the web.

  • Log into office.com with test tenant credentials

Select the Apps icon on the side bar. Your sideloaded app title appears among your installed apps

InstallOffice

Select your app icon to launch your app in Office on the web

AppOffice

Note: Similarly, you can test your application in the Office 365 desktop app as well.

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.

Further reading