/// <inheritdoc/> public async Task InstallAppForTeamAsync(string appId, string teamId) { if (string.IsNullOrWhiteSpace(appId)) { throw new ArgumentNullException(nameof(appId)); } if (string.IsNullOrWhiteSpace(teamId)) { throw new ArgumentNullException(nameof(teamId)); } var userScopeTeamsAppInstallation = new TeamsAppInstallation() { AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", $"{GraphConstants.V1BaseUrl}/appCatalogs/teamsApps/{appId}" }, }, }; await this.serviceClient.Teams[teamId] .InstalledApps .Request() .WithMaxRetry(GraphConstants.MaxRetry) .AddAsync(userScopeTeamsAppInstallation); }
/// <inheritdoc/> public async Task <string> AddApplicationToConversationAsync(ConversationContext conversationContext) { var teamsAppInstallation = new TeamsAppInstallation { AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", $"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{this.appSettings.CatalogAppId}" }, }, }; try { var result = await this.graphServiceClient.Chats[conversationContext.ConversationId].InstalledApps .Request() .AddAsync(teamsAppInstallation); return(result?.Id); } catch (ServiceException exception) { if (exception.StatusCode == HttpStatusCode.Conflict) { this.logger.LogInformation($"App is already installed. Inner error code: {exception.Error.Code}"); return(string.Empty); } throw exception; } }
/// <summary> /// Create new navigation property to installedApps for me /// <param name="body"></param> /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param> /// </summary> public RequestInformation CreatePostRequestInformation(TeamsAppInstallation body, Action <InstalledAppsRequestBuilderPostRequestConfiguration> requestConfiguration = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, UrlTemplate = UrlTemplate, PathParameters = PathParameters, }; requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); if (requestConfiguration != null) { var requestConfig = new InstalledAppsRequestBuilderPostRequestConfiguration(); requestConfiguration.Invoke(requestConfig); requestInfo.AddRequestOptions(requestConfig.Options); requestInfo.AddHeaders(requestConfig.Headers); } return(requestInfo); }
public async Task <string> AddApp() { string token = await GetToken(TenantId); GraphServiceClient graphClient = GetAuthenticatedClient(token); string PollyAppId = "1542629c-01b3-4a6d-8f76-1938b779e48d"; var teamsAppInstallation = new TeamsAppInstallation { AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/" + PollyAppId } } }; // Adding Polly App await graphClient.Teams[TeamId].InstalledApps .Request() .AddAsync(teamsAppInstallation); return("Added Successfully"); }
// Install app in team. public async Task InstallAppInTeam(string teamId, string appId) { try { var graphClient = GetAuthenticatedClient(); var teamsAppInstallation = new TeamsAppInstallation { AdditionalData = new Dictionary <string, object>() { { "*****@*****.**", "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/" + appId } } }; await graphClient.Teams[teamId].InstalledApps .Request() .AddAsync(teamsAppInstallation); } catch (Exception ex) { throw ex; } }
private static async Task <Channel> InitializeTeamInGroupAsync(string groupId, string welcomeMessage) { // Create the team var team = new Team { GuestSettings = new TeamGuestSettings { AllowCreateUpdateChannels = false, AllowDeleteChannels = false } }; await graphClient.CreateTeamAsync(groupId, team); logger.LogInformation("Created team"); // Get channels var channels = await graphClient.GetTeamChannelsAsync(groupId); // Get "General" channel. Since it is created by default and is the only // channel after creation, just get the first result. var generalChannel = channels.CurrentPage.First(); //// Create welcome message (new thread) //var welcomeThread = new ChatThread //{ // RootMessage = new ChatMessage // { // Body = new ItemBody { Content = welcomeMessage } // } //}; //await graphClient.CreateChatThreadAsync(groupId, generalChannel.Id, welcomeThread); //logger.LogInformation("Posted welcome message"); // Provision pilot channel var pilotChannel = new Channel { DisplayName = "Pilots", Description = "Discussion about flightpath, weather, etc." }; await graphClient.CreateTeamChannelAsync(groupId, pilotChannel); logger.LogInformation("Created Pilots channel"); // Provision flight attendants channel var flightAttendantsChannel = new Channel { DisplayName = "Flight Attendants", Description = "Discussion about duty assignments, etc." }; await graphClient.CreateTeamChannelAsync(groupId, flightAttendantsChannel); logger.LogInformation("Created FA channel"); // Add the requested team app if (!string.IsNullOrEmpty(teamAppId)) { var teamsApp = new TeamsAppInstallation { AdditionalData = new Dictionary <string, object>() }; teamsApp.AdditionalData.Add("*****@*****.**", $"https://graph.microsoft.com/beta/appCatalogs/teamsApps/{teamAppId}"); await graphClient.AddAppToTeam(groupId, teamsApp); } logger.LogInformation("Added app to team"); // Return the general channel return(generalChannel); }
public async Task AddAppToTeam(string teamId, TeamsAppInstallation app) { var response = await graphClient.Teams[teamId].InstalledApps.Request().AddAsync(app); }
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); }