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..5edefda33b 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..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; @@ -38,14 +38,28 @@ 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}"); } return null; } @@ -56,103 +70,120 @@ 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}"); + } + 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 +193,50 @@ 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}"); + } + return null; } + 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..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"; } @@ -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; @@ -99,12 +99,9 @@ function SendNotificationToChannel() { var action = "EntityTopic"; - var id = ""; - microsoftTeams.app.getContext().then((context) => { id = context.team.groupId; - let taskDetails = { title: $('#title').val(), description: $('#description').val(), @@ -122,40 +119,38 @@ dataType: 'json', data: taskDetails }); - }); - return true; }; function customTopicTeamNotification() { - var action = "customTopic"; + var id = ""; - let taskDetails = { - DeployementTitle: $('#DeployementTitle').val(), - DeploymentDescription: $('#DeploymentDescription').val(), - taskInfoAction: action, - userName: username, - channelId: teamchannelID, - access_token: token, - taskItemLink: taskItemUrl, - teamId: teamId - }; + 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 + }; - $.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, @@ -175,10 +170,13 @@ }; function channelTabTeamNotification() { - var action = "channelTab"; + var id = ""; - let taskDetails = { + microsoftTeams.app.getContext().then((context) => { + id = context.team.groupId; + + let taskDetails = { reservationId: $("#reservationId").val(), DeployementTitle: $('#reservationTitle').val(), currentSlot: $('#currentSlot').val(), @@ -187,17 +185,16 @@ channelId: teamchannelID, access_token: token, taskItemLink: taskItemUrl, - teamId: teamId - - }; + teamId: id + }; - $.ajax({ - type: 'POST', - url: '/sendNotificationToTeam', - dataType: 'json', - data: taskDetails + $.ajax({ + type: 'POST', + url: '/sendNotificationToTeam', + 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..62b220abd5 100644 --- a/samples/graph-appcatalog-lifecycle/csharp/TeamsApp/appPackage/manifest.json +++ b/samples/graph-appcatalog-lifecycle/csharp/TeamsApp/appPackage/manifest.json @@ -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..2bb16cfb80 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 fetching user state: ${e.message}`); + } + } } module.exports.MainDialog = MainDialog; diff --git a/samples/graph-change-notification/nodejs/index.js b/samples/graph-change-notification/nodejs/index.js index 96433f4dd2..4d2581b2cc 100644 --- a/samples/graph-change-notification/nodejs/index.js +++ b/samples/graph-change-notification/nodejs/index.js @@ -93,9 +93,9 @@ 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 +110,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..7e74a5d829 100644 --- a/samples/msgext-action-preview/nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js +++ b/samples/msgext-action-preview/nodejs/bots/teamsMessagingExtensionsActionPreviewBot.js @@ -70,7 +70,13 @@ class TeamsMessagingExtensionsActionPreviewBot extends TeamsActivityHandler { } }; } - await context.sendActivity(responseActivity); + return { + composeExtension: { + type: 'result', + attachmentLayout: 'list', + attachments: [adaptiveCard] + } + }; } 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