public async Task <IActionResult> PostIncidentAsync([FromBody] IncidentRequestData incidentRequestData) { Validator.NotNull(incidentRequestData, nameof(incidentRequestData)); try { var call = await this.bot.RaiseIncidentAsync(incidentRequestData).ConfigureAwait(false); var callUriTemplate = new UriBuilder(this.bot.BotInstanceUri); callUriTemplate.Path = HttpRouteConstants.CallRoutePrefix.Replace("{callLegId}", call.Id); callUriTemplate.Query = this.bot.BotInstanceUri.Query.Trim('?'); var callUri = callUriTemplate.Uri.AbsoluteUri; var values = new Dictionary <string, string> { { "legId", call.Id }, { "scenarioId", call.ScenarioId.ToString() }, { "call", callUri }, { "logs", callUri.Replace("/calls/", "/logs/") }, }; var serializer = new CommsSerializer(pretty: true); var json = serializer.SerializeObject(values); return(this.Ok(json)); } catch (Exception e) { return(this.Exception(e)); } }
/// <summary> /// Raise an incident. /// </summary> /// <param name="incidentRequestData">The incident data.</param> /// <returns>The task for await.</returns> public async Task <ICall> RaiseIncidentAsync(IncidentRequestData incidentRequestData) { // A tracking id for logging purposes. Helps identify this call in logs. var scenarioId = string.IsNullOrEmpty(incidentRequestData.ScenarioId) ? Guid.NewGuid() : new Guid(incidentRequestData.ScenarioId); string incidentId = Guid.NewGuid().ToString(); var incidentStatusData = new IncidentStatusData(incidentId, incidentRequestData); var incident = this.IncidentStatusManager.AddIncident(incidentId, incidentStatusData); var botMeetingCall = await this.JoinCallAsync(incidentRequestData, incidentId).ConfigureAwait(false); // Rehydrates and validates the group call. botMeetingCall = await this.RehydrateAndValidateGroupCallAsync(this.Client, botMeetingCall).ConfigureAwait(false); foreach (var objectId in incidentRequestData.ObjectIds) { var makeCallRequestData = new MakeCallRequestData( incidentRequestData.TenantId, objectId, "Application".Equals(incidentRequestData.ResponderType, StringComparison.OrdinalIgnoreCase)); var responderCall = await this.MakeCallAsync(makeCallRequestData, scenarioId).ConfigureAwait(false); this.AddCallToHandlers(responderCall, new IncidentCallContext(IncidentCallType.ResponderNotification, incidentId)); } return(botMeetingCall); }
/// <summary> /// Unknown Visitor incident. /// </summary> /// <param name="incidentRequestData">The incident data.</param> /// <returns>The task for await.</returns> public async Task <ICall> CallUnknownVisitorAsync(IncidentRequestData incidentRequestData) { // A tracking id for logging purposes. Helps identify this call in logs. var scenarioId = string.IsNullOrEmpty(incidentRequestData.ScenarioId) ? Guid.NewGuid() : new Guid(incidentRequestData.ScenarioId); string incidentId = Guid.NewGuid().ToString(); var incidentStatusData = new IncidentStatusData(incidentId, incidentRequestData); var incident = this.IncidentStatusManager.AddIncident(incidentId, incidentStatusData); var receptionObjectId = incidentRequestData.ObjectIds.First(); // call the receptionist var buildingObjectId = incidentRequestData.ObjectIds.Last(); // call the building var receptionTarget = new ParticipantInfo { Identity = new IdentitySet { User = new Identity { Id = receptionObjectId, }, }, }; var buildingTarget = new ParticipantInfo { Identity = new IdentitySet { User = new Identity { Id = buildingObjectId, }, }, }; var call = new Call { Targets = new[] { receptionTarget }, MediaConfig = new ServiceHostedMediaConfig { }, RequestedModalities = new List <Modality> { Modality.Video }, TenantId = incidentRequestData.TenantId, }; // call the receptionist var statefulCall = await this.Client.Calls().AddAsync(call, scenarioId: scenarioId).ConfigureAwait(false); // add the building var addParticipantRequestData = new AddParticipantRequestData() { ObjectId = buildingObjectId, }; await this.MyAddParticipantAsync(statefulCall.Id, addParticipantRequestData).ConfigureAwait(false); this.graphLogger.Info($"Call creation complete: {statefulCall.Id}"); // return botMeetingCall; return(null); }
/// <summary> /// Saves incident details of participants /// </summary> /// <param name="participants">Participant details</param> /// <param name="joinWebUrl">Joining web url</param> /// <returns>Call id of the incident</returns> public async Task <string> PostIncidentAsync(List <Models.Participant> participants, string joinWebUrl) { string callId = null; List <string> participantsAadIds = new List <string>(); foreach (var participant in participants) { participantsAadIds.Add(participant.AadId.ToString()); } //participantsAadIds.Add(objectId); IncidentRequestData incidentRequestData = new IncidentRequestData() { Name = "New incident" + DateTime.UtcNow.ToString(CultureInfo.InvariantCulture), Time = DateTime.UtcNow, TenantId = _configuration["AzureAd:TenantId"], ObjectIds = participantsAadIds, JoinUrl = joinWebUrl }; Validator.NotNull(incidentRequestData, nameof(incidentRequestData)); try { var call = await _bot.RaiseIncidentAsync(incidentRequestData).ConfigureAwait(false); var callUriTemplate = new UriBuilder(_bot.BotInstanceUri) { Path = HttpRouteConstants.CallRoutePrefix.Replace("{callLegId}", call.Id), Query = _bot.BotInstanceUri.Query.Trim('?') }; var callUri = callUriTemplate.Uri.AbsoluteUri; var values = new Dictionary <string, string> { { "legId", call.Id }, { "scenarioId", call.ScenarioId.ToString() }, { "call", callUri }, { "logs", callUri.Replace("/calls/", "/logs/") }, }; var serializer = new CommsSerializer(pretty: true); serializer.SerializeObject(values); callId = call.Id; } catch (Exception e) { _logger.LogError(e.Message + ' ' + e.StackTrace); } return(callId); }
public async Task <IActionResult> PostIncidentAsync([FromBody] IncidentRequestData incidentRequestData) { Validator.NotNull(incidentRequestData, nameof(incidentRequestData)); try { var botMeetingCall = await this.bot.RaiseIncidentAsync(incidentRequestData).ConfigureAwait(false); return(this.Ok(botMeetingCall.Id)); } catch (Exception e) { return(this.Exception(e)); } }
/// <summary> /// Initializes a new instance of the <see cref="IncidentStatusData"/> class. /// </summary> /// <param name="id">The incident id.</param> /// <param name="data">The incident data.</param> public IncidentStatusData(string id, IncidentRequestData data) : this(id, data.Name, data.Time, data.ObjectIds) { }
private async Task HandleEvent(ITurnContext <IMessageActivity> turnContext, string input, CancellationToken cancellationToken) { var conversationId = turnContext.Activity.Conversation.Id; switch (input) { case Constants.RequestACall: var raiseNewRequestAttachment = this.cardHelper.RaiseNewRequestAttachment(); await turnContext.SendActivityAsync(MessageFactory.Attachment(raiseNewRequestAttachment), cancellationToken); break; case Constants.PlaceACall: await turnContext.SendActivityAsync(Constants.RequestHasBeenSubmitted); var acsOnlineMeeting = await this.graph.CreateOnlineMeeting(); if (acsOnlineMeeting != null) { var webChatMeetingLinkAttachment = this.cardHelper.WebChatMeetingLinkAttachment($"{this.configuration[Constants.BaseUrl]}?meetingLink=" + acsOnlineMeeting.JoinWebUrl); await turnContext.SendActivityAsync(this.CreateMessageActivityForWebChat(string.Empty, webChatMeetingLinkAttachment)); string[] usersIdsArray = this.configuration[Constants.UserIdsConfigurationSettingsKey].Split(','); IncidentRequestData incidentRequestData = new IncidentRequestData() { Name = "New incident" + DateTime.UtcNow.ToString(CultureInfo.InvariantCulture), Time = DateTime.UtcNow, TenantId = this.configuration[Constants.TenantIdConfigurationSettingsKey], ObjectIds = usersIdsArray, JoinUrl = acsOnlineMeeting.JoinWebUrl, }; var call = await this.bot.RaiseIncidentAsync(incidentRequestData).ConfigureAwait(false); } break; case Constants.SubmitNewRequest: await this.SubmitNewChatRequest(turnContext); break; case var accept when string.Equals(accept, Constants.Accept, StringComparison.InvariantCultureIgnoreCase): var acsEvent = await this.graph.CreateOnlineMeeting(); if (acsEvent != null) { var customerInfo = await this.GetCustomerInformation(conversationId); if (customerInfo != null) { await this.SubmitUpdatedChatRequest(turnContext, customerInfo, cancellationToken, acsEvent.JoinWebUrl); await this.SendToWebChatFromTeamsChannel(turnContext, cancellationToken, Constants.UpdateAssignmentStatusToUser, null); var webChatMeetingLinkAttachment = this.cardHelper.WebChatMeetingLinkAttachment($"{this.configuration[Constants.BaseUrl]}?meetingLink=" + acsEvent.JoinWebUrl); await this.SendToWebChatFromTeamsChannel(turnContext, cancellationToken, string.Empty, webChatMeetingLinkAttachment); } } break; default: break; } }