Skip to content

Latest commit

 

History

History
page_type description products languages extensions urlFragment
sample
This sample application demonstrates how to retrieve meeting attendance reports using the Graph API and send them through a bot in the meeting chat.
office-teams
office
office-365
csharp
contentType createdDate
samples
08/20/2022 00:01:15
officedev-microsoft-teams-samples-meetings-attendance-report-csharp

Meeting attendance report

This sample application showcases how to utilize the Graph API to generate meeting attendance reports and deliver them through a bot in Microsoft Teams chat. Users can effortlessly manage attendance tracking, ensuring they stay informed about participant engagement during meetings.

Included Features

  • Bots
  • Graph API

Interaction with app

When meeting ends, attendance report card is sent by the bot.

Attendance Report

Prerequisites

Run the app (Using Teams Toolkit for Visual Studio)

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

  1. Install Visual Studio 2022 Version 17.10 Preview 4 or higher Visual Studio
  2. Install Teams Toolkit for Visual Studio Teams Toolkit extension
  3. In the debug dropdown menu of Visual Studio, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel.
  4. In the debug dropdown menu of Visual Studio, select default startup project > Microsoft Teams (browser)
  5. In Visual Studio, right-click your TeamsApp project and Select Teams Toolkit > Prepare Teams App Dependencies
  6. Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps.
  7. Select Debug > Start Debugging or F5 to run the menu in Visual Studio.
  8. 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

  1. Register a new application in the Microsoft Entra ID – App Registrations portal.

    • Click on "New registration", and create an Azure AD application.

    • Name: The name of your Teams app - if you are following the template for a default deployment, we recommend "App catalog lifecycle".

    • Supported account types: Select "Accounts in any organizational directory"

    • Leave the "Redirect URL" field blank.

    • Click on the "Register" button.

    • When the app is registered, you'll be taken to the app's "Overview" page. Copy the Application (client) ID; we will need it later. Verify that the "Supported account types" is set to Multiple organizations.

    • On the side rail in the Manage section, navigate to the "Certificates & secrets" section. In the Client secrets section, click on "+ New client secret". Add a description for the secret and select Expires as "Never". Click "Add".

    • Once the client secret is created, copy its Value, please take a note of the secret as it will be required later.

    • At this point you have 3 unique values:

      • Application (client) ID which will be later used during Azure bot creation
      • Client secret for the bot which will be later used during Azure bot creation
      • Directory (tenant) ID We recommend that you copy these values into a text file, using an application like Notepad. We will need these values later.
    • Under left menu, navigate to API Permissions, and make sure to add the following permissions of Microsoft Graph API > Application permissions:

      • OnlineMeetingArtifact.Read.All

    Click on Add Permissions to commit your changes.

    • If you are logged in as the Global Administrator, click on the Grant admin consent for %tenant-name% button to grant admin consent else, inform your admin to do the same through the portal or follow the steps provided here to create a link and send it to your admin for consent.

    • Global Administrator can grant consent using following link: https://login.microsoftonline.com/common/adminconsent?client_id=<%appId%>

  2. Setup for Bot SSO

  • 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_tunnel_domain>/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. Allow applications to access online meetings on behalf of a user
  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
  • Once started you should see URL https://123.ngrok-free.app if you are using Ngrok and if you are using dev tunnels, your URL will be like: https://12345.devtunnels.ms. Copy it, this is your baseUrl that will used as endpoint for Azure bot and webhook.

  1. Setup for code
  • Clone the repository

    git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
  • Update the appsettings.json configuration for the bot to use the MicrosoftAppId and MicrosoftAppPassword and MicrosoftAppTenantId and AppBaseUrl and UserId (Note that the MicrosoftAppId is the AppId created in step 1 , the MicrosoftAppPassword is referred to as the "client secret" in step 4 and you can always create a new client secret anytime., MicrosoftAppTenantId is reffered to as Directory tenant Id in step 1, AppBaseUrl is the URL that you get in step 2 after running the tunnelling application, UserId of the user used while granting the policy in step 1).

  • Run the bot from a terminal or from Visual Studio:

    A) From a terminal, navigate to MeetingAttendance

    # run the bot
    dotnet run

    B) Or from Visual Studio

  • Launch Visual Studio

  • File -> Open -> Project/Solution

  • Navigate to samples/meetings-attendance-report/csharp folder

  • Select MeetingAttendance.csproj file

  • Press F5 to run the project

  1. Setup Manifest for Teams
  • This step is specific to Teams.
    • Edit the manifest.json contained in the appPackage 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>> (depending on the scenario it may occur multiple times in the manifest.json) Also replace the <> with any valid GUID or with your MicrosoftAppId
    • Edit the manifest.json for configurationUrl inside configurableTabs . Replace <your_tunnel_domain> 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.
    • Edit the manifest.json for validDomains 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.
    • Zip up the contents of the appPackage folder to create a manifest.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)

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

Running the sample

Schedule the meeting and add Meeting Attendance Bot from Apps section in that particular scheduled meeting:

Install

Add Meeting UI:

Add Meeting

On installation you will get a welcome card

Welcome Card

Once the bot is installed in the meeting, whenever meeting ends bot will send attendance report:

Attendance Report

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