public async Task <IMessageActivity> ScheduleInterviewAsync( ITurnContext turnContext, CancellationToken cancellationToken) { var commandData = JsonConvert.DeserializeObject <ScheduleInterviewCommand>(turnContext.Activity.Value?.ToString()); if (commandData is null) { return(null); } await _interviewService.ScheduleInterview(commandData, cancellationToken); var candidate = await _candidateService.GetById(commandData.CandidateId, cancellationToken); var interviewers = await _recruiterService.GetAllInterviewers(cancellationToken); var templateModel = new CandidateTemplateModel { Items = new List <Candidate> { candidate }, Interviewers = interviewers, AppSettings = _appSettings, NoItemsLabel = "You don't have such candidate." }; var messageActivity = await _candidatesTemplate.RenderTemplate(turnContext, null, TemplateConstants.CandidateAsAdaptiveCardWithMultipleItems, templateModel); return(messageActivity); }
public async Task NotifyRecruiterAboutCandidateStageChange( Candidate candidate, CancellationToken cancellationToken = default) { if (candidate?.Position != null) { var recruiter = await _recruiterService.GetById(candidate.Position.HiringManagerId, cancellationToken); if (recruiter?.ConversationData is null) { return; } var interviewers = await _recruiterService.GetAllInterviewers(cancellationToken); var templateModel = new CandidateTemplateModel { Items = new List <Candidate> { candidate }, Interviewers = interviewers, AppSettings = _appSettings }; var attachments = (await _candidatesTemplate.RenderTemplate(null, null, TemplateConstants.CandidateAsAdaptiveCardWithMultipleItems, templateModel)).Attachments; await SendToConversation($"Candidate stage has been changed for {candidate.Name} from {candidate.PreviousStage} to {candidate.Stage}", attachments, recruiter.ConversationData, cancellationToken); } }
public override async Task <DialogTurnResult> BeginDialogAsync( DialogContext dc, object options = default, CancellationToken cancellationToken = default) { var text = dc.Context.GetTextWithoutCommand(BotCommands.CandidateSummaryDialog); var candidates = await _candidateService.Search(text, 15, cancellationToken); var templateModel = new CandidateTemplateModel { BotCommand = BotCommands.CandidateSummaryDialog, ListCardTitle = "Please select candidate:", Items = candidates, NoItemsLabel = "You don't have such candidates." }; await _candidatesTemplate.ReplyWith(dc.Context, TemplateConstants.CandidateAsFileConsentCardWithMultipleItems, templateModel); return(await dc.EndDialogAsync(cancellationToken : cancellationToken)); }
public override async Task <DialogTurnResult> BeginDialogAsync( DialogContext dc, object options = null, CancellationToken cancellationToken = default) { var text = dc.Context.GetTextWithoutCommand(BotCommands.TopCandidatesDialogCommand); var positions = await _positionService.Search(text, 15, cancellationToken); if (positions.Count == 1) { var candidates = positions[0].Candidates; var interviewers = await _recruiterService.GetAllInterviewers(cancellationToken); CandidateTemplateModel templateModel = new CandidateTemplateModel { ListCardTitle = "Top candidates who have recently applied to your position:", BotCommand = BotCommands.CandidateDetailsDialogCommand, Items = candidates, Interviewers = interviewers, AppSettings = _appSettings, NoItemsLabel = $"There are no candidates for position ID: {positions[0].PositionExternalId}" }; await _candidatesTemplate.ReplyWith(dc.Context, TemplateConstants.CandidateAsAdaptiveCardWithMultipleItems, templateModel); } else { PositionTemplateModel positionsTemplate = new PositionTemplateModel { ListCardTitle = "I found several positions. Please specify:", Items = positions, BotCommand = BotCommands.TopCandidatesDialogCommand, NoItemsLabel = "You don't have open position with such ID." }; await _positionsTemplate.ReplyWith(dc.Context, TemplateConstants.PositionAsAdaptiveCardWithMultipleItems, positionsTemplate); } return(await dc.EndDialogAsync(cancellationToken : cancellationToken)); }
public override async Task <DialogTurnResult> BeginDialogAsync( DialogContext dc, object options = null, CancellationToken cancellationToken = default) { var text = dc.Context.GetTextWithoutCommand(BotCommands.CandidateDetailsDialogCommand); var candidates = await _candidateService.Search(text, 15, cancellationToken); var interviewers = await _recruiterService.GetAllInterviewers(cancellationToken); var templateModel = new CandidateTemplateModel { ListCardTitle = "I found following candidates:", BotCommand = string.Empty, Items = candidates, Interviewers = interviewers, AppSettings = _appSettings, NoItemsLabel = "You don't have such candidates." }; await _candidatesTemplate.ReplyWith(dc.Context, TemplateConstants.CandidateAsAdaptiveCardWithMultipleItems, templateModel); return(await dc.EndDialogAsync(cancellationToken : cancellationToken)); }
public async Task <InvokeResponse> HandleMessagingExtensionQueryAsync( ITurnContext turnContext, MessagingExtensionQuery query, CancellationToken cancellationToken) { var initialRunParameter = GetQueryParameterByName(query, "initialRun"); // situation where the incoming payload was received from the config popup if (!string.IsNullOrEmpty(query.State)) { initialRunParameter = bool.TrueString; } var isInitialRun = string.Equals(initialRunParameter, bool.TrueString, StringComparison.OrdinalIgnoreCase); var maxResults = isInitialRun ? 5 : query.QueryOptions.Count ?? 25; var attachments = new List <MessagingExtensionAttachment>(); var searchText = GetQueryParameterByName(query, MessagingExtensionCommands.SearchTextParameterName); switch (query.CommandId) { case MessagingExtensionCommands.SearchPositions: var positions = await _positionService.Search(searchText, maxResults, cancellationToken); foreach (var position in positions) { var positionsTemplate = new PositionTemplateModel { Items = new List <Position> { position }, }; var mainCard = await _positionsTemplate.RenderTemplate(turnContext, null, TemplateConstants.PositionAsAdaptiveCardWithMultipleItems, positionsTemplate); var previewCard = await _positionsTemplate.RenderTemplate(turnContext, null, TemplateConstants.PositionAsThumbnailCardWithMultipleItems, positionsTemplate); attachments.Add(mainCard.Attachments.First().ToMessagingExtensionAttachment(previewCard.Attachments.First())); } break; case MessagingExtensionCommands.SearchCandidates: var candidates = await _candidateService.Search(searchText, maxResults, cancellationToken); var interviewers = await _recruiterService.GetAllInterviewers(cancellationToken); foreach (var candidate in candidates) { var templateModel = new CandidateTemplateModel { Items = new List <Candidate> { candidate }, Interviewers = interviewers, AppSettings = _appSettings, }; var mainCard = await _candidatesTemplate.RenderTemplate(turnContext, null, TemplateConstants.CandidateAsAdaptiveCardWithMultipleItems, templateModel); var previewCard = await _candidatesTemplate.RenderTemplate(turnContext, null, TemplateConstants.CandidateAsThumbnailCardWithMultipleItems, templateModel); attachments.Add(mainCard.Attachments.First().ToMessagingExtensionAttachment(previewCard.Attachments.First())); } break; } return(_mapper.Map <MessagingExtensionAttachment[], InvokeResponse>(attachments.ToArray())); }