Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
page_type description products languages extensions urlFragment
sample
This sample app demonstrates sending change notifications to user presence in Teams based on user presence status.
office-teams
office
office-365
csharp
contentType createdDate
samples
07-07-2021 13:38:26
officedev-microsoft-teams-samples-graph-change-notification-csharp

Change Notification sample

Bot Framework v4 ChangeNotification sample.

This sample app demonstrates sending change notifications to user presence in Teams based on user presence status.

Prerequisites

  • Microsoft Teams is installed and you have an account
  • .NET Core SDK version 3.1
  • ngrok or equivalent tunnelling solution
  1. Clone the repository

    git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git

A) Or from Visual Studio code

  • Launch Visual Studio code
  • File -> Open Folder
  • Navigate to samples/graph-change-notification/csharp folder
  • Select ChangeNotification folder
  • Press F5 to run the project

B) Run ngrok - point to port 3978

  ngrok http -host-header=rewrite 3978

Instruction on setting connection string for bot authentication on the behalf of user

  1. In the Azure portal, select your resource group from the dashboard.

  2. Select your bot channel registration link.

  3. Open the resource page and select Configuration under Settings.

  4. Select Add OAuth Connection Settings. image

  5. Complete the form as follows:

image

a. Enter a name for the connection. You'll use this name in your bot in the appsettings.json file. For example BotTeamsAuthADv1.

b. Service Provider. Select Azure Active Directory. Once you select this, the Azure AD-specific fields will be displayed.

c. Client id. Enter the Application (client) ID that you recorded for your Azure identity provider app in the steps above.

d. Client secret. Enter the secret that you recorded for your Azure identity provider app in the steps above.

e. Grant Type. Enter authorization_code.

f. Login URL. Enter https://login.microsoftonline.com.

g. Tenant ID, enter the Directory (tenant) ID that you recorded earlier for your Azure identity app or common depending on the supported account type selected when you created the identity provider app. h. For Resource URL, enter https://graph.microsoft.com/ i. Provide Scopes like "Presence.Read, Presence.Read.All" image

Instruction for appsetting

  1. Provide appId and appPassword in the appsetting that is created in Azure.
  2. Provide UserId in appsetting for which you want to subscribe the user presence.
  3. Provide the ngrok url as "BaseUrl" in appsetting on which application is running on.

Concepts introduced in this sample

  • After sucessfully installation of app you will get a sign in button. When sign in is complete then you get your current status in adapative card image image

  • After that when the user status chagnes you will get notify about their status:

  • Change user status from available to busy like image

  • Change user status from busy to busy offline image

Further reading