/// <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)) { return(await dc.EndDialogAsync(cancellationToken : cancellationToken).ConfigureAwait(false)); } if (dc.Context.Activity.ChannelId != Channels.Msteams) { throw new InvalidOperationException($"{Kind} works only on the Teams channel."); } string meetingId = MeetingId.GetValueOrNull(dc.State); string participantId = ParticipantId.GetValueOrNull(dc.State); string tenantId = TenantId.GetValueOrNull(dc.State); 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($"{Kind} could not 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); if (this.Property != null) { dc.State.SetValue(this.Property.GetValue(dc.State), result); } return(await dc.EndDialogAsync(result, cancellationToken : cancellationToken).ConfigureAwait(false)); }