/// <summary> /// Bot calls users. /// </summary> /// <param name="participantsCallingRequestData">Input data.</param> /// <returns>The <see cref="Task"/>.</returns> public async Task BotCallsUsersAsync(ParticipantsCallingRequestData participantsCallingRequestData) { Guid scenarioId = Guid.NewGuid(); ParticipantInfo source = new ParticipantInfo { Identity = new IdentitySet { Application = new Identity { Id = this.appId, }, }, }; Call requestCall = new Call { Source = source, Targets = new List <InvitationParticipantInfo>(), MediaConfig = new ServiceHostedMediaConfig { }, RequestedModalities = new List <Modality> { Modality.Audio }, TenantId = participantsCallingRequestData.TenantId, Direction = CallDirection.Outgoing, CallbackUri = new Uri(this.botBaseUri, ControllerConstants.CallbackPrefix).ToString(), }; List <InvitationParticipantInfo> listTargets = new List <InvitationParticipantInfo>(); foreach (string userId in participantsCallingRequestData.ObjectIds) { InvitationParticipantInfo target = new InvitationParticipantInfo { Identity = new IdentitySet { User = new Identity { Id = userId, }, } }; listTargets.Add(target); } requestCall.Targets = listTargets; var callRequest = this.RequestBuilder.Communications.Calls; var request = new GraphRequest <Call>(new Uri(callRequest.RequestUrl), requestCall, RequestType.Create); var response = await this.GraphApiClient.SendAsync <Call, Call>(request, requestCall.TenantId, scenarioId).ConfigureAwait(false); Call responseMeetingCall = response.Content; this.GraphLogger.Log( TraceLevel.Verbose, $"Bot called users {participantsCallingRequestData.ObjectIds}, the responded state is {responseMeetingCall?.State}"); }
public async Task <IActionResult> PostNotificationsAsync([FromBody] ParticipantsCallingRequestData participantsCallingRequestData) { try { Validator.NotNull(participantsCallingRequestData, nameof(participantsCallingRequestData), "participantsCallingRequestData is Null."); Validator.NotNull(participantsCallingRequestData.ObjectIds, nameof(participantsCallingRequestData.ObjectIds), "Object Ids are Null or Whitespace."); Validator.NotNullOrWhitespace(participantsCallingRequestData.TenantId, nameof(participantsCallingRequestData.TenantId), "Tenant Id is Null or Whitespace."); await this.bot.BotCallsUsersAsync(participantsCallingRequestData).ConfigureAwait(false); return(this.Ok("Bot got a notification to call group of users.")); } catch (Exception e) { return(this.Exception(e)); } }