Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions packages/Teams/js/schemas/Actions/Teams.GetMeetingInfo.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema",
"$role": "implements(Microsoft.IDialog)",
"title": "Get meeting information",
"description": "Get teams meeting 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": [
"dialog.meetingInfo"
]
},
"meetingId": {
"$ref": "schema:#/definitions/stringExpression",
"title": "Meeting id",
"description": "Meeting Id or expression to a meetingId to use to get the meeting information. Default value is the current turn.activity.channelData.meeting.id.",
"examples": [
"=turn.activity.channelData.meeting.id"
]
},
"disabled": {
"$ref": "schema:#/definitions/booleanExpression",
"title": "Disabled",
"description": "Optional condition which if true will disable this action.",
"examples": [
"=user.age > 3"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://schemas.botframework.com/schemas/ui/v1.0/ui.schema",
"menu": {
"submenu": ["Microsoft Teams", "Get Teams Info"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema",
"$role": [ "implements(Microsoft.ITrigger)", "extends(Microsoft.OnCondition)" ],
"title": "On meeting end",
"description": "Actions triggered when a Teams Meeting is ended",
"type": "object",
"required": [
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://schemas.botframework.com/schemas/ui/v1.0/ui.schema",
"trigger": {
"submenu": "Microsoft Teams",
"label": "On meeting end"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema",
"$role": [ "implements(Microsoft.ITrigger)", "extends(Microsoft.OnCondition)" ],
"title": "On meeting start",
"description": "Actions triggered when a Teams Meeting is started",
"type": "object",
"required": [
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://schemas.botframework.com/schemas/ui/v1.0/ui.schema",
"trigger": {
"submenu": "Microsoft Teams",
"label": "On meeting start"
}
}
123 changes: 123 additions & 0 deletions packages/Teams/js/src/actions/getMeetingInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import {
BoolExpression,
BoolExpressionConverter,
Expression,
StringExpression,
StringExpressionConverter,
} from 'adaptive-expressions';
import { Channels, TeamsInfo } from 'botbuilder';
import {
Converter,
ConverterFactory,
Dialog,
DialogConfiguration,
DialogContext,
DialogTurnResult,
} from 'botbuilder-dialogs';
import { getValue } from './actionHelpers';

export interface GetMeetingInfoConfiguration
extends DialogConfiguration {
disabled?: boolean | string | BoolExpression;
property?: string | Expression | StringExpression;
meetingId?: string | Expression | StringExpression;
}

/**
* Calls `TeamsInfo.getMeetingInfo` and sets the result to a memory property.
*/
export class GetMeetingInfo
extends Dialog
implements GetMeetingInfoConfiguration {
/**
* Class identifier.
*/
static $kind = 'Teams.GetMeetingInfo';

/**
* Gets or sets an optional expression which if is true will disable this action.
*
* @example
* "user.age > 18".
*/
public disabled?: BoolExpression;

/**
* Gets or sets property path to put the value in.
*/
public property?: StringExpression;

/**
* Gets or sets the expression to get the value to use for meeting id.
*
* @default
* =turn.activity.channelData.meeting.id
*/
public meetingId = new StringExpression(
'=turn.activity.channelData.meeting.id'
);

public getConverter(
property: keyof GetMeetingInfoConfiguration
): Converter | ConverterFactory {
switch (property) {
case 'disabled':
return new BoolExpressionConverter();
case 'property':
case 'meetingId':
return new StringExpressionConverter();
default:
return super.getConverter(property);
}
}

/**
* Called when the dialog is started and pushed onto the dialog stack.
*
* @param {DialogContext} dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation.
* @param {object} _options Optional, initial information to pass to the dialog.
* @returns {Promise<DialogTurnResult>} A promise representing the asynchronous operation.
*/
public async beginDialog(
dc: DialogContext,
_options?: Record<string, unknown>
): Promise<DialogTurnResult> {
if (this.disabled?.getValue(dc.state)) {
return dc.endDialog();
}

if (dc.context.activity.channelId !== Channels.Msteams) {
throw new Error(
`${GetMeetingInfo.$kind} works only on the Teams channel.`
);
}

const meetingId = getValue(dc, this.meetingId);

const result = await TeamsInfo.getMeetingInfo(
dc.context,
meetingId
);

if (this.property != null) {
dc.state.setValue(this.property.getValue(dc.state), result);
}

return dc.endDialog(result);
}

/**
* Builds the compute Id for the dialog.
*
* @returns {string} A string representing the compute Id.
*/
protected onComputeId(): string {
return `GetMeetingInfo[\
${this.meetingId ?? ''},\
${this.property?.toString() ?? ''}\
]`;
}
}
1 change: 1 addition & 0 deletions packages/Teams/js/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

export * from './getMeetingInfo';
export * from './getMeetingParticipant';
export * from './getMember';
export * from './getPagedMembers';
Expand Down
9 changes: 9 additions & 0 deletions packages/Teams/js/src/adaptiveTeamsBotComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from 'botbuilder-dialogs-adaptive-runtime-core';

import {
GetMeetingInfo,
GetMeetingParticipant,
GetMember,
GetPagedMembers,
Expand Down Expand Up @@ -40,6 +41,8 @@ import {
OnTeamsChannelRenamed,
OnTeamsChannelRestored,
OnTeamsFileConsent,
OnTeamsMeetingStart,
OnTeamsMeetingEnd,
OnTeamsMEBotMessagePreviewEdit,
OnTeamsMEBotMessagePreviewSend,
OnTeamsMECardButtonClicked,
Expand Down Expand Up @@ -75,6 +78,10 @@ export class AdaptiveTeamsBotComponent extends BotComponent {
getDeclarativeTypes() {
return [
// Actions
{
kind: GetMeetingInfo.$kind,
type: GetMeetingInfo,
},
{
kind: GetMeetingParticipant.$kind,
type: GetMeetingParticipant,
Expand Down Expand Up @@ -153,6 +160,8 @@ export class AdaptiveTeamsBotComponent extends BotComponent {
type: OnTeamsChannelRestored,
},
{ kind: OnTeamsFileConsent.$kind, type: OnTeamsFileConsent },
{ kind: OnTeamsMeetingStart.$kind, type: OnTeamsMeetingStart },
{ kind: OnTeamsMeetingEnd.$kind, type: OnTeamsMeetingEnd },
{
kind: OnTeamsMEBotMessagePreviewEdit.$kind,
type: OnTeamsMEBotMessagePreviewEdit,
Expand Down
2 changes: 2 additions & 0 deletions packages/Teams/js/src/conditions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export * from './onTeamsChannelDeleted';
export * from './onTeamsChannelRenamed';
export * from './onTeamsChannelRestored';
export * from './onTeamsFileConsent';
export * from './onTeamsMeetingStart';
export * from './onTeamsMeetingEnd';
export * from './onTeamsMEBotMessagePreviewEdit';
export * from './onTeamsMEBotMessagePreviewSend';
export * from './onTeamsMECardButtonClicked';
Expand Down
29 changes: 29 additions & 0 deletions packages/Teams/js/src/conditions/onTeamsMeetingEnd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { Expression } from 'adaptive-expressions';
import { Channels } from 'botbuilder';
import { TurnPath } from 'botbuilder-dialogs';
import { OnEventActivity } from 'botbuilder-dialogs-adaptive';

/**
* Actions triggered when a Teams Meeting End event is received.
* Note: turn.activity.value has meeting data.
*/
export class OnTeamsMeetingEnd extends OnEventActivity {
static $kind = 'Teams.OnMeetingEnd';

/**
* Create expression for this condition.
*
* @returns {Expression} An [Expression](xref:adaptive-expressions.Expression) used to evaluate this rule.
*/
protected createExpression(): Expression {
return Expression.andExpression(
Expression.parse(
`${TurnPath.activity}.channelId == '${Channels.Msteams}' && ${TurnPath.activity}.name == 'application/vnd.microsoft.meetingEnd'`
),
super.createExpression()
);
}
}
29 changes: 29 additions & 0 deletions packages/Teams/js/src/conditions/onTeamsMeetingStart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { Expression } from 'adaptive-expressions';
import { Channels } from 'botbuilder';
import { TurnPath } from 'botbuilder-dialogs';
import { OnEventActivity } from 'botbuilder-dialogs-adaptive';

/**
* Actions triggered when a Teams Meeting Start event is received.
* Note: turn.activity.value has meeting data.
*/
export class OnTeamsMeetingStart extends OnEventActivity {
static $kind = 'Teams.OnMeetingStart';

/**
* Create expression for this condition.
*
* @returns {Expression} An [Expression](xref:adaptive-expressions.Expression) used to evaluate this rule.
*/
protected createExpression(): Expression {
return Expression.andExpression(
Expression.parse(
`${TurnPath.activity}.channelId == '${Channels.Msteams}' && ${TurnPath.activity}.name == 'application/vnd.microsoft.meetingStart'`
),
super.createExpression()
);
}
}
4 changes: 3 additions & 1 deletion packages/Teams/js/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { AdaptiveTeamsBotComponent } from './adaptiveTeamsBotComponent';

/**
* @module @microsoft/bot-components-teams
*/

export * from './actions';
export * from './adaptiveTeamsBotComponent';
export { AdaptiveTeamsBotComponent };
export * from './conditions';
export default AdaptiveTeamsBotComponent;