Skip to content

Commit

Permalink
Merge pull request #774 from OfficeDev/v-pritka/meetings-notification…
Browse files Browse the repository at this point in the history
…-feedback-changes

Added sdk changes for meetings notification sample
  • Loading branch information
Prithvi-MSFT authored Apr 18, 2023
2 parents 9f30fc9 + c6191c5 commit 4be0ed9
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,42 +160,11 @@ private async Task HandleActions(ITurnContext<IMessageActivity> turnContext, Can
{
var actionSet = JsonConvert.DeserializeObject<ActionBase>(turnContext.Activity.Value.ToString());
var selectedMembers = actionSet.Choice;
var recipients = JsonConvert.SerializeObject(selectedMembers.Split(","));
var pageUrl = JsonConvert.SerializeObject(_config["BaseUrl"] + "/SendNotificationPage");
var pageUrl = _config["BaseUrl"] + "/SendNotificationPage";
var meetingId = turnContext.Activity.TeamsGetMeetingInfo()?.Id ?? throw new InvalidOperationException("This method is only valid within the scope of a MS Teams Meeting.");
TargetedMeetingNotification notification = GetTargetedMeetingNotification(selectedMembers.Split(',').ToList(), pageUrl);

// Notification payload for meeting target notification API.
string notificationPayload = @"{
""type"": ""targetedMeetingNotification"",
""value"": {
""recipients"": " + recipients + @",
""surfaces"": [{
""surface"": ""meetingStage"",
""contentType"": ""task"",
""content"": {
""value"": {
""height"": ""300"",
""width"": ""400"",
""title"": ""Targeted meeting Notification"",
""url"": " + pageUrl + @"
}
}
}]}}";

var httpClient = _httpClientFactory.CreateClient();
var serviceUrl = turnContext.Activity.ServiceUrl;

var url = serviceUrl + "v1/meetings/" + meetingId + "/notification";
HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Post, url);

var Client = turnContext.TurnState.Get<IConnectorClient>();
var creds = Client.Credentials as AppCredentials;
var bearerToken = await creds.GetTokenAsync().ConfigureAwait(false);
httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
httpRequest.Content = new StringContent(notificationPayload, Encoding.UTF8, "application/json");

//Make the post http call for sending targeted notifications.
HttpResponseMessage httpResponse = await httpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
await TeamsInfo.SendMeetingNotificationAsync(turnContext, notification, meetingId);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -268,5 +237,41 @@ private Attachment GetAdaptiveCardAttachment(string fileName, object cardData)
};
return adaptiveCardAttachment;
}

/// <summary>
/// Create Notification for send to recipients
/// </summary>
/// <param name="recipients">List of members added to the conversation.</param>
/// <param name="pageUrl">page url that will be load in the notification.</param>
/// <returns>Target meeting notification object.</returns>
private TargetedMeetingNotification GetTargetedMeetingNotification(List<string> recipients, string pageUrl)
{
TargetedMeetingNotification notification = new TargetedMeetingNotification()
{
Type = "TargetedMeetingNotification",
Value = new TargetedMeetingNotificationValue()
{
Recipients = recipients,
Surfaces = new List<Surface>()
{
new MeetingStageSurface<TaskModuleContinueResponse>()
{
ContentType = ContentType.Task,
Content = new TaskModuleContinueResponse
{
Value = new TaskModuleTaskInfo()
{
Title = "Targeted meeting Notification",
Height =300,
Width = 400,
Url = pageUrl
}
}
}
},
}
};
return notification;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<PackageReference Include="AdaptiveCards" Version="2.7.3" />
<PackageReference Include="AdaptiveCards.Templating" Version="1.3.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.11" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.18.1" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.18.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.19.2" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.19.2" />
<PackageReference Include="NEST" Version="7.17.5" />
</ItemGroup>

Expand Down
16 changes: 8 additions & 8 deletions samples/meetings-notification/csharp/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
page_type: sample
description: Microsoft Teams meeting extensibility sample for iteracting with Content Bubble Bot in-meeting
description: Microsoft Teams meeting extensibility sample for iteracting with In-meeting notificaion and Targegted Meeting Notifications
products:
- office-teams
- office
Expand All @@ -15,22 +15,23 @@ urlFragment: officedev-microsoft-teams-samples-meetings-notification-csharp

# Meetings Notification

This sample illustrates how to implement [Targeted In-Meeting Notification](https://learn.microsoft.com/en-us/microsoftteams/platform/apps-in-teams-meetings/meeting-apps-apis?branch=pr-en-us-7615&tabs=dotnet#targeted-meeting-notification-api) In-Meeting Experience.
This sample illustrates how to implement [In-Meeting Notification](https://learn.microsoft.com/en-us/microsoftteams/platform/apps-in-teams-meetings/meeting-apps-apis?branch=pr-en-us-7615&tabs=dotnet#send-an-in-meeting-notification) and [Targeted In-Meeting Notification](https://learn.microsoft.com/microsoftteams/platform/apps-in-teams-meetings/meeting-apps-apis?branch=pr-en-us-7615&tabs=dotnet#targeted-meeting-notification-api) for scheduled meetings.

## Included Features
* Bots
* In-Meeting Notifications
* Targeted In-Meeting Notifications
* Adaptive Cards
* RSC Permissions

## Interaction with app

![In-Meeting Notification](InMeetingNotifications/Images/MeetingNotification.gif)
![Meetings Notification](InMeetingNotifications/Images/MeetingNotification.gif)

## 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](https://docs.microsoft.com/microsoftteams/platform/concepts/build-and-test/prepare-your-o365-tenant#enable-custom-teams-apps-and-turn-on-custom-app-uploading)).

**Meetings Content Bubble:** [Manifest](/samples/meetings-notification/csharp/demo-manifest/meetings-notification.zip)
**Meetings Notification:** [Manifest](/samples/meetings-notification/csharp/demo-manifest/meetings-notification.zip)

## Prerequisites

Expand Down Expand Up @@ -85,14 +86,14 @@ Please find below demo manifest which is deployed on Microsoft Azure and you can
- Go to your project directory, the ./Manifest folder, select the zip folder, and choose Open.
- Select Add in the pop-up dialog box. Your app is uploaded to Teams.
**Note**: If you are facing any issue in your app, please uncomment [this](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/meetings-content-bubble/csharp/ContentBubble/AdapterWithErrorHandler.cs#L26) line and put your debugger for local debug.
**Note**: If you are facing any issue in your app, please uncomment [this](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/meetings-notification/csharp/InMeetingNotifications/AdapterWithErrorHandler.cs#L26) line and put your debugger for local debug.
## Interacting with the app in Teams Meeting
Message the Bot by @ mentioning to interact with the content bubble.
Message the Bot by @ mentioning to interact with meetings notifications.
1. You will see agenda items listed in an Adaptive Card.
1. Select any option and click on Push Agenda button
1. You can submit your feedback on either Content Bubble/Adaptive card sent in chat.
1. You can submit your feedback on either In-meeting notification/Adaptive card sent in chat.
## Running the sample
Expand All @@ -119,6 +120,5 @@ Type `SendTargetedNotification` in bot chat to send Targeted Meeting notificatio
## Further Reading
- [Meeting apps APIs](https://learn.microsoft.com/microsoftteams/platform/apps-in-teams-meetings/meeting-apps-apis?tabs=dotnet)
- [Meeting content bubble](https://learn.microsoft.com/microsoftteams/platform/sbs-meeting-content-bubble)
- [Build tabs for meeting](https://learn.microsoft.com/microsoftteams/platform/apps-in-teams-meetings/build-tabs-for-meeting?tabs=desktop)
- [Build in-meeting notification for Teams meeting](https://learn.microsoft.com/microsoftteams/platform/apps-in-teams-meetings/in-meeting-notification-for-meeting)

0 comments on commit 4be0ed9

Please sign in to comment.