/// <summary> /// Called when the dialog is started and pushed onto the dialog stack. /// </summary> /// <param name="dc">The <see cref="DialogContext"/> for the current turn of conversation.</param> /// <param name="options">Optional, initial information to pass to the dialog.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects /// or threads to receive notice of cancellation.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public override async Task <DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken)) { if (options is CancellationToken) { throw new ArgumentException($"{nameof(options)} cannot be a cancellation token"); } if (this.Disabled != null && this.Disabled.GetValue(dc.State) == true) { return(await dc.EndDialogAsync(cancellationToken : cancellationToken).ConfigureAwait(false)); } if (dc.Context.Activity.ChannelId != Channels.Msteams) { throw new Exception("TeamsInfo.GetMeetingParticipantAsync() works only on the Teams channel."); } string meetingId = GetValueOrNull(dc, this.MeetingId); string participantId = GetValueOrNull(dc, this.ParticipantId); string tenantId = GetValueOrNull(dc, this.TenantId); if (participantId == null) { // TeamsInfo.GetMeetingParticipantAsync will default to retrieving the current meeting's participant // if none is provided. This could lead to unexpected results. Therefore, GetMeetingParticipant action // throws an exception if the expression provided somehow maps to an invalid result. throw new InvalidOperationException($"GetMeetingParticipant could determine the participant id by expression value provided. {nameof(participantId)} is required."); } var result = await TeamsInfo.GetMeetingParticipantAsync(dc.Context, meetingId, participantId, tenantId, cancellationToken : cancellationToken).ConfigureAwait(false); dc.State.SetValue(this.Property.GetValue(dc.State), result); return(await dc.EndDialogAsync(result, cancellationToken : cancellationToken).ConfigureAwait(false)); }
private async Task CallTeamsInfoGetParticipantAsync(ITurnContext turnContext) { var participant = await TeamsInfo.GetMeetingParticipantAsync(turnContext); Assert.Equal("Organizer", participant.Meeting.Role); Assert.Equal("meetigConversationId-1", participant.Conversation.Id); Assert.Equal("userPrincipalName-1", participant.User.UserPrincipalName); }