Skip to content

Latest commit

 

History

History
 
 
page_type description products languages extensions contentType createdDate
sample
This sample illustrates how you can use Proactive installation of app for user and send proactive notification by calling Microsoft Graph APIs.
office-teams
office
office-365
nodejs
samples
07-07-2021 13:38:26

Proactive Installation Sample App

This sample app illustartes the proactive installation of app using Graph API and sending proactive notification to users from GroupChat or Channel.

Language Used : Nodejs

Prerequisites

Tools

  • Node.js version 10.14 or higher

    # determine node version
    node --version

To try this sample

  • 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 bot you will create an App ID and App password - make sure you keep these for later.

  1. Clone the repository
    git clone https://github.com/OfficeDev/microsoft-teams-samples.git
  • In a terminal, navigate to samples/javascript_nodejs/graph-proactive-installation
    cd samples/graph-proactive-installation/nodejs
  • Install modules
    npm install
  • Start the bot
    npm start
  1. Run the bot from Visual Studio Code:

    • Launch Visual Studio Code
    • Folder -> Open -> Project/Solution
    • Navigate to samples/graph-proactive-installation/nodejs folder
    • Select nodejs Folder
    • To run the application required node modules. Please use this command to install modules npm install
  2. Run ngrok - point to port 3978

       ngrok http -host-header=rewrite 3978
  3. Update the manifest.json file with Microsoft-App-ID value and to get TeamsAppCatalogId upload your Manifest for my Organization. image

  4. Go to .env file and add MicrosoftAppId , MicrosoftAppPassword and AppCatalogTeamAppId information.

    • To get AppCatalogTeamAppId navigate to following link in your browser Get TeamsAppCatalogId from Microsoft Graph explorer. And then search with app name or based on Manifest App id in Graph Explorer response and copy the Id [i.e teamApp.Id]
  5. Required Microsoft graph Application level permissions to run this sample app

    • TeamsAppInstallation.ReadWriteForUser.All
  6. Get consent for the Application permissions by following steps mentioned here.

  7. Run your app, either from Visual Studio code with npm start or using Run in the Terminal.

Interacting with the Proactive installation App in Teams

  • Install the Proactive App Installation demo in a Team or GroupChat. image

  • Team Scope: Run Check and install to pro-actively installs the App for all the users in team. After installation send 'Send message' command to send proactive message. image

  • Group Chat: Run Check and install to pro-actively installs the App for all the users in team. After installation send 'Send message' command to send proactive message. image

Further Reading