Skip to content

Latest commit

 

History

History
page_type description products languages extensions urlFragment
sample
This sample app demonstrates the use of Teams tab in stage view using Node.js, featuring collaborative elements and interactive capabilities.
office-teams
office
office-365
nodejs
contentType createdDate
samples
10/06/2021 01:48:56 AM
officedev-microsoft-teams-samples-tab-stage-view-nodejs

Stage View

This sample app showcases the capabilities of Microsoft Teams tabs in stage view using Node.js. It demonstrates collaborative features such as multi-window support and interactive elements, allowing users to engage dynamically through adaptive cards and deep linking for a richer experience in Teams. This App talks about the Teams tab in stage view with Nodejs.

For reference please check Tabs link unfurling and Stage View

Included Features

  • Bots
  • Stage View (tabs)
  • Collaborative Stageview
  • Stageview Multi-window (PopOut)
  • Stageview Modal

Interaction with app

Tab Stage ViewGif

Try it yourself - experience the App in your Microsoft Teams client

Please find below demo manifest which is deployed on Microsoft Azure and you can try it yourself by uploading the app package (.zip file link below) to your teams and/or as a personal app. (Sideloading must be enabled for your tenant, see steps here).

Stage View: Manifest

Prerequisites

  • Office 365 tenant. You can get a free tenant for development use by signing up for the Office 365 Developer Program.

  • To test locally, NodeJS must be installed on your development machine (version 16.14.2 or higher).

    # determine node version
    node --version
  • dev tunnel or Ngrok (For local environment testing) latest version (any other tunneling software can also be used) If you using Ngrok to test locally, you'll need Ngrok installed on your development machine. Make sure you've downloaded and installed Ngrok on your local machine. ngrok will tunnel requests from the Internet to your local computer and terminate the SSL connection from Teams.

  • Teams Toolkit for VS Code or TeamsFx CLI

Run the app (Using Teams Toolkit for Visual Studio Code)

The simplest way to run this sample in Teams is to use Teams Toolkit for Visual Studio Code.

  1. Ensure you have downloaded and installed Visual Studio Code
  2. Install the Teams Toolkit extension
  3. Select File > Open Folder in VS Code and choose this samples directory from the repo
  4. Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps
  5. Select Debug > Start Debugging or F5 to run the app in a Teams web client.
  6. In the browser that launches, select the Add button to install the app to Teams.

If you do not have permission to upload custom apps (sideloading), Teams Toolkit will recommend creating and using a Microsoft 365 Developer Program account - a free program to get your own dev environment sandbox that includes Teams.

Setup

NOTE: The free ngrok plan will generate a new URL every time you run it, which requires you to update your Azure AD registration, the Teams app manifest, and the project configuration. A paid account with a permanent ngrok URL is recommended.

  1. Setup for Bot

    • Register Azure AD application
    • Register a bot with Azure Bot Service, following the instructions here.
    • While registering the bot, use https://<your_tunnel_domain>/api/messages as the messaging endpoint.

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

  2. Setup NGROK

  3. Run ngrok - point to port 3978

    ngrok http 3978 --host-header="localhost:3978"

    Alternatively, you can also use the dev tunnels. Please follow Create and host a dev tunnel and host the tunnel with anonymous user access command as shown below:

    devtunnel host -p 3978 --allow-anonymous
  4. Setup for code

  • Clone the repository

    git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
  • In a console, navigate to samples/tab-stage-view/nodejs folder

  • Install modules

    npm install
  • Update the .env configuration for the bot to use the MicrosoftAppId (Microsoft App Id) and MicrosoftAppPassword (App Password) from the Azure bot registration in Azure portal or Bot Framework registration. Also update BaseUrl according to your code runtime environment.

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.

  • Run your bot at the command line:

    npm start
  • Install modules & Run the NodeJS Server

    • Server will run on PORT: 3978

    • Open a terminal and navigate to project root directory

      npm run server
  • This command is equivalent to: npm install > npm start

  • Setup Manifest for Teams

  1. This step is specific to Teams.

    • Edit the manifest.json in the appManifest folder and replace the following details:
    • <<MANIFEST-ID>> with some unique GUID or MicrosoftAppId
    • <<BASE-URL>> with your application's base url, e.g. https://1234.ngrok-free.app
    • <<YOUR-MICROSOFT-APP-ID>> with the MicrosoftAppId received from Microsoft Entra ID app registration in Azure portal.
    • <<DOMAIN-NAME>> with the ngrok URL or app hosted base url. Note: If you want to test your app across multi hub like: Outlook/Office.com, please update the manifest.json in the tab-stage-view\nodejs\appManifest_Hub folder with the required values.
    • Zip up the contents of the appManifest folder to create a Manifest.zip or appManifest_Hub folder to create a appManifest_Hub.zip
    • 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 ./appManifest folder, select the zip folder, and choose Open. - Select Add in the pop-up dialog box. Your tab is uploaded to Teams.

Note: If you are facing any issue in your app, please uncomment this line and put your debugger for local debug..

Running the sample

  • From Teams left side bar, select the ellipses ●●● and choose your app from the list.

Install App:

InstallApp

Welcome message with feature explanation and Adaptive Card with actions:

Welcome Message

Open the URL in tab stage view:

InstallApp

Click view via card action:

Stage View in tab

Click view via deeplink:

Tab View

Opening Collaborative- Desktop Stage View. Please refer Collaborative Stage view for more details.

Stage View in tab

OpenMode Model

OpenMode PopOut

Opening stage view from Adaptive card via deep link:

Stage View Deep Link

Web Stage View:

LinkUnfurlingStageView

Opening stage view from unfurling link. If you copy and paste a link from https://tabstageview.com/card into the compose message area, the link will unfurl.

LinkUnfurlingText

Tab with execute deep link action to open stage view:

Tab View

Click deep-link:

Tab View

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

After opening Outlook web, click the "New mail" button.

Open New Mail

On the tool bar on top, select Apps icon. Your sideloaded app title appears among your installed apps

OpenAppIcon

Opening stage view from unfurling link. If you copy and paste a link from https://tabstageview.com/card into the compose message area the link will unfurl.

Outlook Unfurling

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