Skip to content

Latest commit

 

History

History
page_type description products languages extensions urlFragment
sample
This is an sample tab application which shows the contents of tab context object in a private and shared channel.
office-teams
office
office-365
nodejs
javascript
contentType createdDate
samples
17/06/2022 12:26:57 PM
officedev-microsoft-teams-samples-tab-channel-context-nodejs

Prerequisites

Tab context in channel

This sample shows the contents of tab context object in a private and shared channel.

Included Features

  • Tabs

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.

Interaction with app

PreviewImage

Setup

  1. Setup NGROK 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
  2. Clone the repository

    git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
  3. Install node modules

    Inside node js folder, navigate to samples/tab-channel-context/nodejs open your local terminal and run the below command to install node modules. You can do the same in Visual Studio code terminal by opening the project in Visual Studio code.

    npm install
    
  4. Run the solution from the same path terminal using below command.

    npm start
    
  5. Modify the manifest.json in the /appManifest folder and replace the following details

    • {{Manifest-id}} with some unique GUID. Refer GUID generator
    • {{base-url}} with base Url domain. E.g. if you are using ngrok it would be https://1234.ngrok-free.app and if you are using dev tunnels, your URL will be like: https://12345.devtunnels.ms.
    • <<Domain Name>> with base Url domain. E.g. if you are using ngrok it would be https://1234.ngrok-free.app then your domain-name will be 1234.ngrok-free.app and if you are using dev tunnels then your domain will be like: 12345.devtunnels.ms.
  6. Zip the contents of appManifest folder into a manifest.zip, and use the manifest.zip to deploy in app store or add to Teams.

  7. 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 Apps -> Manage your apps -> Upload an 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 app is uploaded to Teams.
  8. Add the tab in private/shared channel.

NOTE: Only accounts with admin access can create private/shared channels in team.

Running the sample

  1. Configure in Regular channel

image1

image2

image3

image4

  1. Configure in Private channel

image5

image6

image7

image8

Features of the sample

  • Add the tab in private/shared channel.
  • The details of the context object will be shown on tab based on channel type.
  • You can expand/reduce the JSON for the context object and can also copy a particular object slice.

Further reading