public override async Task <DialogTurnResult> BeginDialogAsync( DialogContext dc, object options = null, CancellationToken cancellationToken = default) { var hiringManagers = await _recruiterService.GetAllHiringManagers(cancellationToken); var token = await((IUserTokenProvider)dc.Context.Adapter) .GetUserTokenAsync(dc.Context, _appSettings.OAuthConnectionName, null, cancellationToken); var successfullyInstalled = new List <string>(); foreach (var manager in hiringManagers) { if (await _graphApiService.InstallBotForUser(token.Token, manager.Alias, cancellationToken)) { successfullyInstalled.Add(manager.Name); } } var message = successfullyInstalled.Count == 0 ? "Bot wasn't installed to any of hiring manager." : $"Bot was successfully installed for: {string.Join(", ", successfullyInstalled)}"; await dc.Context.SendActivityAsync(message, cancellationToken : cancellationToken); return(await dc.EndDialogAsync(cancellationToken : cancellationToken)); }
public AdaptiveCard GetAdaptiveCardForNewJobPosting(string description = null) { var locations = _locationService.GetAllLocations().GetAwaiter().GetResult(); var hiringManagers = _recruiterService.GetAllHiringManagers().GetAwaiter().GetResult(); var command = new { commandId = AppCommands.OpenNewTicket }; var wrapAction = new CardAction { Title = "Create ticket", Value = command }; var action = new AdaptiveSubmitAction { Data = command }; action.RepresentAsBotBuilderAction(wrapAction); return(new AdaptiveCard { Version = "1.0", Body = new List <AdaptiveElement> { new AdaptiveTextBlock("Enter in ticket description") { IsSubtle = true, Wrap = true, Size = AdaptiveTextSize.Small }, new AdaptiveTextBlock("Description"), new AdaptiveTextInput { Id = "description", IsMultiline = true, Placeholder = "E.g There is an application error.", Value = description } }, Actions = new List <AdaptiveAction> { action } }); }
public async Task HandleFileAttachments(ITurnContext turnContext, CancellationToken cancellationToken) { var description = await TryToExtractDescriptionFromFile(turnContext.Activity.Attachments); if (!string.IsNullOrEmpty(description)) { var locations = await _locationService.GetAllLocations(cancellationToken); var hiringManagers = await _recruiterService.GetAllHiringManagers(cancellationToken); await _newJobPostingTemplate.ReplyWith(turnContext, nameof(NewJobPostingToAdaptiveCardTemplate), new { Locations = locations, HiringManagers = hiringManagers, Description = description }); } }
public override async Task <DialogTurnResult> BeginDialogAsync( DialogContext dc, object options = null, CancellationToken cancellationToken = default) { var locations = await _locationService.GetAllLocations(cancellationToken); var hiringManagers = await _recruiterService.GetAllHiringManagers(cancellationToken); await _newJobPostingTemplate.ReplyWith(dc.Context, nameof(NewJobPostingToAdaptiveCardTemplate), new { Locations = locations, HiringManagers = hiringManagers, Description = string.Empty }); return(await dc.EndDialogAsync(cancellationToken : cancellationToken)); }
public async Task <InvokeResponse> HandleMessagingExtensionFetchTaskAsync(ITurnContext <IInvokeActivity> turnContext, CancellationToken cancellationToken) { var composeExtensionQuery = turnContext.TurnState.Get <ITeamsContext>().GetMessagingExtensionActionData(); MessagingExtensionActionResponse response = null; if (string.Equals(composeExtensionQuery?.CommandId, MessagingExtensionCommands.OpenNewPosition, StringComparison.OrdinalIgnoreCase)) { var locations = await _locationService.GetAllLocations(cancellationToken); var hiringManagers = await _recruiterService.GetAllHiringManagers(cancellationToken); var messageActivity = await _newJobPostingToAdaptiveCardTemplate.RenderTemplate(turnContext, null, nameof(NewJobPostingToAdaptiveCardTemplate), new { Locations = locations, HiringManagers = hiringManagers, Description = string.Empty }); response = new MessagingExtensionActionResponse { Task = new TaskModuleContinueResponse { Type = "continue", Value = new TaskModuleTaskInfo { Card = messageActivity.Attachments.First(), Title = "Create new job posting", Width = "large", Height = "large" } } }; } return(_mapper.Map <MessagingExtensionActionResponse, InvokeResponse>(response)); }
public AdaptiveCard GetAdaptiveCardForNewJobPosting(string description = null) { var locations = _locationService.GetAllLocations().GetAwaiter().GetResult(); var hiringManagers = _recruiterService.GetAllHiringManagers().GetAwaiter().GetResult(); var command = new { commandId = AppCommands.OpenNewPosition }; var wrapAction = new CardAction { Title = "Create posting", Value = command }; var action = new AdaptiveSubmitAction { Data = command }; action.RepresentAsBotBuilderAction(wrapAction); return(new AdaptiveCard { Version = "1.0", Body = new List <AdaptiveElement> { new AdaptiveTextBlock("Enter in basic information about this posting") { IsSubtle = true, Wrap = true, Size = AdaptiveTextSize.Small }, new AdaptiveTextBlock("Title") { Wrap = true }, new AdaptiveTextInput { Id = "jobTitle", Placeholder = "E.g. Senior PM" }, new AdaptiveColumnSet { Columns = new List <AdaptiveColumn> { new AdaptiveColumn { Width = "stretch", Items = new List <AdaptiveElement> { new AdaptiveTextBlock("Level") { Wrap = true }, new AdaptiveChoiceSetInput { Id = "jobLevel", Style = AdaptiveChoiceInputStyle.Compact, Choices = Enumerable.Range(7, 4).Select(x => { var s = x.ToString(); return new AdaptiveChoice { Title = s, Value = s }; }).ToList(), Value = "7" } } }, new AdaptiveColumn { Width = "stretch", Items = new List <AdaptiveElement> { new AdaptiveTextBlock("Post by") { Wrap = true }, new AdaptiveDateInput { Id = "jobPostingDate", Placeholder = "Posting date", Value = DateTime.Now.ToShortDateString() } } } } }, new AdaptiveColumnSet { Columns = new List <AdaptiveColumn> { new AdaptiveColumn { Items = new List <AdaptiveElement> { new AdaptiveTextBlock("Location"), new AdaptiveChoiceSetInput { Id = "jobLocation", Style = AdaptiveChoiceInputStyle.Compact, Choices = locations.Select(x => new AdaptiveChoice { Value = x.LocationId.ToString(), Title = x.City }).ToList(), Value = Convert.ToString(locations[0].LocationId) } } }, new AdaptiveColumn { Items = new List <AdaptiveElement> { new AdaptiveTextBlock("Hiring manager"), new AdaptiveChoiceSetInput { Id = "jobHiringManager", Style = AdaptiveChoiceInputStyle.Compact, Choices = hiringManagers.Select(x => new AdaptiveChoice { Value = x.RecruiterId.ToString(), Title = x.Name }).ToList(), Value = Convert.ToString(hiringManagers[0].RecruiterId) } } } } }, new AdaptiveTextBlock("Description"), new AdaptiveTextInput { Id = "jobDescription", IsMultiline = true, Placeholder = "E.g. Senior Product Manager in charge of driving complicated work and stuff.", Value = description } }, Actions = new List <AdaptiveAction> { action } }); }