From 551bdc88adb2e6bbc4cc4ffea4760c3f78fc3831 Mon Sep 17 00:00:00 2001 From: Pawan Koshti Date: Mon, 30 Dec 2024 12:01:59 +0530 Subject: [PATCH 1/7] Fixed the samples --- .../src/dialogs/RootDialog.cs | 2 +- samples/bot-tag-mention/csharp/README.md | 24 +- samples/bot-tag-mention/nodejs/README.md | 7 + .../Helpers/ChatMessageHelper.cs | 257 +++++++++++------- .../Views/Shared/TeamNotification.cshtml | 25 +- .../csharp/TeamsApp/appPackage/manifest.json | 8 +- .../nodejs/dialogs/mainDialog.js | 28 +- .../graph-change-notification/nodejs/index.js | 12 +- .../RSCDemo/Controllers/HomeController.cs | 2 +- ...eamsMessagingExtensionsActionPreviewBot.js | 9 +- .../Controllers/HomeController.cs | 2 +- 11 files changed, 249 insertions(+), 127 deletions(-) diff --git a/samples/app-complete-sample/csharp/AppCompleteSample/src/dialogs/RootDialog.cs b/samples/app-complete-sample/csharp/AppCompleteSample/src/dialogs/RootDialog.cs index 12a177c019..b562ca91e2 100644 --- a/samples/app-complete-sample/csharp/AppCompleteSample/src/dialogs/RootDialog.cs +++ b/samples/app-complete-sample/csharp/AppCompleteSample/src/dialogs/RootDialog.cs @@ -104,7 +104,7 @@ await stepContext.BeginDialogAsync( else if (command == DialogMatches.MultiDialog2Match) { return await stepContext.BeginDialogAsync( - nameof(MultiDialog2)); + nameof(ThumbnailcardDialog)); } else if (command == DialogMatches.FecthLastExecutedDialogMatch) { diff --git a/samples/bot-tag-mention/csharp/README.md b/samples/bot-tag-mention/csharp/README.md index 0e7e5d7a8f..141c25aae1 100644 --- a/samples/bot-tag-mention/csharp/README.md +++ b/samples/bot-tag-mention/csharp/README.md @@ -39,14 +39,14 @@ This sample app demonstrates the use of tag mention funtionality in teams scope 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. +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. @@ -172,6 +172,14 @@ You can interact with this bot in Teams by sending it a message, or selecting a **Team channel Scope** +**Create tags within the team channel** +To create tags in Microsoft Teams, follow these steps: + +1. Select Teams on the left side of the app and choose the team you want to create tags for. +2. Click the "More options" button (three dots) next to the team name and select "Manage tags". +3. Click "Create tag" and provide a name, description, and assign team members to the tag . + + 1. **Show Welcome** - **Result:** The bot will send the welcome card for you to interact with necessary commands - **Valid Scopes:** team chat diff --git a/samples/bot-tag-mention/nodejs/README.md b/samples/bot-tag-mention/nodejs/README.md index c2fd271bc6..096dd627e8 100644 --- a/samples/bot-tag-mention/nodejs/README.md +++ b/samples/bot-tag-mention/nodejs/README.md @@ -166,6 +166,13 @@ You can interact with this bot in Teams by sending it a message, or selecting a **Team channel Scope** +**Create tags within the team channel** +To create tags in Microsoft Teams, follow these steps: + +1. Select Teams on the left side of the app and choose the team you want to create tags for. +2. Click the "More options" button (three dots) next to the team name and select "Manage tags". +3. Click "Create tag" and provide a name, description, and assign team members to the tag . + 1. **Show Welcome** - **Result:** The bot will send the welcome card for you to interact with necessary commands - **Valid Scopes:** team chat diff --git a/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs index 54e258a2c5..422c7b919c 100644 --- a/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs +++ b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs @@ -38,16 +38,34 @@ public async Task CreateChatMessageForChannel(TaskDetails taskDetai chatMessage.HostedContents = chatMessageHostedContentsCollectionPage; try { - var channelMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[taskDetails.channelId].Messages - .Request() - .AddAsync(chatMessage); - return channelMessage; + // First, get the list of channels to find the default channel ID + var channels = await graphClientChat.Teams[taskDetails.teamId].Channels + .Request() + .GetAsync(); + + // Assuming "General" is the name of the default channel + var defaultChannel = channels.CurrentPage.FirstOrDefault(c => c.DisplayName.Equals("General", StringComparison.OrdinalIgnoreCase)); + + if (defaultChannel != null) + { + // Add the message to the default channel + var createdMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[defaultChannel.Id].Messages + .Request() + .AddAsync(chatMessage); + + // Return the created message + return createdMessage; // + + } } - catch(Exception e) + catch (ServiceException ex) { - Console.WriteLine(e); + Console.WriteLine($"Error adding message: {ex.Message}"); + // You might want to handle the error further here or return null + } return null; + } public async Task CreateChannelMessageAdaptiveCard(TaskDetails taskDetails, string accessToken) @@ -56,103 +74,124 @@ public async Task CreateChannelMessageAdaptiveCard(TaskDetails task var Card = new AdaptiveCard(new AdaptiveSchemaVersion("1.0")) { Body = new List() - { - new AdaptiveTextBlock() - { - Text="Here is Your Reservation Details:", - Weight = AdaptiveTextWeight.Bolder, - Size = AdaptiveTextSize.Large, - Id="taskDetails" - }, - new AdaptiveTextBlock() - { - Text=taskDetails.reservationId, - Weight = AdaptiveTextWeight.Lighter, - Size = AdaptiveTextSize.Medium, - Id="taskTitle" - }, - new AdaptiveTextBlock() - { - Text=taskDetails.DeployementTitle, - Weight = AdaptiveTextWeight.Lighter, - Size = AdaptiveTextSize.Medium, - Id="taskdesc" - }, - new AdaptiveTextBlock() - { - Text=taskDetails.currentSlot, - Weight = AdaptiveTextWeight.Lighter, - Size = AdaptiveTextSize.Medium, - Id="taskslot" - } - } - + { + new AdaptiveTextBlock() + { + Text = "Here is Your Reservation Details:", + Weight = AdaptiveTextWeight.Bolder, + Size = AdaptiveTextSize.Large, + Id = "taskDetails" + }, + new AdaptiveTextBlock() + { + Text = taskDetails.reservationId, + Weight = AdaptiveTextWeight.Lighter, + Size = AdaptiveTextSize.Medium, + Id = "taskTitle" + }, + new AdaptiveTextBlock() + { + Text = taskDetails.DeployementTitle, + Weight = AdaptiveTextWeight.Lighter, + Size = AdaptiveTextSize.Medium, + Id = "taskdesc" + }, + new AdaptiveTextBlock() + { + Text = taskDetails.currentSlot, + Weight = AdaptiveTextWeight.Lighter, + Size = AdaptiveTextSize.Medium, + Id = "taskslot" + } + } }; - var chatMessage = new ChatMessage { - Subject = "Reservation Activtity:", + Subject = "Reservation Activity:", Body = new ItemBody { ContentType = BodyType.Html, Content = "" }, - Attachments = new List() - { - new ChatMessageAttachment - { - Id = "74d20c7f34aa4a7fb74e2b30004247c5", - ContentType = "application/vnd.microsoft.card.adaptive", - ContentUrl = null, - Content = JsonConvert.SerializeObject(Card), - Name = null, - ThumbnailUrl = null - } - } + Attachments = new List + { + new ChatMessageAttachment + { + Id = "74d20c7f34aa4a7fb74e2b30004247c5", + ContentType = "application/vnd.microsoft.card.adaptive", + ContentUrl = null, + Content = JsonConvert.SerializeObject(Card), + Name = null, + ThumbnailUrl = null + } + } }; chatMessage.HostedContents = chatMessageHostedContentsCollectionPage; - var getChannelMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[taskDetails.channelId].Messages + try + { + // First, get the list of channels to find the default channel ID + var channels = await graphClientChat.Teams[taskDetails.teamId].Channels .Request() - .AddAsync(chatMessage); - return getChannelMessage; + .GetAsync(); + + // Assuming "General" is the name of the default channel + var defaultChannel = channels.CurrentPage.FirstOrDefault(c => c.DisplayName.Equals("General", StringComparison.OrdinalIgnoreCase)); + + if (defaultChannel != null) + { + // Add the message to the default channel + var createdMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[defaultChannel.Id].Messages + .Request() + .AddAsync(chatMessage); + + // Return the created message + return createdMessage; // + + } + } + catch (ServiceException ex) + { + Console.WriteLine($"Error adding message: {ex.Message}"); + // You might want to handle the error further here or return null + } + return null; + } - public async Task CreatePendingFinanceRequestCard(TaskDetails taskDetails, string accessToken) + public async Task CreatePendingFinanceRequestCard(TaskDetails taskDetails, string accessToken) { - GraphServiceClient graphClientChat= SimpleGraphClient.GetGraphClient(accessToken); + GraphServiceClient graphClientChat = SimpleGraphClient.GetGraphClient(accessToken); var Card = new AdaptiveCard(new AdaptiveSchemaVersion("1.0")) { Body = new List() - { - new AdaptiveTextBlock() - { - Text="Here is Your Task Details in Teams", - Weight = AdaptiveTextWeight.Bolder, - Size = AdaptiveTextSize.Large, - Id="taskDetails" - }, - new AdaptiveTextBlock() - { - Text=taskDetails.title, - Weight = AdaptiveTextWeight.Lighter, - Size = AdaptiveTextSize.Medium, - Id="taskTitle" - }, - new AdaptiveTextBlock() - { - Text=taskDetails.description, - Weight = AdaptiveTextWeight.Lighter, - Size = AdaptiveTextSize.Medium, - Id="taskdesc" - }, - } - + { + new AdaptiveTextBlock() + { + Text = "Here is Your Task Details in Teams", + Weight = AdaptiveTextWeight.Bolder, + Size = AdaptiveTextSize.Large, + Id = "taskDetails" + }, + new AdaptiveTextBlock() + { + Text = taskDetails.title, + Weight = AdaptiveTextWeight.Lighter, + Size = AdaptiveTextSize.Medium, + Id = "taskTitle" + }, + new AdaptiveTextBlock() + { + Text = taskDetails.description, + Weight = AdaptiveTextWeight.Lighter, + Size = AdaptiveTextSize.Medium, + Id = "taskdesc" + }, + } }; - var chatMessage = new ChatMessage { Subject = null, @@ -162,26 +201,54 @@ public async Task CreatePendingFinanceRequestCard(TaskDetails task Content = "" }, Attachments = new List() - { - new ChatMessageAttachment - { - Id = "74d20c7f34aa4a7fb74e2b30004247c5", - ContentType = "application/vnd.microsoft.card.adaptive", - ContentUrl = null, - Content = JsonConvert.SerializeObject(Card), - Name = null, - ThumbnailUrl = null - } - } + { + new ChatMessageAttachment + { + Id = "74d20c7f34aa4a7fb74e2b30004247c5", + ContentType = "application/vnd.microsoft.card.adaptive", + ContentUrl = null, + Content = JsonConvert.SerializeObject(Card), + Name = null, + ThumbnailUrl = null + } + } }; chatMessage.HostedContents = chatMessageHostedContentsCollectionPage; - var getChannelMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[taskDetails.channelId].Messages + + try + { + // First, get the list of channels to find the default channel ID + var channels = await graphClientChat.Teams[taskDetails.teamId].Channels .Request() - .AddAsync(chatMessage); - return getChannelMessage; + .GetAsync(); + + // Assuming "General" is the name of the default channel + var defaultChannel = channels.CurrentPage.FirstOrDefault(c => c.DisplayName.Equals("General", StringComparison.OrdinalIgnoreCase)); + + if (defaultChannel != null) + { + // Add the message to the default channel + var createdMessage = await graphClientChat.Teams[taskDetails.teamId].Channels[defaultChannel.Id].Messages + .Request() + .AddAsync(chatMessage); + + // Return the created message + return createdMessage; // + + } + } + catch (ServiceException ex) + { + Console.WriteLine($"Error adding message: {ex.Message}"); + // You might want to handle the error further here or return null + + } + return null; + //return null; // Ensure a return value is provided here } + public async Task CreateGroupChatMessage(TaskDetails taskDetails, string accessToken) { var graphClientChat = SimpleGraphClient.GetGraphClient(accessToken); diff --git a/samples/graph-activity-feed/csharp/ActivityFeedNotification/Views/Shared/TeamNotification.cshtml b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Views/Shared/TeamNotification.cshtml index 99a819d3b5..f062a74e9c 100644 --- a/samples/graph-activity-feed/csharp/ActivityFeedNotification/Views/Shared/TeamNotification.cshtml +++ b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Views/Shared/TeamNotification.cshtml @@ -85,7 +85,7 @@ teamId = context.team.groupId; }); - var encodedWebUrl = encodeURI(window.location.origin + var encodedWebUrl = encodeURI(window.location.origin); var encodedContext = encodeURI('{"subEntityId": "task456"}'); var taskItemUrl = 'https://teams.microsoft.com/l/entity//tasklist123?webUrl=' + encodedWebUrl + '&context=' + encodedContext; var empty = true; @@ -104,8 +104,10 @@ microsoftTeams.app.getContext().then((context) => { id = context.team.groupId; - + + console.log(context); let taskDetails = { + title: $('#title').val(), description: $('#description').val(), userName: username, @@ -131,7 +133,12 @@ function customTopicTeamNotification() { var action = "customTopic"; + var id = ""; + + microsoftTeams.app.getContext().then((context) => { + id = context.team.groupId; + let taskDetails = { DeployementTitle: $('#DeployementTitle').val(), DeploymentDescription: $('#DeploymentDescription').val(), @@ -140,7 +147,7 @@ channelId: teamchannelID, access_token: token, taskItemLink: taskItemUrl, - teamId: teamId + teamId: id }; $.ajax({ @@ -149,7 +156,7 @@ dataType: 'json', data: taskDetails }); - + }); return true; }; @@ -175,9 +182,11 @@ }; function channelTabTeamNotification() { - + var action = "channelTab"; - + var id = ""; + microsoftTeams.app.getContext().then((context) => { + id = context.team.groupId; let taskDetails = { reservationId: $("#reservationId").val(), DeployementTitle: $('#reservationTitle').val(), @@ -187,7 +196,7 @@ channelId: teamchannelID, access_token: token, taskItemLink: taskItemUrl, - teamId: teamId + teamId: id }; @@ -197,7 +206,7 @@ dataType: 'json', data: taskDetails }); - + }); return true; }; diff --git a/samples/graph-appcatalog-lifecycle/csharp/TeamsApp/appPackage/manifest.json b/samples/graph-appcatalog-lifecycle/csharp/TeamsApp/appPackage/manifest.json index 7c766180c7..f704640007 100644 --- a/samples/graph-appcatalog-lifecycle/csharp/TeamsApp/appPackage/manifest.json +++ b/samples/graph-appcatalog-lifecycle/csharp/TeamsApp/appPackage/manifest.json @@ -3,7 +3,7 @@ "manifestVersion": "1.19", "version": "1.0.0", "id": "${{TEAMS_APP_ID}}", - "developer": { + "developer": { "name": "Microsoft", "websiteUrl": "https://www.techmahindra.com/", "privacyUrl": "https://www.techmahindra.com/privacy", @@ -39,5 +39,9 @@ "validDomains": [ "token.botframework.com", "${{BOT_DOMAIN}}" - ] + ], + "webApplicationInfo": { + "id": "${{AAD_APP_CLIENT_ID}}", + "resource": "api://botid-${{AAD_APP_CLIENT_ID}}" + } } \ No newline at end of file diff --git a/samples/graph-change-notification/nodejs/dialogs/mainDialog.js b/samples/graph-change-notification/nodejs/dialogs/mainDialog.js index e9442c0084..f40980e781 100644 --- a/samples/graph-change-notification/nodejs/dialogs/mainDialog.js +++ b/samples/graph-change-notification/nodejs/dialogs/mainDialog.js @@ -10,11 +10,11 @@ const MAIN_WATERFALL_DIALOG = 'MainWaterfallDialog'; const OAUTH_PROMPT = 'OAuthPrompt'; const { SubscriptionManagementService } = require('../Helper/SubscriptionManager'); const { subscriptionConfiguration } = require('../constant'); +const { Client } = require('@microsoft/microsoft-graph-client'); class MainDialog extends LogoutDialog { constructor() { - super(MAIN_DIALOG, process.env.connectionName); - + super(MAIN_DIALOG, process.env.connectionName); this.addDialog(new OAuthPrompt(OAUTH_PROMPT, { connectionName: process.env.connectionName, text: 'Please Sign In', @@ -27,7 +27,6 @@ class MainDialog extends LogoutDialog { this.promptStep.bind(this), this.loginStep.bind(this) ])); - this.initialDialogId = MAIN_WATERFALL_DIALOG; } @@ -55,6 +54,7 @@ class MainDialog extends LogoutDialog { // Get the token from the previous step. Note that we could also have gotten the // token directly from the prompt itself. There is an example of this in the next method. const tokenResponse = stepContext.result; + this.accessToken = tokenResponse.token; if (tokenResponse) { const subscriptionManager = new SubscriptionManagementService(tokenResponse.token); //subscribe user presence @@ -64,6 +64,28 @@ class MainDialog extends LogoutDialog { await stepContext.context.sendActivity('Login was not successful please try again.'); return await stepContext.endDialog(); } + + getGraphClient() { + const client = Client.init({ + authProvider: (done) => { + done(null, this.accessToken); + } + }); + return client; + } + + async getUserState(userStateURL) { + try { + let userState = null; + const client = this.getGraphClient(); + userState = await client.api(userStateURL).get(); //get user state + + return userState; + } + catch (e) { + console.log("Error--" + e); + } + } } module.exports.MainDialog = MainDialog; diff --git a/samples/graph-change-notification/nodejs/index.js b/samples/graph-change-notification/nodejs/index.js index 96433f4dd2..153db53e8b 100644 --- a/samples/graph-change-notification/nodejs/index.js +++ b/samples/graph-change-notification/nodejs/index.js @@ -93,9 +93,10 @@ const notification = async (req, res, next) => { console.log("In Response"); clientStatesValid = false; console.log(req.body.value[0].resourceData); - let userstatus = req.body.value[0].resourceData; - console.log(userstatus.activity); - console.log(userstatus.availability); + + // Call the API + const userstatus = await dialog.getUserState("communications/presences/" + req.body.value[0].resourceData.id); + status = 202; //for storing step context const dbot = new DialogBot(conversationState, userState, dialog, conversationReferences); @@ -110,8 +111,5 @@ const notification = async (req, res, next) => { } } - // Listen for incoming requests. -server.post('/api/notifications', notification); - - +server.post('/api/notifications', notification); \ No newline at end of file diff --git a/samples/graph-rsc/csharp/RSCDemo/Controllers/HomeController.cs b/samples/graph-rsc/csharp/RSCDemo/Controllers/HomeController.cs index a68cb6d401..e49a57a9fd 100644 --- a/samples/graph-rsc/csharp/RSCDemo/Controllers/HomeController.cs +++ b/samples/graph-rsc/csharp/RSCDemo/Controllers/HomeController.cs @@ -141,7 +141,7 @@ public async Task GetInstalledAppList(string reciepientUserId) foreach(AppData element in installedAppList) { - if (element.TeamsAppDefinition.DisplayName == "RSC feed") + if (element.TeamsAppDefinition.DisplayName == "RSC-GraphAPI ") { appId = element.Id; } diff --git a/samples/msgext-action-preview/nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js b/samples/msgext-action-preview/nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js index e213c2d2d6..2e77c72973 100644 --- a/samples/msgext-action-preview/nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js +++ b/samples/msgext-action-preview/nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js @@ -70,7 +70,14 @@ class TeamsMessagingExtensionsActionPreviewBot extends TeamsActivityHandler { } }; } - await context.sendActivity(responseActivity); + return { + composeExtension: { + type: 'result', + attachmentLayout: 'list', + attachments: [adaptiveCard] + } + }; + // await context.sendActivity(responseActivity); } async handleTeamsMessagingExtensionCardButtonClicked(context, obj) { diff --git a/samples/tab-request-approval/csharp/TabRequestApproval/Controllers/HomeController.cs b/samples/tab-request-approval/csharp/TabRequestApproval/Controllers/HomeController.cs index 2d5e6e799d..f38f76243d 100644 --- a/samples/tab-request-approval/csharp/TabRequestApproval/Controllers/HomeController.cs +++ b/samples/tab-request-approval/csharp/TabRequestApproval/Controllers/HomeController.cs @@ -138,7 +138,7 @@ public async Task SendNotificationToManager(RequestInfo taskInfo) { Source = TeamworkActivityTopicSource.Text, Value = $"{taskInfo.title}", - WebUrl = "https://teams.microsoft.com/l/entity/" + _configuration["AzureAd:MicrosoftAppId"] + "/request?context={\"subEntityId\":\"" + taskInfo.taskId + "\"}" + WebUrl = "https://teams.microsoft.com/l/entity/" + installationId.ToList()[0] + "/request?context={\"subEntityId\":\"" + taskInfo.taskId + "\"}" }, ActivityType = "approvalRequired", PreviewText = new ItemBody From e54cd347963a8cd69b50eeb7ee7d4c424852389e Mon Sep 17 00:00:00 2001 From: Pawan Koshti Date: Mon, 30 Dec 2024 16:41:18 +0530 Subject: [PATCH 2/7] Fixed Copilot feedbacks --- samples/bot-tag-mention/nodejs/README.md | 2 +- .../ActivityFeedNotification/Helpers/ChatMessageHelper.cs | 2 +- samples/graph-change-notification/nodejs/dialogs/mainDialog.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/bot-tag-mention/nodejs/README.md b/samples/bot-tag-mention/nodejs/README.md index 096dd627e8..5edefda33b 100644 --- a/samples/bot-tag-mention/nodejs/README.md +++ b/samples/bot-tag-mention/nodejs/README.md @@ -171,7 +171,7 @@ To create tags in Microsoft Teams, follow these steps: 1. Select Teams on the left side of the app and choose the team you want to create tags for. 2. Click the "More options" button (three dots) next to the team name and select "Manage tags". -3. Click "Create tag" and provide a name, description, and assign team members to the tag . +3. Click "Create tag" and provide a name, description, and assign team members to the tag. 1. **Show Welcome** - **Result:** The bot will send the welcome card for you to interact with necessary commands diff --git a/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs index 422c7b919c..a5e857273f 100644 --- a/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs +++ b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs @@ -54,7 +54,7 @@ public async Task CreateChatMessageForChannel(TaskDetails taskDetai .AddAsync(chatMessage); // Return the created message - return createdMessage; // + return createdMessage; } } diff --git a/samples/graph-change-notification/nodejs/dialogs/mainDialog.js b/samples/graph-change-notification/nodejs/dialogs/mainDialog.js index f40980e781..2bb16cfb80 100644 --- a/samples/graph-change-notification/nodejs/dialogs/mainDialog.js +++ b/samples/graph-change-notification/nodejs/dialogs/mainDialog.js @@ -83,7 +83,7 @@ class MainDialog extends LogoutDialog { return userState; } catch (e) { - console.log("Error--" + e); + console.log(`Error fetching user state: ${e.message}`); } } } From 5e7332544789ca985a5d1aac30f7883f26bb916d Mon Sep 17 00:00:00 2001 From: Jegadeesh-MSFT <140516784+Jegadeesh-MSFT@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:32:16 +0530 Subject: [PATCH 3/7] Remove unnecessary comments and whitespace --- .../Helpers/ChatMessageHelper.cs | 168 ++++++++---------- 1 file changed, 78 insertions(+), 90 deletions(-) diff --git a/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs index a5e857273f..0ce3bb2330 100644 --- a/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs +++ b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Helpers/ChatMessageHelper.cs @@ -1,4 +1,4 @@ -using AdaptiveCards; +using AdaptiveCards; using Microsoft.Extensions.Configuration; using Microsoft.Graph; using Microsoft.Graph.Auth; @@ -55,17 +55,13 @@ public async Task CreateChatMessageForChannel(TaskDetails taskDetai // Return the created message return createdMessage; - } } catch (ServiceException ex) { Console.WriteLine($"Error adding message: {ex.Message}"); - // You might want to handle the error further here or return null - } return null; - } public async Task CreateChannelMessageAdaptiveCard(TaskDetails taskDetails, string accessToken) @@ -74,36 +70,36 @@ public async Task CreateChannelMessageAdaptiveCard(TaskDetails task var Card = new AdaptiveCard(new AdaptiveSchemaVersion("1.0")) { Body = new List() - { - new AdaptiveTextBlock() - { - Text = "Here is Your Reservation Details:", - Weight = AdaptiveTextWeight.Bolder, - Size = AdaptiveTextSize.Large, - Id = "taskDetails" - }, - new AdaptiveTextBlock() - { - Text = taskDetails.reservationId, - Weight = AdaptiveTextWeight.Lighter, - Size = AdaptiveTextSize.Medium, - Id = "taskTitle" - }, - new AdaptiveTextBlock() - { - Text = taskDetails.DeployementTitle, - Weight = AdaptiveTextWeight.Lighter, - Size = AdaptiveTextSize.Medium, - Id = "taskdesc" - }, - new AdaptiveTextBlock() - { - Text = taskDetails.currentSlot, - Weight = AdaptiveTextWeight.Lighter, - Size = AdaptiveTextSize.Medium, - Id = "taskslot" - } - } + { + new AdaptiveTextBlock() + { + Text = "Here is Your Reservation Details:", + Weight = AdaptiveTextWeight.Bolder, + Size = AdaptiveTextSize.Large, + Id = "taskDetails" + }, + new AdaptiveTextBlock() + { + Text = taskDetails.reservationId, + Weight = AdaptiveTextWeight.Lighter, + Size = AdaptiveTextSize.Medium, + Id = "taskTitle" + }, + new AdaptiveTextBlock() + { + Text = taskDetails.DeployementTitle, + Weight = AdaptiveTextWeight.Lighter, + Size = AdaptiveTextSize.Medium, + Id = "taskdesc" + }, + new AdaptiveTextBlock() + { + Text = taskDetails.currentSlot, + Weight = AdaptiveTextWeight.Lighter, + Size = AdaptiveTextSize.Medium, + Id = "taskslot" + } + } }; var chatMessage = new ChatMessage @@ -115,17 +111,17 @@ public async Task CreateChannelMessageAdaptiveCard(TaskDetails task Content = "" }, Attachments = new List - { - new ChatMessageAttachment - { - Id = "74d20c7f34aa4a7fb74e2b30004247c5", - ContentType = "application/vnd.microsoft.card.adaptive", - ContentUrl = null, - Content = JsonConvert.SerializeObject(Card), - Name = null, - ThumbnailUrl = null - } - } + { + new ChatMessageAttachment + { + Id = "74d20c7f34aa4a7fb74e2b30004247c5", + ContentType = "application/vnd.microsoft.card.adaptive", + ContentUrl = null, + Content = JsonConvert.SerializeObject(Card), + Name = null, + ThumbnailUrl = null + } + } }; chatMessage.HostedContents = chatMessageHostedContentsCollectionPage; @@ -147,18 +143,14 @@ public async Task CreateChannelMessageAdaptiveCard(TaskDetails task .AddAsync(chatMessage); // Return the created message - return createdMessage; // - + return createdMessage; } } catch (ServiceException ex) { Console.WriteLine($"Error adding message: {ex.Message}"); - // You might want to handle the error further here or return null - } return null; - } public async Task CreatePendingFinanceRequestCard(TaskDetails taskDetails, string accessToken) @@ -167,29 +159,29 @@ public async Task CreatePendingFinanceRequestCard(TaskDetails taskD var Card = new AdaptiveCard(new AdaptiveSchemaVersion("1.0")) { Body = new List() - { - new AdaptiveTextBlock() - { - Text = "Here is Your Task Details in Teams", - Weight = AdaptiveTextWeight.Bolder, - Size = AdaptiveTextSize.Large, - Id = "taskDetails" - }, - new AdaptiveTextBlock() - { - Text = taskDetails.title, - Weight = AdaptiveTextWeight.Lighter, - Size = AdaptiveTextSize.Medium, - Id = "taskTitle" - }, - new AdaptiveTextBlock() - { - Text = taskDetails.description, - Weight = AdaptiveTextWeight.Lighter, - Size = AdaptiveTextSize.Medium, - Id = "taskdesc" - }, - } + { + new AdaptiveTextBlock() + { + Text = "Here is Your Task Details in Teams", + Weight = AdaptiveTextWeight.Bolder, + Size = AdaptiveTextSize.Large, + Id = "taskDetails" + }, + new AdaptiveTextBlock() + { + Text = taskDetails.title, + Weight = AdaptiveTextWeight.Lighter, + Size = AdaptiveTextSize.Medium, + Id = "taskTitle" + }, + new AdaptiveTextBlock() + { + Text = taskDetails.description, + Weight = AdaptiveTextWeight.Lighter, + Size = AdaptiveTextSize.Medium, + Id = "taskdesc" + }, + } }; var chatMessage = new ChatMessage @@ -201,17 +193,17 @@ public async Task CreatePendingFinanceRequestCard(TaskDetails taskD Content = "" }, Attachments = new List() - { - new ChatMessageAttachment - { - Id = "74d20c7f34aa4a7fb74e2b30004247c5", - ContentType = "application/vnd.microsoft.card.adaptive", - ContentUrl = null, - Content = JsonConvert.SerializeObject(Card), - Name = null, - ThumbnailUrl = null - } - } + { + new ChatMessageAttachment + { + Id = "74d20c7f34aa4a7fb74e2b30004247c5", + ContentType = "application/vnd.microsoft.card.adaptive", + ContentUrl = null, + Content = JsonConvert.SerializeObject(Card), + Name = null, + ThumbnailUrl = null + } + } }; chatMessage.HostedContents = chatMessageHostedContentsCollectionPage; @@ -234,18 +226,14 @@ public async Task CreatePendingFinanceRequestCard(TaskDetails taskD .AddAsync(chatMessage); // Return the created message - return createdMessage; // - + return createdMessage; } } catch (ServiceException ex) { Console.WriteLine($"Error adding message: {ex.Message}"); - // You might want to handle the error further here or return null - } return null; - //return null; // Ensure a return value is provided here } From b84b93e2417422ffb36904fedb9a4bea517a0434 Mon Sep 17 00:00:00 2001 From: Jegadeesh-MSFT <140516784+Jegadeesh-MSFT@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:08:01 +0530 Subject: [PATCH 4/7] Remove unnecessary whitespace and console log --- .../Views/Shared/TeamNotification.cshtml | 68 ++++++++----------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/samples/graph-activity-feed/csharp/ActivityFeedNotification/Views/Shared/TeamNotification.cshtml b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Views/Shared/TeamNotification.cshtml index f062a74e9c..18cb651fdc 100644 --- a/samples/graph-activity-feed/csharp/ActivityFeedNotification/Views/Shared/TeamNotification.cshtml +++ b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Views/Shared/TeamNotification.cshtml @@ -1,4 +1,4 @@ -@model TabActivityFeed.Model.TaskDetails +@model TabActivityFeed.Model.TaskDetails @{ Layout = "~/Views/Shared/_Layout.cshtml"; } @@ -99,15 +99,10 @@ function SendNotificationToChannel() { var action = "EntityTopic"; - var id = ""; - microsoftTeams.app.getContext().then((context) => { id = context.team.groupId; - - console.log(context); let taskDetails = { - title: $('#title').val(), description: $('#description').val(), userName: username, @@ -124,45 +119,38 @@ dataType: 'json', data: taskDetails }); - }); - return true; }; function customTopicTeamNotification() { - var action = "customTopic"; var id = ""; microsoftTeams.app.getContext().then((context) => { - id = context.team.groupId; - - let taskDetails = { - DeployementTitle: $('#DeployementTitle').val(), - DeploymentDescription: $('#DeploymentDescription').val(), - taskInfoAction: action, - userName: username, - channelId: teamchannelID, - access_token: token, - taskItemLink: taskItemUrl, - teamId: id - }; + let taskDetails = { + DeployementTitle: $('#DeployementTitle').val(), + DeploymentDescription: $('#DeploymentDescription').val(), + taskInfoAction: action, + userName: username, + channelId: teamchannelID, + access_token: token, + taskItemLink: taskItemUrl, + teamId: id + }; - $.ajax({ - type: 'POST', - url: '/sendNotificationToTeam', - dataType: 'json', - data: taskDetails - }); + $.ajax({ + type: 'POST', + url: '/sendNotificationToTeam', + dataType: 'json', + data: taskDetails + }); }); return true; }; - function SendDefaultNotification() { - alert("hello"); let taskDetails = { userName: username, channelId: teamchannelID, @@ -182,12 +170,13 @@ }; function channelTabTeamNotification() { - var action = "channelTab"; var id = ""; - microsoftTeams.app.getContext().then((context) => { + + microsoftTeams.app.getContext().then((context) => { id = context.team.groupId; - let taskDetails = { + + let taskDetails = { reservationId: $("#reservationId").val(), DeployementTitle: $('#reservationTitle').val(), currentSlot: $('#currentSlot').val(), @@ -197,15 +186,14 @@ access_token: token, taskItemLink: taskItemUrl, teamId: id + }; - }; - - $.ajax({ - type: 'POST', - url: '/sendNotificationToTeam', - dataType: 'json', - data: taskDetails - }); + $.ajax({ + type: 'POST', + url: '/sendNotificationToTeam', + dataType: 'json', + data: taskDetails + }); }); return true; }; From cfae15c6b51634816bc257fc47cb40f7491aba37 Mon Sep 17 00:00:00 2001 From: Jegadeesh-MSFT <140516784+Jegadeesh-MSFT@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:12:34 +0530 Subject: [PATCH 5/7] Fix indentation in manifest.json file --- .../csharp/TeamsApp/appPackage/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/graph-appcatalog-lifecycle/csharp/TeamsApp/appPackage/manifest.json b/samples/graph-appcatalog-lifecycle/csharp/TeamsApp/appPackage/manifest.json index f704640007..62b220abd5 100644 --- a/samples/graph-appcatalog-lifecycle/csharp/TeamsApp/appPackage/manifest.json +++ b/samples/graph-appcatalog-lifecycle/csharp/TeamsApp/appPackage/manifest.json @@ -3,7 +3,7 @@ "manifestVersion": "1.19", "version": "1.0.0", "id": "${{TEAMS_APP_ID}}", - "developer": { + "developer": { "name": "Microsoft", "websiteUrl": "https://www.techmahindra.com/", "privacyUrl": "https://www.techmahindra.com/privacy", From 120d4e2c28812db33a0324bf4e7055c75218b256 Mon Sep 17 00:00:00 2001 From: Jegadeesh-MSFT <140516784+Jegadeesh-MSFT@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:16:00 +0530 Subject: [PATCH 6/7] Remove unnecessary whitespace in index.js --- samples/graph-change-notification/nodejs/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/graph-change-notification/nodejs/index.js b/samples/graph-change-notification/nodejs/index.js index 153db53e8b..4d2581b2cc 100644 --- a/samples/graph-change-notification/nodejs/index.js +++ b/samples/graph-change-notification/nodejs/index.js @@ -96,7 +96,6 @@ const notification = async (req, res, next) => { // Call the API const userstatus = await dialog.getUserState("communications/presences/" + req.body.value[0].resourceData.id); - status = 202; //for storing step context const dbot = new DialogBot(conversationState, userState, dialog, conversationReferences); From 41a17bdd400152d7e8ceb2995c000675f3c22719 Mon Sep 17 00:00:00 2001 From: Jegadeesh-MSFT <140516784+Jegadeesh-MSFT@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:17:54 +0530 Subject: [PATCH 7/7] Remove commented-out sendActivity call --- .../nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/msgext-action-preview/nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js b/samples/msgext-action-preview/nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js index 2e77c72973..7e74a5d829 100644 --- a/samples/msgext-action-preview/nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js +++ b/samples/msgext-action-preview/nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js @@ -77,7 +77,6 @@ class TeamsMessagingExtensionsActionPreviewBot extends TeamsActivityHandler { attachments: [adaptiveCard] } }; - // await context.sendActivity(responseActivity); } async handleTeamsMessagingExtensionCardButtonClicked(context, obj) {