public async Task CreateTab(string tenantId, string teamId, string channelId) { string token = await GetToken(tenantId); GraphServiceClient graphClient = GetAuthenticatedClient(token); var appsInstalled = await graphClient.Teams[teamId].InstalledApps.Request().Expand("teamsAppDefinition").GetAsync(); var teamsAppId = appsInstalled.Where(o => o.TeamsAppDefinition.DisplayName == "Channel Lifecycle").Select(o => o.TeamsAppDefinition.TeamsAppId).FirstOrDefault(); var teamsTab = new TeamsTab { DisplayName = "My Tab", Configuration = new TeamsTabConfiguration { EntityId = "2DCA2E6C7A10415CAF6B8AB66123125", ContentUrl = _configuration["BaseUri"] + "/TestTab", WebsiteUrl = _configuration["BaseUri"] + "/TestTab" }, AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/" + teamsAppId } } }; var result = await graphClient.Teams[teamId].Channels[channelId].Tabs .Request() .AddAsync(teamsTab); }
public async Task AddTab(string groupId, string channelId, string tabName, TeamsTabConfiguration configuration) { var tab = new TeamsTab { DisplayName = tabName, Configuration = configuration, AdditionalData = new Dictionary <string, object> { { "*****@*****.**", $"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{_appDefId}" } } }; await _client.Teams[groupId].Channels[channelId].Tabs.Request().AddAsync(tab); }
/// <summary> /// Update the navigation property tabs in me /// <param name="body"></param> /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param> /// </summary> public RequestInformation CreatePatchRequestInformation(TeamsTab body, Action <TeamsTabItemRequestBuilderPatchRequestConfiguration> requestConfiguration = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, UrlTemplate = UrlTemplate, PathParameters = PathParameters, }; requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); if (requestConfiguration != null) { var requestConfig = new TeamsTabItemRequestBuilderPatchRequestConfiguration(); requestConfiguration.Invoke(requestConfig); requestInfo.AddRequestOptions(requestConfig.Options); requestInfo.AddHeaders(requestConfig.Headers); } return(requestInfo); }
public static async Task AddTeamsChannelAndTab(string _id) { try { var channel = new Channel { DisplayName = "API Discussion", Description = "This channel is where we debate all API things", MembershipType = ChannelMembershipType.Standard }; var newChannel = await graphClient.Teams[_id].Channels.Request().AddAsync(channel); var apps = await graphClient.Teams[_id].InstalledApps.Request().Expand("TeamsApp").GetAsync(); var WebApp = apps.Where(x => x.TeamsApp.DisplayName == "Website").Select(y => y.TeamsApp).FirstOrDefault(); var tab = new TeamsTab { DisplayName = "My New Tab", TeamsApp = WebApp, Configuration = new TeamsTabConfiguration { ContentUrl = "https://github.com/microsoftgraph/microsoft-graph-docs/blob/main/api-reference/v1.0/overview.md", EntityId = "TotallyUniqueId", RemoveUrl = null, WebsiteUrl = null, ODataType = null }, AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", "https://graph.microsoft.com/beta/appCatalogs/teamsApps/com.microsoft.teamspace.tab.web" } } }; await graphClient.Teams[_id].Channels[newChannel.Id].Tabs.Request().AddAsync(tab); } catch (ServiceException ex) { Console.WriteLine($"Error adding Channel/Tab: {ex.Message}"); } }
public static async Task <TeamsTab> AddPlannerTab(string teamId, string channelId, string title) { PlannerPlan plan = null; TeamsTab newTab = null; try { plan = new PlannerPlan(); plan.Owner = teamId; plan.Title = title; plan = await graphClient.Planner.Plans.Request() .AddAsync(plan); } catch (ServiceException ex) { Console.WriteLine($"Error add plan: {ex.Message}"); plan = null; } if (plan != null) { TeamsPlannerTab plannerTab = new TeamsPlannerTab(title, plan.Id); newTab = await graphClient.Teams[teamId].Channels[channelId].Tabs.Request().AddAsync(plannerTab); //using (HttpClient httpClient = new HttpClient()) //{ // TeamsPlannerTab plannerTab = new TeamsPlannerTab("Plan Gamma2", plan.Id); // var resp = await httpClient.PostAsJson( // $"https://graph.microsoft.com/beta/teams/{teamId}/channels/{channelId}/tabs", // plannerTab, // graphClient.AuthenticationProvider as IAuthenticationProvider2); // newTab = await resp.Content.ReadAsJsonAsync<TeamsTab>(); //} } return(newTab); }
/// <inheritdoc/> public async Task <string> AddTabToConversationAsync(ConversationContext conversationContext, TabInfo tabInfo) { // Check if a tab is already added. var existingTabs = await this.graphServiceClient.Chats[conversationContext.ConversationId].Tabs .Request().GetAsync(); var resourceTab = existingTabs.Where(tab => tabInfo.EntityId.Equals(tab.Configuration.EntityId)).FirstOrDefault(); if (resourceTab != null) { // Return an existing tab id. return(resourceTab.Id); } // Add a new tab. var teamsTab = new TeamsTab { DisplayName = tabInfo.DisplayName, Configuration = new TeamsTabConfiguration { EntityId = tabInfo.EntityId, ContentUrl = tabInfo.ContentUrl, WebsiteUrl = tabInfo.WebsiteUrl, RemoveUrl = tabInfo.RemoveUrl, }, AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", $"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{this.appSettings.CatalogAppId}" }, }, }; var result = await this.graphServiceClient.Chats[conversationContext.ConversationId].Tabs .Request() .AddAsync(teamsTab); return(result?.Id); }
private static async Task CreateSharePointPageAsync(string groupId, string channelId, float flightNumber) { try { // Get the team site var teamSite = await graphClient.GetTeamSiteAsync(groupId); logger.LogInformation("Got team site"); // Initialize page var sharePointPage = new SitePage { Name = "Crew.aspx", Title = $"Flight {flightNumber} Crew" }; var webParts = new List <WebPart> { new WebPart { Type = webPartId, Data = new SitePageData { AdditionalData = new Dictionary <string, object> { { "dataVersion", "1.0" }, { "properties", new Dictionary <string, object> { { "description", "CrewBadges" } } } } } } }; sharePointPage.WebParts = webParts; var createdPage = await graphClient.CreateSharePointPageAsync(teamSite.Id, sharePointPage); logger.LogInformation("Created crew page"); // Publish the page await graphClient.PublishSharePointPageAsync(teamSite.Id, createdPage.Id); var pageUrl = createdPage.WebUrl.StartsWith("https") ? createdPage.WebUrl : $"{teamSite.WebUrl}/{createdPage.WebUrl}"; logger.LogInformation("Published crew page"); // Add the list as a team tab var pageTab = new TeamsTab { Name = createdPage.Title, TeamsAppId = "com.microsoft.teamspace.tab.web", Configuration = new TeamsTabConfiguration { ContentUrl = pageUrl, WebsiteUrl = pageUrl } }; await graphClient.AddTeamChannelTab(groupId, channelId, pageTab); logger.LogInformation("Added crew page as Teams tab"); } catch (Exception ex) { logger.LogWarning($"Failed to create crew page: ${ex.ToString()}"); } }
public async Task AddTeamChannelTab(string teamId, string channelId, TeamsTab tab) { await graphClient.Teams[teamId].Channels[channelId].Tabs.Request().AddAsync(tab); }
public async void CreateGroupChat(GraphServiceClient graphClient, string[] members, string userID, string title) { var chat = new Chat { ChatType = ChatType.Group, Topic = title, Members = new ChatMembersCollectionPage() { new AadUserConversationMember { Roles = new List <String>() { "owner" }, AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", "https://graph.microsoft.com/v1.0/users('" + members[0] + "')" } } }, new AadUserConversationMember { Roles = new List <String>() { "owner" }, AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", "https://graph.microsoft.com/v1.0/users('" + userID + "')" } } } } }; var response = await graphClient.Chats .Request() .AddAsync(chat); if (members.Length == 2) { AddMemberWithoutHistory(graphClient, response, members); DeleteMember(graphClient, response); } else if (members.Length == 3) { AddMemberWithHistory(graphClient, response, members); AddMemberWithoutHistory(graphClient, response, members); DeleteMember(graphClient, response); } else if (members.Length >= 4) { AddMemberWithHistory(graphClient, response, members); AddMemberWithoutHistory(graphClient, response, members); AddMemberWithNoOfDays(graphClient, response, members); DeleteMember(graphClient, response); } //Adding Polly app to chat var teamsAppInstallation = new TeamsAppInstallation { AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/1542629c-01b3-4a6d-8f76-1938b779e48d" } } }; await graphClient.Chats[response.Id].InstalledApps .Request() .AddAsync(teamsAppInstallation); //Adding Polly as tab to chat var teamsTab = new TeamsTab { DisplayName = "Associate Insights", Configuration = new TeamsTabConfiguration { EntityId = "pollyapp", ContentUrl = "https://teams.polly.ai/msteams/content/meeting/tab?theme={theme}", WebsiteUrl = null, RemoveUrl = "https://teams.polly.ai/msteams/content/tabdelete?theme={theme}" }, AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/1542629c-01b3-4a6d-8f76-1938b779e48d" } } }; await graphClient.Chats[response.Id].Tabs .Request() .AddAsync(teamsTab); }