This repository was archived by the owner on Jan 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 486
Teams GetParticipant #4770
Merged
Merged
Teams GetParticipant #4770
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
654e476
Teams GetParticipant
EricDahlvang aa7e19c
GetParticipantAsync to GetMeetingParticipantAsync
EricDahlvang 6921695
Add GetMeetingParticipant action
EricDahlvang 239e547
Add GetMeetingParticipant to TeamsComponentRegistration
EricDahlvang a648ddf
build errors
EricDahlvang 61db4ea
remove meeting parameter from TeamsChannelData
EricDahlvang 7b7e87e
address Tom's feedback
EricDahlvang 767837d
Merge branch 'eric/teamsGetParticipant' of https://github.com/microso…
EricDahlvang 59c4edd
Add inMeeting to TeamsParticipantChannelAccount
EricDahlvang e55d8fd
Add tests for GetMeetingParticipant. (also update TestUtils to enable…
EricDahlvang d9e7d83
tests.schema file
EricDahlvang 609765e
some cleanup
EricDahlvang a6469e3
Feedback and some cleanup
EricDahlvang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
148 changes: 148 additions & 0 deletions
148
libraries/Microsoft.Bot.Builder.Dialogs.Adaptive.Teams/Actions/GetMeetingParticipant.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| // Licensed under the MIT License. | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
|
||
| using System; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using AdaptiveExpressions.Properties; | ||
| using Microsoft.Bot.Builder.Teams; | ||
| using Microsoft.Bot.Connector; | ||
| using Microsoft.Bot.Schema.Teams; | ||
| using Newtonsoft.Json; | ||
|
|
||
| namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions | ||
| { | ||
| /// <summary> | ||
| /// Calls TeamsInfo.GetMeetingParticipantAsync and sets the result to a memory property. | ||
| /// </summary> | ||
| public class GetMeetingParticipant : Dialog | ||
| { | ||
| /// <summary> | ||
| /// Class identifier. | ||
| /// </summary> | ||
| [JsonProperty("$kind")] | ||
| public const string Kind = "Teams.GetMeetingParticipant"; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="GetMeetingParticipant"/> class. | ||
| /// </summary> | ||
| /// <param name="callerPath">Optional, source file full path.</param> | ||
| /// <param name="callerLine">Optional, line number in source file.</param> | ||
| [JsonConstructor] | ||
| public GetMeetingParticipant([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) | ||
| : base() | ||
| { | ||
| this.RegisterSourceLocation(callerPath, callerLine); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets an optional expression which if is true will disable this action. | ||
| /// </summary> | ||
| /// <example> | ||
| /// "user.age > 18". | ||
| /// </example> | ||
| /// <value> | ||
| /// A boolean expression. | ||
| /// </value> | ||
| [JsonProperty("disabled")] | ||
| public BoolExpression Disabled { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets property path to put the value in. | ||
| /// </summary> | ||
| /// <value> | ||
| /// Property path to put the value in. | ||
| /// </value> | ||
| [JsonProperty("property")] | ||
| public StringExpression Property { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the expression to get the value to use for meeting id. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The expression to get the value to use for meeting id. If this is missing, then the current turn Activity.TeamsChannelData.Meeting.Id will be used. | ||
| /// </value> | ||
| [JsonProperty("meetingId")] | ||
| public StringExpression MeetingId { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the expression to get the value to use for participant id. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The expression to get the value to use for participant id. If this is missing, then the current turn Activity.From.AadObjectId will be used. | ||
| /// </value> | ||
| [JsonProperty("participantId")] | ||
| public StringExpression ParticipantId { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the expression to get the value to use for tenant id. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The expression to get the value to use for tenant id. If this is missing, then the current turn Activity.TeamsChannelData.Tenant.Id will be used. | ||
| /// </value> | ||
| [JsonProperty("tenantId")] | ||
| public StringExpression TenantId { get; set; } | ||
|
|
||
| /// <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) ?? dc.Context.Activity.TeamsGetMeetingInfo()?.Id; | ||
| string participantId = GetValueOrNull(dc, this.ParticipantId) ?? dc.Context.Activity.From.AadObjectId; | ||
| string tenantId = GetValueOrNull(dc, this.TenantId) ?? dc.Context.Activity.GetChannelData<TeamsChannelData>()?.Tenant?.Id; | ||
|
|
||
| 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); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Builds the compute Id for the dialog. | ||
| /// </summary> | ||
| /// <returns>A string representing the compute Id.</returns> | ||
| protected override string OnComputeId() | ||
| { | ||
| return $"{this.GetType().Name}[{this.MeetingId?.ToString() ?? string.Empty},{this.ParticipantId?.ToString() ?? string.Empty},{this.TenantId?.ToString() ?? string.Empty},{this.Property?.ToString() ?? string.Empty}]"; | ||
| } | ||
|
|
||
| private string GetValueOrNull(DialogContext dc, StringExpression stringExpression) | ||
| { | ||
| if (stringExpression != null) | ||
| { | ||
| var (value, valueError) = stringExpression.TryGetValue(dc.State); | ||
| if (valueError != null) | ||
| { | ||
| throw new Exception($"Expression evaluation resulted in an error. Expression: {stringExpression.ExpressionText}. Error: {valueError}"); | ||
| } | ||
|
|
||
| return value as string; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...oft.Bot.Builder.Dialogs.Adaptive.Teams/Schemas/Actions/Teams.GetMeetingParticipant.schema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| { | ||
| "$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema", | ||
| "$role": "implements(Microsoft.IDialog)", | ||
| "title": "Get Meeting Participant", | ||
|
EricDahlvang marked this conversation as resolved.
Outdated
|
||
| "description": "Get teams meeting partipant information.", | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string", | ||
| "title": "Id", | ||
| "description": "Optional id for the dialog" | ||
| }, | ||
| "property": { | ||
| "$ref": "schema:#/definitions/stringExpression", | ||
| "title": "Property", | ||
| "description": "Property (named location to store information).", | ||
| "examples": [ | ||
| "user.participantInfo" | ||
| ] | ||
| }, | ||
| "meetingId": { | ||
| "$ref": "schema:#/definitions/stringExpression", | ||
| "title": "MeetingId", | ||
|
EricDahlvang marked this conversation as resolved.
Outdated
|
||
| "description": "Meeting Id or expression to a meetingId to use to get the participant information. If none is defined then the current turn Activity.TeamsChannelData.Meeting.Id will be used.", | ||
| "examples": [ | ||
| "$lastActivity.teamsChannelData.meeting.id" | ||
|
EricDahlvang marked this conversation as resolved.
Outdated
|
||
| ] | ||
| }, | ||
| "participantId": { | ||
| "$ref": "schema:#/definitions/stringExpression", | ||
| "title": "ParticipantId", | ||
|
EricDahlvang marked this conversation as resolved.
Outdated
|
||
| "description": "Participant Id or expression to a participantId to use to get the participant information. If none is defined then the current turn Activity.From.AadObjectId will be used.", | ||
| "examples": [ | ||
| "$lastActivity.from.aadObjectId" | ||
|
EricDahlvang marked this conversation as resolved.
Outdated
|
||
| ] | ||
| }, | ||
| "tenantId": { | ||
| "$ref": "schema:#/definitions/stringExpression", | ||
| "title": "TenantId", | ||
|
EricDahlvang marked this conversation as resolved.
Outdated
|
||
| "description": "Tenant Id or expression to a tenantId to use to get the participant information. If none is defined then the current turn Activity.TeamsChannelData.Tenant.Id will be used.", | ||
| "examples": [ | ||
| "$lastActivity.teamsChannelData.tenant.id" | ||
|
EricDahlvang marked this conversation as resolved.
Outdated
|
||
| ] | ||
| }, | ||
| "disabled": { | ||
| "$ref": "schema:#/definitions/booleanExpression", | ||
| "title": "Disabled", | ||
| "description": "Optional condition which if true will disable this action.", | ||
| "examples": [ | ||
| "user.age > 3" | ||
|
EricDahlvang marked this conversation as resolved.
Outdated
|
||
| ] | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.