AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(microsoft-teams): let AI agents work with teams, channels, chats and messages (#17051)
Kishan Parmardb1e9674a8cf
diff --git a/bun.lock b/bun.lockindex 44d12afa603..a7897b93c54 100644--- a/bun.lock+++ b/bun.lock@@ -6104,7 +6104,7 @@},"packages/pieces/community/microsoft-teams": {"name": "@activepieces/piece-microsoft-teams",- "version": "0.7.4",+ "version": "0.8.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",diff --git a/packages/pieces/community/microsoft-teams/package.json b/packages/pieces/community/microsoft-teams/package.jsonindex 73a4580d847..578aba4d99a 100644--- a/packages/pieces/community/microsoft-teams/package.json+++ b/packages/pieces/community/microsoft-teams/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-microsoft-teams",- "version": "0.7.4",+ "version": "0.8.0","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","dependencies": {diff --git a/packages/pieces/community/microsoft-teams/src/index.ts b/packages/pieces/community/microsoft-teams/src/index.tsindex 13402ceb9a4..4914779807e 100644--- a/packages/pieces/community/microsoft-teams/src/index.ts+++ b/packages/pieces/community/microsoft-teams/src/index.ts@@ -1,12 +1,8 @@import { createCustomApiCallAction } from '@activepieces/pieces-common';-import { getGraphBaseUrl } from './lib/common/microsoft-cloud';-import {- createPiece,- OAuth2PropertyValue,-} from '@activepieces/pieces-framework';-import { PieceCategory } from '@activepieces/pieces-framework';+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';import { createChannelAction } from './lib/actions/create-channel';import { createChatAndSendMessageAction } from './lib/actions/create-chat-and-send-message';+import { microsoftTeamsAiActions } from './lib/actions/ai';import { createPrivateChannelAction } from './lib/actions/create-private-channel';import { deleteChatMessageAction } from './lib/actions/delete-chat-message';import { findChannelAction } from './lib/actions/find-channel';@@ -21,6 +17,7 @@ import { requestApprovalDirectMessage } from './lib/actions/request-approval-dirimport { sendChannelMessageAction } from './lib/actions/send-channel-message';import { sendChatMessageAction } from './lib/actions/send-chat-message';import { microsoftTeamsAuth } from './lib/auth';+import { microsoftTeamsClient } from './lib/common/client';import { newChannelTrigger } from './lib/triggers/new-channel';import { newChannelMessageTrigger } from './lib/triggers/new-channel-message';import { newChatTrigger } from './lib/triggers/new-chat';@@ -29,7 +26,7 @@ import { newChatMessageTrigger } from './lib/triggers/new-chat-message';export const microsoftTeams = createPiece({displayName: 'Microsoft Teams',auth: microsoftTeamsAuth,- minimumSupportedRelease: '0.87.0',+ minimumSupportedRelease: '0.88.2',logoUrl: 'https://cdn.activepieces.com/pieces/microsoft-teams.png',categories: [PieceCategory.BUSINESS_INTELLIGENCE,@@ -52,14 +49,12 @@ export const microsoftTeams = createPiece({getMeetingRecordingAction,requestApprovalInChannel,requestApprovalDirectMessage,+ ...microsoftTeamsAiActions,createCustomApiCallAction({auth: microsoftTeamsAuth,- baseUrl: (auth) => {- const cloud = (auth as OAuth2PropertyValue).props?.['cloud'] as string | undefined;- return getGraphBaseUrl(cloud) + '/v1.0/teams';- },+ baseUrl: (auth) => (auth ? microsoftTeamsClient.baseUrl({ auth }) : ''),authMapping: async (auth) => ({- Authorization: `Bearer ${(auth as OAuth2PropertyValue).access_token}`,+ Authorization: `Bearer ${auth.access_token}`,}),}),],diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/get-channel-message-by-id.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/get-channel-message-by-id.tsnew file mode 100644index 00000000000..773b2616e65--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/get-channel-message-by-id.ts@@ -0,0 +1,42 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetChannelMessageByIdOutputSchema } from '../../../output-schemas';++export const getChannelMessageById = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_channel_message_by_id',+ outputSchema: microsoftTeamsGetChannelMessageByIdOutputSchema,+ displayName: 'Get Channel Message by ID',+ description: 'Gets one channel message, or one reply in its thread.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one top-level channel message by ID, or one reply in its thread when Reply ID is set. Message IDs come from List Channel Messages and reply IDs from List Channel Message Replies; team IDs from List Joined Teams and channel IDs from List Channels.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelId: microsoftTeamsAiProps.channelId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The top-level message ID, from List Channel Messages.',+ required: true,+ }),+ replyId: Property.ShortText({+ displayName: 'Reply ID',+ description: 'A reply ID under that message, from List Channel Message Replies. Leave empty to get the message itself.',+ required: false,+ }),+ },+ async run(context) {+ const { teamId, channelId, messageId, replyId } = context.propsValue;+ const base = `/teams/${teamId}/channels/${channelId}/messages/${messageId}`;+ const path = replyId ? `${base}/replies/${replyId}` : base;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api(path).get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/get-channel-message-hosted-content.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/get-channel-message-hosted-content.tsnew file mode 100644index 00000000000..a8fe1f26bf7--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/get-channel-message-hosted-content.ts@@ -0,0 +1,50 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetChannelMessageHostedContentOutputSchema } from '../../../output-schemas';++export const getChannelMessageHostedContent = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_channel_message_hosted_content',+ outputSchema: microsoftTeamsGetChannelMessageHostedContentOutputSchema,+ displayName: 'Get Channel Message Hosted Content',+ description: 'Downloads one hosted content (such as an inline image) of a channel message or reply as base64.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Downloads the bytes of one hosted content (inline image, code snippet) of a channel message, or of one reply when Reply ID is set, as base64. Hosted content IDs come from List Channel Message Hosted Contents, called with the same message and reply IDs.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelId: microsoftTeamsAiProps.channelId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The top-level message ID, from List Channel Messages.',+ required: true,+ }),+ replyId: Property.ShortText({+ displayName: 'Reply ID',+ description: 'A reply ID under that message, from List Channel Message Replies. Leave empty for the message itself.',+ required: false,+ }),+ hostedContentId: Property.ShortText({+ displayName: 'Hosted Content ID',+ description: 'The hosted content ID, from List Channel Message Hosted Contents.',+ required: true,+ }),+ },+ async run(context) {+ const { teamId, channelId, messageId, replyId, hostedContentId } = context.propsValue;+ const base = `/teams/${teamId}/channels/${channelId}/messages/${messageId}`;+ const message = replyId ? `${base}/replies/${replyId}` : base;+ const contentBase64 = await microsoftTeamsClient.getBase64({+ auth: context.auth,+ path: `${message}/hostedContents/${hostedContentId}/$value`,+ });+ return { id: hostedContentId, contentBase64 };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/list-channel-message-hosted-contents.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/list-channel-message-hosted-contents.tsnew file mode 100644index 00000000000..91df661857d--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/list-channel-message-hosted-contents.ts@@ -0,0 +1,41 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListChannelMessageHostedContentsOutputSchema } from '../../../output-schemas';++export const listChannelMessageHostedContents = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_channel_message_hosted_contents',+ outputSchema: microsoftTeamsListChannelMessageHostedContentsOutputSchema,+ displayName: 'List Channel Message Hosted Contents',+ description: 'Lists the inline images and other hosted content of a channel message or reply.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the hosted contents (inline images, code snippets) of one channel message, or of one reply when Reply ID is set; read the bytes of one with Get Channel Message Hosted Content. Message IDs come from List Channel Messages and reply IDs from List Channel Message Replies.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelId: microsoftTeamsAiProps.channelId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The top-level message ID, from List Channel Messages.',+ required: true,+ }),+ replyId: Property.ShortText({+ displayName: 'Reply ID',+ description: 'A reply ID under that message, from List Channel Message Replies. Leave empty for the message itself.',+ required: false,+ }),+ },+ async run(context) {+ const { teamId, channelId, messageId, replyId } = context.propsValue;+ const base = `/teams/${teamId}/channels/${channelId}/messages/${messageId}`;+ const message = replyId ? `${base}/replies/${replyId}` : base;+ return await microsoftTeamsClient.list({ auth: context.auth, path: `${message}/hostedContents` });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/list-channel-message-replies.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/list-channel-message-replies.tsnew file mode 100644index 00000000000..7483098b15a--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/list-channel-message-replies.ts@@ -0,0 +1,44 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListChannelMessageRepliesOutputSchema } from '../../../output-schemas';++const MAX_LIMIT = 50;+const DEFAULT_LIMIT = 20;++export const listChannelMessageReplies = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_channel_message_replies',+ outputSchema: microsoftTeamsListChannelMessageRepliesOutputSchema,+ displayName: 'List Channel Message Replies',+ description: 'Lists the replies in the thread of a channel message, one page at a time.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the replies in the thread of one top-level channel message, one page at a time; pass @odata.nextLink back as Next Page Link for the next page. Message IDs come from List Channel Messages; team IDs from List Joined Teams and channel IDs from List Channels.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelId: microsoftTeamsAiProps.channelId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The top-level message ID, from List Channel Messages.',+ required: true,+ }),+ limit: microsoftTeamsAiProps.limit({ max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT }),+ nextLink: microsoftTeamsAiProps.nextLink(),+ },+ async run(context) {+ const { teamId, channelId, messageId, limit, nextLink } = context.propsValue;+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: `/teams/${teamId}/channels/${channelId}/messages/${messageId}/replies`,+ page: { limit, max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT },+ nextLink,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/list-channel-messages.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/list-channel-messages.tsnew file mode 100644index 00000000000..cd41c85ed08--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/list-channel-messages.ts@@ -0,0 +1,39 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListChannelMessagesOutputSchema } from '../../../output-schemas';++const MAX_LIMIT = 50;+const DEFAULT_LIMIT = 20;++export const listChannelMessages = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_channel_messages',+ outputSchema: microsoftTeamsListChannelMessagesOutputSchema,+ displayName: 'List Channel Messages',+ description: 'Lists the top-level messages in a channel, one page at a time.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the top-level messages of one channel, newest first, without their replies, one page at a time; pass @odata.nextLink back as Next Page Link for the next page. Team IDs come from List Joined Teams and channel IDs from List Channels; use List Channel Message Replies for a thread.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelId: microsoftTeamsAiProps.channelId({ required: true }),+ limit: microsoftTeamsAiProps.limit({ max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT }),+ nextLink: microsoftTeamsAiProps.nextLink(),+ },+ async run(context) {+ const { teamId, channelId, limit, nextLink } = context.propsValue;+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: `/teams/${teamId}/channels/${channelId}/messages`,+ page: { limit, max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT },+ nextLink,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/post-channel-message-reply.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/post-channel-message-reply.tsnew file mode 100644index 00000000000..ce06415374d--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/post-channel-message-reply.ts@@ -0,0 +1,45 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsUtils } from '../../../common/utils';+import { microsoftTeamsGetChannelMessageOutputSchema } from '../../../output-schemas';++export const postChannelMessageReply = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_post_channel_message_reply',+ outputSchema: microsoftTeamsGetChannelMessageOutputSchema,+ displayName: 'Post Channel Message Reply',+ description: 'Posts a reply in the thread of a channel message.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Posts a reply in the thread of an existing top-level channel message; use Post Channel Message to start a new thread. Message IDs come from List Channel Messages or Post Channel Message. To @mention users, set Content Type to html, add each user to Mentions (user ID from List Team Members or List Users) and write mention N as <at id="N">displayName</at> in Content, N being its index in Mentions starting at 0; the action rejects mentions with text content or a missing tag. Team IDs come from List Joined Teams and channel IDs from List Channels.',+ idempotent: false,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelId: microsoftTeamsAiProps.channelId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The ID of the top-level message to reply to, from List Channel Messages or Post Channel Message.',+ required: true,+ }),+ content: Property.LongText({+ displayName: 'Content',+ description:+ 'The message body. With mentions, use html and write mention N as <at id="N">displayName</at>, N being its index in Mentions starting at 0.',+ required: true,+ }),+ contentType: microsoftTeamsAiProps.contentType(),+ mentions: microsoftTeamsAiProps.mentions(),+ },+ async run(context) {+ const { teamId, channelId, messageId, content, contentType, mentions } = context.propsValue;+ const body = microsoftTeamsUtils.buildMessageBody({ content, contentType, mentions: mentions ?? [] });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await client.api(`/teams/${teamId}/channels/${channelId}/messages/${messageId}/replies`).post(body);+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/post-channel-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/post-channel-message.tsnew file mode 100644index 00000000000..3abf25cd3e3--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/post-channel-message.ts@@ -0,0 +1,45 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsUtils } from '../../../common/utils';+import { microsoftTeamsGetChannelMessageByIdOutputSchema } from '../../../output-schemas';++export const postChannelMessage = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_post_channel_message',+ outputSchema: microsoftTeamsGetChannelMessageByIdOutputSchema,+ displayName: 'Post Channel Message',+ description: 'Posts a new top-level message to a channel.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Posts a new top-level message to a channel; use Post Channel Message Reply to answer an existing thread. To @mention users, set Content Type to html, add each user to Mentions (user ID from List Team Members or List Users) and write mention N as <at id="N">displayName</at> in Content, N being its index in Mentions starting at 0; the action rejects mentions with text content or a missing tag. Team IDs come from List Joined Teams and channel IDs from List Channels.',+ idempotent: false,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelId: microsoftTeamsAiProps.channelId({ required: true }),+ content: Property.LongText({+ displayName: 'Content',+ description:+ 'The message body. With mentions, use html and write mention N as <at id="N">displayName</at>, N being its index in Mentions starting at 0.',+ required: true,+ }),+ contentType: microsoftTeamsAiProps.contentType(),+ subject: Property.ShortText({+ displayName: 'Subject',+ description: 'An optional subject line shown above the message.',+ required: false,+ }),+ mentions: microsoftTeamsAiProps.mentions(),+ },+ async run(context) {+ const { teamId, channelId, content, contentType, subject, mentions } = context.propsValue;+ const body = microsoftTeamsUtils.buildMessageBody({ content, contentType, subject, mentions: mentions ?? [] });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await client.api(`/teams/${teamId}/channels/${channelId}/messages`).post(body);+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/set-channel-message-reaction.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/set-channel-message-reaction.tsnew file mode 100644index 00000000000..b9c8a6d369d--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/set-channel-message-reaction.ts@@ -0,0 +1,48 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsSetChannelMessageReactionOutputSchema } from '../../../output-schemas';++export const setChannelMessageReaction = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_set_channel_message_reaction',+ outputSchema: microsoftTeamsSetChannelMessageReactionOutputSchema,+ displayName: 'Set Channel Message Reaction',+ description: 'Adds a reaction from the signed-in user to a channel message or reply.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Adds the signed-in user\'s reaction, given as a unicode emoji, to a channel message, or to one reply when Reply ID is set; remove it with Unset Channel Message Reaction. Message IDs come from List Channel Messages and reply IDs from List Channel Message Replies.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelId: microsoftTeamsAiProps.channelId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The top-level message ID, from List Channel Messages.',+ required: true,+ }),+ replyId: Property.ShortText({+ displayName: 'Reply ID',+ description: 'A reply ID under that message, from List Channel Message Replies. Leave empty to react to the message itself.',+ required: false,+ }),+ reactionType: Property.ShortText({+ displayName: 'Reaction',+ description: 'The reaction as a unicode emoji, for example 👍 or ❤️.',+ required: true,+ }),+ },+ async run(context) {+ const { teamId, channelId, messageId, replyId, reactionType } = context.propsValue;+ const base = `/teams/${teamId}/channels/${channelId}/messages/${messageId}`;+ const message = replyId ? `${base}/replies/${replyId}` : base;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`${message}/setReaction`).post({ reactionType });+ return { success: true, reactionType };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/unset-channel-message-reaction.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/unset-channel-message-reaction.tsnew file mode 100644index 00000000000..634e2a6d436--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channel-messages/unset-channel-message-reaction.ts@@ -0,0 +1,48 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsSetChannelMessageReactionOutputSchema } from '../../../output-schemas';++export const unsetChannelMessageReaction = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_unset_channel_message_reaction',+ outputSchema: microsoftTeamsSetChannelMessageReactionOutputSchema,+ displayName: 'Unset Channel Message Reaction',+ description: 'Removes a reaction of the signed-in user from a channel message or reply.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Removes the signed-in user\'s reaction, given as the same unicode emoji it was set with, from a channel message, or from one reply when Reply ID is set; add one with Set Channel Message Reaction. Message IDs come from List Channel Messages and reply IDs from List Channel Message Replies.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelId: microsoftTeamsAiProps.channelId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The top-level message ID, from List Channel Messages.',+ required: true,+ }),+ replyId: Property.ShortText({+ displayName: 'Reply ID',+ description: 'A reply ID under that message, from List Channel Message Replies. Leave empty for the message itself.',+ required: false,+ }),+ reactionType: Property.ShortText({+ displayName: 'Reaction',+ description: 'The reaction to remove, as a unicode emoji, for example 👍.',+ required: true,+ }),+ },+ async run(context) {+ const { teamId, channelId, messageId, replyId, reactionType } = context.propsValue;+ const base = `/teams/${teamId}/channels/${channelId}/messages/${messageId}`;+ const message = replyId ? `${base}/replies/${replyId}` : base;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`${message}/unsetReaction`).post({ reactionType });+ return { success: true, reactionType };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/create-team-channel.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/create-team-channel.tsnew file mode 100644index 00000000000..cf7df956cd5--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/create-team-channel.ts@@ -0,0 +1,54 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsCreateChannelOutputSchema } from '../../../output-schemas';++const MEMBERSHIP_TYPES: string[] = ['standard', 'private'];++export const createTeamChannel = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_create_team_channel',+ outputSchema: microsoftTeamsCreateChannelOutputSchema,+ displayName: 'Create Team Channel',+ description: 'Creates a standard or private channel in a team.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Creates a standard or private channel in one team; shared channels are not supported. Team IDs come from List Joined Teams. Not idempotent: each call adds another channel, so check List Channels first for the name.',+ idempotent: false,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ displayName: Property.ShortText({+ displayName: 'Channel Name',+ description: 'The channel name, up to 50 characters.',+ required: true,+ }),+ description: Property.LongText({+ displayName: 'Description',+ required: false,+ }),+ membershipType: Property.StaticDropdown({+ displayName: 'Membership Type',+ description: 'standard (every team member) or private (only invited members). Defaults to standard.',+ required: false,+ options: {+ options: [+ { label: 'Standard', value: 'standard' },+ { label: 'Private', value: 'private' },+ ],+ },+ }),+ },+ async run(context) {+ const { teamId, displayName, description, membershipType } = context.propsValue;+ if (membershipType !== undefined && !MEMBERSHIP_TYPES.includes(membershipType)) {+ throw new Error(`Membership Type must be one of ${MEMBERSHIP_TYPES.join(', ')}, got '${membershipType}'.`);+ }+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await client.api(`/teams/${teamId}/channels`).post({ displayName, description, membershipType });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/get-channel.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/get-channel.tsnew file mode 100644index 00000000000..a24d3837292--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/get-channel.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetChannelOutputSchema } from '../../../output-schemas';++export const getChannel = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_channel',+ outputSchema: microsoftTeamsGetChannelOutputSchema,+ displayName: 'Get Channel',+ description: 'Gets one channel of a team by its ID.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one channel of a team by its ID, with its name, description, membership type and web URL. Team IDs come from List Joined Teams and channel IDs from List Channels or List All Channels.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelId: microsoftTeamsAiProps.channelId({ required: true }),+ },+ async run(context) {+ const { teamId, channelId } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api(`/teams/${teamId}/channels/${channelId}`).get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/get-primary-channel.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/get-primary-channel.tsnew file mode 100644index 00000000000..02abf7fb674--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/get-primary-channel.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsCreatePrivateChannelOutputSchema } from '../../../output-schemas';++export const getPrimaryChannel = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_primary_channel',+ outputSchema: microsoftTeamsCreatePrivateChannelOutputSchema,+ displayName: 'Get Primary Channel',+ description: 'Gets the General channel of a team.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ "Gets a team's default General channel, including its channel ID, without listing every channel. Team IDs come from List Joined Teams.",+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ },+ async run(context) {+ const { teamId } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api(`/teams/${teamId}/primaryChannel`).get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/list-all-channels.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/list-all-channels.tsnew file mode 100644index 00000000000..7b93f8d710f--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/list-all-channels.ts@@ -0,0 +1,37 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListAllChannelsOutputSchema } from '../../../output-schemas';++export const listAllChannels = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_all_channels',+ outputSchema: microsoftTeamsListAllChannelsOutputSchema,+ displayName: 'List All Channels',+ description: 'Lists the channels of a team, including channels shared into it.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the channels hosted in one team plus the channels shared into it from other teams, optionally only those whose name matches Channel Name exactly; use it to resolve a channel name to its ID. Team IDs come from List Joined Teams; use List Incoming Channels for only the shared-in channels.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ channelName: Property.ShortText({+ displayName: 'Channel Name',+ description: 'Return only channels whose display name is exactly this. Leave empty for every channel.',+ required: false,+ }),+ },+ async run(context) {+ const { teamId, channelName } = context.propsValue;+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: `/teams/${teamId}/allChannels`,+ filter: channelName === undefined ? undefined : `displayName eq '${channelName.replace(/'/g, "''")}'`,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/list-channels.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/list-channels.tsnew file mode 100644index 00000000000..c9cb29786eb--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/list-channels.ts@@ -0,0 +1,33 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListChannelsOutputSchema } from '../../../output-schemas';++export const listChannels = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_channels',+ outputSchema: microsoftTeamsListChannelsOutputSchema,+ displayName: 'List Channels',+ description: 'Lists the channels of a team.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the channels the signed-in user can see in one team, with each channel ID and membership type. Team IDs come from List Joined Teams. Use List All Channels to also include channels shared into the team.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ filter: Property.ShortText({+ displayName: 'Filter',+ description: "An OData $filter on channel properties, for example membershipType eq 'private'.",+ required: false,+ }),+ },+ async run(context) {+ const { teamId, filter } = context.propsValue;+ return await microsoftTeamsClient.list({ auth: context.auth, path: `/teams/${teamId}/channels`, filter });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/list-incoming-channels.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/list-incoming-channels.tsnew file mode 100644index 00000000000..1423c58f24d--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/channels/list-incoming-channels.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListIncomingChannelsOutputSchema } from '../../../output-schemas';++export const listIncomingChannels = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_incoming_channels',+ outputSchema: microsoftTeamsListIncomingChannelsOutputSchema,+ displayName: 'List Incoming Channels',+ description: 'Lists the channels shared into a team from other teams.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ "Lists only the shared channels that other teams have shared into one team, not the team's own channels. Team IDs come from List Joined Teams; use List All Channels for the team's own and shared-in channels together.",+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ },+ async run(context) {+ const { teamId } = context.propsValue;+ return await microsoftTeamsClient.list({ auth: context.auth, path: `/teams/${teamId}/incomingChannels` });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/get-chat-message-by-id.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/get-chat-message-by-id.tsnew file mode 100644index 00000000000..1d6c73d6587--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/get-chat-message-by-id.ts@@ -0,0 +1,34 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetChatMessageByIdOutputSchema } from '../../../output-schemas';++export const getChatMessageById = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_chat_message_by_id',+ outputSchema: microsoftTeamsGetChatMessageByIdOutputSchema,+ displayName: 'Get Chat Message by ID',+ description: 'Gets one message in a chat by its ID.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one chat message by chat ID and message ID, with its body, sender, mentions, reactions, attachments and edit or delete state. Chat IDs come from List Chats; message IDs from List Chat Messages or Post Chat Message.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The message ID, from List Chat Messages or Post Chat Message.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, messageId } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api(`/chats/${chatId}/messages/${messageId}`).get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/get-chat-message-hosted-content.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/get-chat-message-hosted-content.tsnew file mode 100644index 00000000000..b5859d87da4--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/get-chat-message-hosted-content.ts@@ -0,0 +1,42 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetChatMessageHostedContentOutputSchema } from '../../../output-schemas';++export const getChatMessageHostedContent = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_chat_message_hosted_content',+ outputSchema: microsoftTeamsGetChatMessageHostedContentOutputSchema,+ displayName: 'Get Chat Message Hosted Content',+ description: 'Downloads one hosted content of a chat message as base64.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Downloads the bytes of one hosted content (an inline image or code snippet) of a chat message, base64-encoded. Chat IDs come from List Chats; message IDs from List Chat Messages; hosted content IDs from List Chat Message Hosted Contents.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The message ID, from List Chat Messages or Get Chat Message by ID.',+ required: true,+ }),+ hostedContentId: Property.ShortText({+ displayName: 'Hosted Content ID',+ description: 'The hosted content ID, from List Chat Message Hosted Contents.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, messageId, hostedContentId } = context.propsValue;+ const contentBase64 = await microsoftTeamsClient.getBase64({+ auth: context.auth,+ path: `/chats/${chatId}/messages/${messageId}/hostedContents/${hostedContentId}/$value`,+ });+ return { id: hostedContentId, chatId, messageId, contentBase64 };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/list-chat-message-hosted-contents.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/list-chat-message-hosted-contents.tsnew file mode 100644index 00000000000..62d2d87c6c6--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/list-chat-message-hosted-contents.ts@@ -0,0 +1,36 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListChannelMessageHostedContentsOutputSchema } from '../../../output-schemas';++export const listChatMessageHostedContents = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_chat_message_hosted_contents',+ outputSchema: microsoftTeamsListChannelMessageHostedContentsOutputSchema,+ displayName: 'List Chat Message Hosted Contents',+ description: 'Lists the images and code snippets hosted inside a chat message.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the hosted contents (inline images, code snippets) of one chat message, without their bytes; read the bytes with Get Chat Message Hosted Content. Chat IDs come from List Chats; message IDs from List Chat Messages.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The message ID, from List Chat Messages or Get Chat Message by ID.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, messageId } = context.propsValue;+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: `/chats/${chatId}/messages/${messageId}/hostedContents`,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/list-chat-messages.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/list-chat-messages.tsnew file mode 100644index 00000000000..3cd97966b2a--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/list-chat-messages.ts@@ -0,0 +1,38 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListChatMessagesOutputSchema } from '../../../output-schemas';++const MAX_LIMIT = 50;+const DEFAULT_LIMIT = 20;++export const listChatMessages = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_chat_messages',+ outputSchema: microsoftTeamsListChatMessagesOutputSchema,+ displayName: 'List Chat Messages',+ description: 'Lists the messages in a chat, one page at a time.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the messages of one chat, most recently modified first, one page at a time; pass @odata.nextLink back as Next Page Link for the next page. Chat IDs come from List Chats.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ limit: microsoftTeamsAiProps.limit({ max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT }),+ nextLink: microsoftTeamsAiProps.nextLink(),+ },+ async run(context) {+ const { chatId, limit, nextLink } = context.propsValue;+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: `/chats/${chatId}/messages`,+ page: { limit, max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT },+ nextLink,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/post-chat-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/post-chat-message.tsnew file mode 100644index 00000000000..f495409f850--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/post-chat-message.ts@@ -0,0 +1,38 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsUtils } from '../../../common/utils';+import { microsoftTeamsGetChatMessageByIdOutputSchema } from '../../../output-schemas';++export const postChatMessage = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_post_chat_message',+ outputSchema: microsoftTeamsGetChatMessageByIdOutputSchema,+ displayName: 'Post Chat Message',+ description: 'Sends a message in an existing chat, optionally mentioning people.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Sends a new message into an existing one-on-one, group or meeting chat as text or HTML; each call posts another message. To mention someone, use HTML and write <at id="N">displayName</at> in Content for the mention at index N. Chat IDs come from List Chats; user IDs from List Users.',+ idempotent: false,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ content: Property.LongText({+ displayName: 'Content',+ description: 'The message body, as plain text or HTML depending on Content Type.',+ required: true,+ }),+ contentType: microsoftTeamsAiProps.contentType(),+ mentions: microsoftTeamsAiProps.mentions(),+ },+ async run(context) {+ const { chatId, content, contentType, mentions } = context.propsValue;+ const body = microsoftTeamsUtils.buildMessageBody({ content, contentType, mentions: mentions ?? [] });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await client.api(`/chats/${chatId}/messages`).post(body);+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/set-chat-message-reaction.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/set-chat-message-reaction.tsnew file mode 100644index 00000000000..684b8755d01--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/set-chat-message-reaction.ts@@ -0,0 +1,40 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsSetChatMessageReactionOutputSchema } from '../../../output-schemas';++export const setChatMessageReaction = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_set_chat_message_reaction',+ outputSchema: microsoftTeamsSetChatMessageReactionOutputSchema,+ displayName: 'Set Chat Message Reaction',+ description: "Adds the signed-in user's reaction to a chat message.",+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ "Adds the signed-in user's emoji reaction to a chat message; remove it with Unset Chat Message Reaction. Chat IDs come from List Chats; message IDs from List Chat Messages or Post Chat Message.",+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The message ID, from List Chat Messages or Post Chat Message.',+ required: true,+ }),+ reactionType: Property.ShortText({+ displayName: 'Reaction',+ description: 'The reaction as a unicode emoji, for example 👍, ❤️ or 😆.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, messageId, reactionType } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/chats/${chatId}/messages/${messageId}/setReaction`).post({ reactionType });+ return { reactionSet: true, chatId, messageId, reactionType };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/soft-delete-chat-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/soft-delete-chat-message.tsnew file mode 100644index 00000000000..f1c203704af--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/soft-delete-chat-message.ts@@ -0,0 +1,36 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsSoftDeleteChatMessageOutputSchema } from '../../../output-schemas';++export const softDeleteChatMessage = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_soft_delete_chat_message',+ outputSchema: microsoftTeamsSoftDeleteChatMessageOutputSchema,+ displayName: 'Soft Delete Chat Message',+ description: 'Deletes a chat message you sent; it can be restored.',+ audience: 'ai',+ classification: 'DESTRUCTIVE',+ aiMetadata: {+ description:+ 'Soft-deletes a chat message the signed-in user sent; it stays recoverable with Undo Soft Delete Chat Message. Chat IDs come from List Chats; message IDs from List Chat Messages or Post Chat Message.',+ idempotent: false,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The ID of a message the signed-in user sent, from List Chat Messages or Post Chat Message.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, messageId } = context.propsValue;+ const { id: userId } = await microsoftTeamsClient.signedInUser({ auth: context.auth });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/users/${userId}/chats/${chatId}/messages/${messageId}/softDelete`).post({});+ return { softDeleted: true, chatId, messageId };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/undo-soft-delete-chat-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/undo-soft-delete-chat-message.tsnew file mode 100644index 00000000000..36bba0970da--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/undo-soft-delete-chat-message.ts@@ -0,0 +1,36 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsUndoSoftDeleteChatMessageOutputSchema } from '../../../output-schemas';++export const undoSoftDeleteChatMessage = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_undo_soft_delete_chat_message',+ outputSchema: microsoftTeamsUndoSoftDeleteChatMessageOutputSchema,+ displayName: 'Undo Soft Delete Chat Message',+ description: 'Restores a chat message you soft-deleted.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Restores a chat message the signed-in user removed with Soft Delete Chat Message. Chat IDs come from List Chats; message IDs from List Chat Messages.',+ idempotent: false,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The ID of the soft-deleted message, from List Chat Messages or Soft Delete Chat Message.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, messageId } = context.propsValue;+ const { id: userId } = await microsoftTeamsClient.signedInUser({ auth: context.auth });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/users/${userId}/chats/${chatId}/messages/${messageId}/undoSoftDelete`).post({});+ return { restored: true, chatId, messageId };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/unset-chat-message-reaction.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/unset-chat-message-reaction.tsnew file mode 100644index 00000000000..e4e7f6ef9b8--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/unset-chat-message-reaction.ts@@ -0,0 +1,40 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsUnsetChatMessageReactionOutputSchema } from '../../../output-schemas';++export const unsetChatMessageReaction = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_unset_chat_message_reaction',+ outputSchema: microsoftTeamsUnsetChatMessageReactionOutputSchema,+ displayName: 'Unset Chat Message Reaction',+ description: "Removes the signed-in user's reaction from a chat message.",+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ "Removes an emoji reaction the signed-in user added to a chat message, for example with Set Chat Message Reaction. Chat IDs come from List Chats; message IDs from List Chat Messages or Post Chat Message.",+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The message ID, from List Chat Messages or Post Chat Message.',+ required: true,+ }),+ reactionType: Property.ShortText({+ displayName: 'Reaction',+ description: 'The reaction as a unicode emoji, for example 👍, ❤️ or 😆.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, messageId, reactionType } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/chats/${chatId}/messages/${messageId}/unsetReaction`).post({ reactionType });+ return { reactionRemoved: true, chatId, messageId, reactionType };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/update-chat-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/update-chat-message.tsnew file mode 100644index 00000000000..50213d2d5fa--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chat-messages/update-chat-message.ts@@ -0,0 +1,54 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsUtils } from '../../../common/utils';+import { microsoftTeamsUpdateChatMessageOutputSchema } from '../../../output-schemas';++export const updateChatMessage = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_update_chat_message',+ outputSchema: microsoftTeamsUpdateChatMessageOutputSchema,+ displayName: 'Update Chat Message',+ description: 'Replaces the body of a chat message you sent.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Replaces the whole body of a chat message with new content; only messages the signed-in user sent can be edited. Chat IDs come from List Chats; message IDs from List Chat Messages or Post Chat Message.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The ID of a message the signed-in user sent, from List Chat Messages or Post Chat Message.',+ required: true,+ }),+ content: Property.LongText({+ displayName: 'Content',+ description: 'The new message body, replacing the old one, as plain text or HTML depending on Content Type.',+ required: true,+ }),+ contentType: Property.StaticDropdown({+ displayName: 'Content Type',+ description: 'text or html.',+ required: true,+ defaultValue: 'text',+ options: {+ disabled: false,+ options: [+ { label: 'Text', value: 'text' },+ { label: 'HTML', value: 'html' },+ ],+ },+ }),+ },+ async run(context) {+ const { chatId, messageId, content, contentType } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/chats/${chatId}/messages/${messageId}`).patch(microsoftTeamsUtils.buildMessageBody({ content, contentType, mentions: [] }));+ return { updated: true, chatId, messageId };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/add-chat-member.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/add-chat-member.tsnew file mode 100644index 00000000000..301ed6fd5c9--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/add-chat-member.ts@@ -0,0 +1,61 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsHideChatOutputSchema } from '../../../output-schemas';++const ROLES = ['owner', 'guest'];++export const addChatMember = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_add_chat_member',+ displayName: 'Add Chat Member',+ description: 'Adds a user to a group chat.',+ audience: 'ai',+ outputSchema: microsoftTeamsHideChatOutputSchema,+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Adds a user (user ID from List Users) to a group chat (chat ID from List Chats), optionally sharing chat history from a given time. Group chats only; one-on-one and meeting chats are rejected. Use List Chat Members afterwards for the new membership ID.',+ idempotent: false,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ userId: microsoftTeamsAiProps.userId({ required: true }),+ role: Property.StaticDropdown({+ displayName: 'Role',+ description: 'owner for members and out-of-tenant external users, guest for in-tenant guest users. Defaults to owner.',+ required: false,+ defaultValue: 'owner',+ options: {+ disabled: false,+ options: [+ { label: 'Owner', value: 'owner' },+ { label: 'Guest', value: 'guest' },+ ],+ },+ }),+ visibleHistoryStartDateTime: Property.ShortText({+ displayName: 'Share History From',+ description: 'ISO 8601 timestamp; the new member sees messages from this time on. Use 0001-01-01T00:00:00Z for the whole history. Leave empty to share no history.',+ required: false,+ }),+ },+ async run(context) {+ const { chatId, userId, visibleHistoryStartDateTime } = context.propsValue;+ const role = context.propsValue.role ?? 'owner';+ if (!ROLES.includes(role)) {+ throw new Error(`Role must be one of: ${ROLES.join(', ')}.`);+ }+ const graphBaseUrl = microsoftTeamsClient.graphUrl({ auth: context.auth });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/chats/${chatId}/members`).post({+ '@odata.type': '#microsoft.graph.aadUserConversationMember',+ '[email protected]': `${graphBaseUrl}/v1.0/users('${userId}')`,+ roles: [role],+ ...(visibleHistoryStartDateTime ? { visibleHistoryStartDateTime } : {}),+ });+ return { success: true };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/create-chat.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/create-chat.tsnew file mode 100644index 00000000000..228c96a1fbe--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/create-chat.ts@@ -0,0 +1,75 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsCreateChatOutputSchema } from '../../../output-schemas';++const CHAT_TYPES = ['oneOnOne', 'group'];++export const createChat = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_create_chat',+ outputSchema: microsoftTeamsCreateChatOutputSchema,+ displayName: 'Create Chat',+ description: 'Creates a one-on-one or group chat with the signed-in user and other users.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Creates a chat between the signed-in user (added automatically) and other users by user ID from List Users: oneOnOne takes exactly one other user, group takes two or more and an optional topic. Creating a oneOnOne chat that already exists returns the existing chat. Send messages to it with Post Chat Message.',+ idempotent: false,+ },+ props: {+ chatType: Property.StaticDropdown({+ displayName: 'Chat Type',+ description: 'oneOnOne for a chat with exactly one other user, group for two or more other users.',+ required: true,+ options: {+ disabled: false,+ options: [+ { label: 'One-on-one', value: 'oneOnOne' },+ { label: 'Group', value: 'group' },+ ],+ },+ }),+ userIds: Property.Array({+ displayName: 'User IDs',+ description: 'The other users to add, by user ID or user principal name, from List Users. Do not include the signed-in user.',+ required: true,+ }),+ topic: Property.ShortText({+ displayName: 'Topic',+ description: 'The chat title. Group chats only; at most 250 characters, no colons.',+ required: false,+ }),+ },+ async run(context) {+ const { chatType, topic } = context.propsValue;+ const userIds = context.propsValue.userIds.map((id) => String(id));+ if (!CHAT_TYPES.includes(chatType)) {+ throw new Error(`Chat Type must be one of: ${CHAT_TYPES.join(', ')}.`);+ }+ if (chatType === 'oneOnOne' && userIds.length !== 1) {+ throw new Error('User IDs must contain exactly one user for a oneOnOne chat.');+ }+ if (chatType === 'group' && userIds.length < 2) {+ throw new Error('User IDs must contain at least two users for a group chat.');+ }+ if (chatType === 'oneOnOne' && topic) {+ throw new Error('Topic can only be set for a group chat.');+ }+ const me = await microsoftTeamsClient.signedInUser({ auth: context.auth });+ const graphBaseUrl = microsoftTeamsClient.graphUrl({ auth: context.auth });+ const members = [me.id, ...userIds].map((id) => ({+ '@odata.type': '#microsoft.graph.aadUserConversationMember',+ roles: ['owner'],+ '[email protected]': `${graphBaseUrl}/v1.0/users('${id}')`,+ }));+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await client.api('/chats').post({+ chatType,+ members,+ ...(topic ? { topic } : {}),+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/get-chat-member.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/get-chat-member.tsnew file mode 100644index 00000000000..8fc9704d67c--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/get-chat-member.ts@@ -0,0 +1,34 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetChatMemberOutputSchema } from '../../../output-schemas';++export const getChatMember = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_chat_member',+ outputSchema: microsoftTeamsGetChatMemberOutputSchema,+ displayName: 'Get Chat Member',+ description: 'Gets one membership of a chat by its membership ID.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one chat membership by chat ID (from List Chats) and membership ID (from List Chat Members), with the user ID, display name, email, roles and visible history start. Membership IDs are not user IDs.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ membershipId: Property.ShortText({+ displayName: 'Membership ID',+ description: 'The membership ID (the id field), from List Chat Members.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, membershipId } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api(`/chats/${chatId}/members/${membershipId}`).get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/get-chat.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/get-chat.tsnew file mode 100644index 00000000000..a78036b7fa7--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/get-chat.ts@@ -0,0 +1,47 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetChatOutputSchema } from '../../../output-schemas';++const EXPAND_OPTIONS = ['members', 'lastMessagePreview'];++export const getChat = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_chat',+ outputSchema: microsoftTeamsGetChatOutputSchema,+ displayName: 'Get Chat',+ description: 'Gets one chat by its ID.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one chat the signed-in user is in by its chat ID (from List Chats), with its topic, type, timestamps and web URL. Optionally include its members or a preview of its last message in the same call.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ include: Property.StaticDropdown({+ displayName: 'Include',+ description: 'Extra data to include: the chat members or a preview of the last message. Leave empty for the chat only.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Members', value: 'members' },+ { label: 'Last Message Preview', value: 'lastMessagePreview' },+ ],+ },+ }),+ },+ async run(context) {+ const { chatId, include } = context.propsValue;+ if (include && !EXPAND_OPTIONS.includes(include)) {+ throw new Error(`Include must be one of: ${EXPAND_OPTIONS.join(', ')}.`);+ }+ const client = microsoftTeamsClient.create({ auth: context.auth });+ const request = include ? client.api(`/chats/${chatId}`).expand(include) : client.api(`/chats/${chatId}`);+ return await microsoftTeamsClient.withRetry(() => request.get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/hide-chat.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/hide-chat.tsnew file mode 100644index 00000000000..5ac5cd0a049--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/hide-chat.ts@@ -0,0 +1,31 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsHideChatOutputSchema } from '../../../output-schemas';++export const hideChat = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_hide_chat',+ outputSchema: microsoftTeamsHideChatOutputSchema,+ displayName: 'Hide Chat',+ description: 'Hides a chat for the signed-in user.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ "Hides a chat (chat ID from List Chats) from the signed-in user's chat list, for the signed-in user only. Undo with Unhide Chat.",+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ },+ async run(context) {+ const { chatId } = context.propsValue;+ const user = await microsoftTeamsClient.signedInUser({ auth: context.auth });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/chats/${chatId}/hideForUser`).post({ user });+ return { success: true };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/list-chat-members.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/list-chat-members.tsnew file mode 100644index 00000000000..f96f1cc410f--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/list-chat-members.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListChatMembersOutputSchema } from '../../../output-schemas';++export const listChatMembers = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_chat_members',+ outputSchema: microsoftTeamsListChatMembersOutputSchema,+ displayName: 'List Chat Members',+ description: 'Lists the members of a chat.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists every member of a chat (chat ID from List Chats) with their membership ID, user ID, display name, email and roles. Membership IDs feed Get Chat Member; they are not user IDs.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ },+ async run(context) {+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: `/chats/${context.propsValue.chatId}/members`,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/list-chats.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/list-chats.tsnew file mode 100644index 00000000000..0add95f9cd7--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/list-chats.ts@@ -0,0 +1,37 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListChatsOutputSchema } from '../../../output-schemas';++const MAX_LIMIT = 50;+const DEFAULT_LIMIT = 20;++export const listChats = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_chats',+ outputSchema: microsoftTeamsListChatsOutputSchema,+ displayName: 'List Chats',+ description: "Lists the signed-in user's chats, one page at a time.",+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ "Lists the signed-in user's one-on-one, group and meeting chats with each chat ID, topic and type, one page at a time; pass @odata.nextLink back as Next Page Link for the next page. Use List Chat Members to see who is in a chat.",+ idempotent: true,+ },+ props: {+ limit: microsoftTeamsAiProps.limit({ max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT }),+ nextLink: microsoftTeamsAiProps.nextLink(),+ },+ async run(context) {+ const { limit, nextLink } = context.propsValue;+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: '/chats',+ page: { limit, max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT },+ nextLink,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/list-pinned-chat-messages.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/list-pinned-chat-messages.tsnew file mode 100644index 00000000000..9f34a0be053--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/list-pinned-chat-messages.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListPinnedChatMessagesOutputSchema } from '../../../output-schemas';++export const listPinnedChatMessages = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_pinned_chat_messages',+ outputSchema: microsoftTeamsListPinnedChatMessagesOutputSchema,+ displayName: 'List Pinned Chat Messages',+ description: 'Lists the pinned messages of a chat.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the pinned messages of a chat (chat ID from List Chats), each with its pinned message ID and the full message. The pinned message ID feeds Unpin Chat Message.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ },+ async run(context) {+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() =>+ client.api(`/chats/${context.propsValue.chatId}/pinnedMessages`).expand('message').get(),+ );+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/mark-chat-read.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/mark-chat-read.tsnew file mode 100644index 00000000000..63b8825d260--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/mark-chat-read.ts@@ -0,0 +1,31 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsHideChatOutputSchema } from '../../../output-schemas';++export const markChatRead = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_mark_chat_read',+ outputSchema: microsoftTeamsHideChatOutputSchema,+ displayName: 'Mark Chat Read',+ description: 'Marks a chat as read for the signed-in user.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Marks every message in a chat (chat ID from List Chats) as read for the signed-in user only. Undo with Mark Chat Unread.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ },+ async run(context) {+ const { chatId } = context.propsValue;+ const user = await microsoftTeamsClient.signedInUser({ auth: context.auth });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/chats/${chatId}/markChatReadForUser`).post({ user });+ return { success: true };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/mark-chat-unread.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/mark-chat-unread.tsnew file mode 100644index 00000000000..fb0ed27ec63--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/mark-chat-unread.ts@@ -0,0 +1,39 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsHideChatOutputSchema } from '../../../output-schemas';++export const markChatUnread = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_mark_chat_unread',+ outputSchema: microsoftTeamsHideChatOutputSchema,+ displayName: 'Mark Chat Unread',+ description: 'Marks a chat as unread for the signed-in user.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Marks a chat (chat ID from List Chats) as unread for the signed-in user only: the last message by default, or every message after Last Read Time. Undo with Mark Chat Read.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ lastMessageReadDateTime: Property.ShortText({+ displayName: 'Last Read Time',+ description: 'ISO 8601 timestamp, e.g. 2024-05-01T09:00:00Z; messages sent after it become unread. Leave empty to mark only the last message unread.',+ required: false,+ }),+ },+ async run(context) {+ const { chatId, lastMessageReadDateTime } = context.propsValue;+ const user = await microsoftTeamsClient.signedInUser({ auth: context.auth });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/chats/${chatId}/markChatUnreadForUser`).post({+ user,+ ...(lastMessageReadDateTime ? { lastMessageReadDateTime } : {}),+ });+ return { success: true };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/pin-chat-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/pin-chat-message.tsnew file mode 100644index 00000000000..9e871505911--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/pin-chat-message.ts@@ -0,0 +1,37 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsPinChatMessageOutputSchema } from '../../../output-schemas';++export const pinChatMessage = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_pin_chat_message',+ outputSchema: microsoftTeamsPinChatMessageOutputSchema,+ displayName: 'Pin Chat Message',+ description: 'Pins a message in a chat.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Pins a message (message ID from List Chat Messages) in a chat (chat ID from List Chats) and returns the pinned message ID that Unpin Chat Message takes.',+ idempotent: false,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ messageId: Property.ShortText({+ displayName: 'Message ID',+ description: 'The message ID, from List Chat Messages.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, messageId } = context.propsValue;+ const graphBaseUrl = microsoftTeamsClient.graphUrl({ auth: context.auth });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await client.api(`/chats/${chatId}/pinnedMessages`).post({+ '[email protected]': `${graphBaseUrl}/v1.0/chats/${chatId}/messages/${messageId}`,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/unhide-chat.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/unhide-chat.tsnew file mode 100644index 00000000000..3e07cca8004--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/unhide-chat.ts@@ -0,0 +1,31 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsHideChatOutputSchema } from '../../../output-schemas';++export const unhideChat = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_unhide_chat',+ outputSchema: microsoftTeamsHideChatOutputSchema,+ displayName: 'Unhide Chat',+ description: 'Unhides a chat for the signed-in user.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ "Shows a chat hidden with Hide Chat in the signed-in user's chat list again, by chat ID from List Chats. Only affects the signed-in user.",+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ },+ async run(context) {+ const { chatId } = context.propsValue;+ const user = await microsoftTeamsClient.signedInUser({ auth: context.auth });+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/chats/${chatId}/unhideForUser`).post({ user });+ return { success: true };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/unpin-chat-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/unpin-chat-message.tsnew file mode 100644index 00000000000..127651073dc--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/unpin-chat-message.ts@@ -0,0 +1,35 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsHideChatOutputSchema } from '../../../output-schemas';++export const unpinChatMessage = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_unpin_chat_message',+ outputSchema: microsoftTeamsHideChatOutputSchema,+ displayName: 'Unpin Chat Message',+ description: 'Unpins a message in a chat.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Unpins a pinned message in a chat (chat ID from List Chats) by its pinned message ID from List Pinned Chat Messages or Pin Chat Message. The message itself is kept and can be pinned again.',+ idempotent: false,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ pinnedMessageId: Property.ShortText({+ displayName: 'Pinned Message ID',+ description: 'The pinned message ID (the id field), from List Pinned Chat Messages or Pin Chat Message.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, pinnedMessageId } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ await client.api(`/chats/${chatId}/pinnedMessages/${pinnedMessageId}`).delete();+ return { success: true };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/update-chat.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/update-chat.tsnew file mode 100644index 00000000000..6d39ef36474--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/chats/update-chat.ts@@ -0,0 +1,34 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetChatOutputSchema } from '../../../output-schemas';++export const updateChat = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_update_chat',+ displayName: 'Update Chat',+ description: 'Renames a group chat.',+ audience: 'ai',+ outputSchema: microsoftTeamsGetChatOutputSchema,+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Sets the topic (title) of a group chat by chat ID from List Chats. Only group chats have a topic; one-on-one and meeting chats are rejected.',+ idempotent: true,+ },+ props: {+ chatId: microsoftTeamsAiProps.chatId({ required: true }),+ topic: Property.ShortText({+ displayName: 'Topic',+ description: 'The new chat title, at most 250 characters, no colons.',+ required: true,+ }),+ },+ async run(context) {+ const { chatId, topic } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await client.api(`/chats/${chatId}`).patch({ topic });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/index.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/index.tsnew file mode 100644index 00000000000..9bbf2b40aad--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/index.ts@@ -0,0 +1,121 @@+import { getChannelMessageById } from './channel-messages/get-channel-message-by-id';+import { getChannelMessageHostedContent } from './channel-messages/get-channel-message-hosted-content';+import { listChannelMessageHostedContents } from './channel-messages/list-channel-message-hosted-contents';+import { listChannelMessageReplies } from './channel-messages/list-channel-message-replies';+import { listChannelMessages } from './channel-messages/list-channel-messages';+import { postChannelMessage } from './channel-messages/post-channel-message';+import { postChannelMessageReply } from './channel-messages/post-channel-message-reply';+import { setChannelMessageReaction } from './channel-messages/set-channel-message-reaction';+import { unsetChannelMessageReaction } from './channel-messages/unset-channel-message-reaction';+import { createTeamChannel } from './channels/create-team-channel';+import { getChannel } from './channels/get-channel';+import { getPrimaryChannel } from './channels/get-primary-channel';+import { listAllChannels } from './channels/list-all-channels';+import { listChannels } from './channels/list-channels';+import { listIncomingChannels } from './channels/list-incoming-channels';+import { getChatMessageById } from './chat-messages/get-chat-message-by-id';+import { getChatMessageHostedContent } from './chat-messages/get-chat-message-hosted-content';+import { listChatMessageHostedContents } from './chat-messages/list-chat-message-hosted-contents';+import { listChatMessages } from './chat-messages/list-chat-messages';+import { postChatMessage } from './chat-messages/post-chat-message';+import { setChatMessageReaction } from './chat-messages/set-chat-message-reaction';+import { softDeleteChatMessage } from './chat-messages/soft-delete-chat-message';+import { undoSoftDeleteChatMessage } from './chat-messages/undo-soft-delete-chat-message';+import { unsetChatMessageReaction } from './chat-messages/unset-chat-message-reaction';+import { updateChatMessage } from './chat-messages/update-chat-message';+import { addChatMember } from './chats/add-chat-member';+import { createChat } from './chats/create-chat';+import { getChat } from './chats/get-chat';+import { getChatMember } from './chats/get-chat-member';+import { hideChat } from './chats/hide-chat';+import { listChatMembers } from './chats/list-chat-members';+import { listChats } from './chats/list-chats';+import { listPinnedChatMessages } from './chats/list-pinned-chat-messages';+import { markChatRead } from './chats/mark-chat-read';+import { markChatUnread } from './chats/mark-chat-unread';+import { pinChatMessage } from './chats/pin-chat-message';+import { unhideChat } from './chats/unhide-chat';+import { unpinChatMessage } from './chats/unpin-chat-message';+import { updateChat } from './chats/update-chat';+import { getMeetingRecordingDetails } from './meetings/get-meeting-recording-details';+import { getMeetingTranscriptContent } from './meetings/get-meeting-transcript-content';+import { getMeetingTranscriptDetails } from './meetings/get-meeting-transcript-details';+import { listMeetingRecordings } from './meetings/list-meeting-recordings';+import { listMeetingTranscripts } from './meetings/list-meeting-transcripts';+import { getTeamMember } from './members/get-team-member';+import { listTeamMembers } from './members/list-team-members';+import { getMyPresence } from './presence/get-my-presence';+import { getPresencesByUserIds } from './presence/get-presences-by-user-ids';+import { getUserPresence } from './presence/get-user-presence';+import { searchMessages } from './search/search-messages';+import { getTeam } from './teams/get-team';+import { listAssociatedTeams } from './teams/list-associated-teams';+import { listDeletedTeams } from './teams/list-deleted-teams';+import { listJoinedTeams } from './teams/list-joined-teams';+import { listTeams } from './teams/list-teams';+import { getCurrentUser } from './users/get-current-user';+import { getTeamsLicensingDetails } from './users/get-teams-licensing-details';+import { getUser } from './users/get-user';+import { listUsers } from './users/list-users';++export const microsoftTeamsAiActions = [+ getTeam,+ listAssociatedTeams,+ listDeletedTeams,+ listJoinedTeams,+ listTeams,+ createTeamChannel,+ getChannel,+ getPrimaryChannel,+ listAllChannels,+ listChannels,+ listIncomingChannels,+ getChannelMessageById,+ getChannelMessageHostedContent,+ listChannelMessageHostedContents,+ listChannelMessageReplies,+ listChannelMessages,+ postChannelMessageReply,+ postChannelMessage,+ setChannelMessageReaction,+ unsetChannelMessageReaction,+ addChatMember,+ createChat,+ getChatMember,+ getChat,+ hideChat,+ listChatMembers,+ listChats,+ listPinnedChatMessages,+ markChatRead,+ markChatUnread,+ pinChatMessage,+ unhideChat,+ unpinChatMessage,+ updateChat,+ getChatMessageById,+ getChatMessageHostedContent,+ listChatMessageHostedContents,+ listChatMessages,+ postChatMessage,+ setChatMessageReaction,+ softDeleteChatMessage,+ undoSoftDeleteChatMessage,+ unsetChatMessageReaction,+ updateChatMessage,+ getTeamMember,+ listTeamMembers,+ getCurrentUser,+ getTeamsLicensingDetails,+ getUser,+ listUsers,+ getMyPresence,+ getPresencesByUserIds,+ getUserPresence,+ getMeetingRecordingDetails,+ getMeetingTranscriptContent,+ getMeetingTranscriptDetails,+ listMeetingRecordings,+ listMeetingTranscripts,+ searchMessages,+];diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/get-meeting-recording-details.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/get-meeting-recording-details.tsnew file mode 100644index 00000000000..a0887291b4b--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/get-meeting-recording-details.ts@@ -0,0 +1,36 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetMeetingRecordingDetailsOutputSchema } from '../../../output-schemas';++export const getMeetingRecordingDetails = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_meeting_recording_details',+ displayName: 'Get Meeting Recording Details',+ description: "Gets a meeting recording's details, without the video.",+ audience: 'ai',+ outputSchema: microsoftTeamsGetMeetingRecordingDetailsOutputSchema,+ classification: 'READ',+ aiMetadata: {+ description:+ "Gets one recording's metadata (ID, creation and end time, organizer, content URL) for an online meeting the signed-in user organized. Recording IDs come from List Meeting Recordings; the video itself is not downloaded.",+ idempotent: true,+ },+ props: {+ meetingId: microsoftTeamsAiProps.meetingId({ required: true }),+ recordingId: Property.ShortText({+ displayName: 'Recording ID',+ description: 'The recording ID, from List Meeting Recordings.',+ required: true,+ }),+ },+ async run(context) {+ const { meetingId, recordingId } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() =>+ client.api(`/me/onlineMeetings/${meetingId}/recordings/${recordingId}`).get(),+ );+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/get-meeting-transcript-content.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/get-meeting-transcript-content.tsnew file mode 100644index 00000000000..7618039a340--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/get-meeting-transcript-content.ts@@ -0,0 +1,60 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetMeetingTranscriptContentOutputSchema } from '../../../output-schemas';++const FORMATS: Record<string, string> = {+ vtt: 'text/vtt',+ text: 'application/vnd.microsoft.graph.transcript+text',+};++export const getMeetingTranscriptContent = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_meeting_transcript_content',+ displayName: 'Get Meeting Transcript Content',+ description: 'Gets the text of a meeting transcript.',+ audience: 'ai',+ outputSchema: microsoftTeamsGetMeetingTranscriptContentOutputSchema,+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets the full text of one transcript of an online meeting the signed-in user organized, as WebVTT with speaker names (vtt) or as plain text without speakers (text). If vtt fails with SpeakerAttributionNotAllowed, call again with text. Transcript IDs come from List Meeting Transcripts.',+ idempotent: true,+ },+ props: {+ meetingId: microsoftTeamsAiProps.meetingId({ required: true }),+ transcriptId: Property.ShortText({+ displayName: 'Transcript ID',+ description: 'The transcript ID, from List Meeting Transcripts.',+ required: true,+ }),+ format: Property.StaticDropdown({+ displayName: 'Format',+ description: 'vtt: WebVTT with timestamps and speaker names (default). text: plain text without speaker names.',+ required: false,+ defaultValue: 'vtt',+ options: {+ disabled: false,+ options: [+ { label: 'WebVTT with speakers', value: 'vtt' },+ { label: 'Plain text', value: 'text' },+ ],+ },+ }),+ },+ async run(context) {+ const { meetingId, transcriptId, format } = context.propsValue;+ const accept = FORMATS[format ?? 'vtt'];+ if (!accept) {+ throw new Error(`Format must be one of: ${Object.keys(FORMATS).join(', ')}.`);+ }+ const content = await microsoftTeamsClient.getText({+ auth: context.auth,+ path: `/me/onlineMeetings/${meetingId}/transcripts/${transcriptId}/content`,+ accept,+ });+ return { transcriptId, format: format ?? 'vtt', content };+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/get-meeting-transcript-details.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/get-meeting-transcript-details.tsnew file mode 100644index 00000000000..c21ec975f93--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/get-meeting-transcript-details.ts@@ -0,0 +1,36 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetMeetingTranscriptDetailsOutputSchema } from '../../../output-schemas';++export const getMeetingTranscriptDetails = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_meeting_transcript_details',+ displayName: 'Get Meeting Transcript Details',+ description: "Gets a meeting transcript's details, without its text.",+ audience: 'ai',+ outputSchema: microsoftTeamsGetMeetingTranscriptDetailsOutputSchema,+ classification: 'READ',+ aiMetadata: {+ description:+ "Gets one transcript's metadata (ID, creation and end time, organizer, content URL) for an online meeting the signed-in user organized. Transcript IDs come from List Meeting Transcripts; read the text with Get Meeting Transcript Content.",+ idempotent: true,+ },+ props: {+ meetingId: microsoftTeamsAiProps.meetingId({ required: true }),+ transcriptId: Property.ShortText({+ displayName: 'Transcript ID',+ description: 'The transcript ID, from List Meeting Transcripts.',+ required: true,+ }),+ },+ async run(context) {+ const { meetingId, transcriptId } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() =>+ client.api(`/me/onlineMeetings/${meetingId}/transcripts/${transcriptId}`).get(),+ );+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/list-meeting-recordings.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/list-meeting-recordings.tsnew file mode 100644index 00000000000..b0ec57baaf7--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/list-meeting-recordings.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListMeetingRecordingsOutputSchema } from '../../../output-schemas';++export const listMeetingRecordings = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_meeting_recordings',+ displayName: 'List Meeting Recordings',+ description: 'Lists the recordings of an online meeting the signed-in user organized.',+ audience: 'ai',+ outputSchema: microsoftTeamsListMeetingRecordingsOutputSchema,+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the recordings of one online meeting organized by the signed-in user, with each recording ID, creation time and content URL. Takes the online meeting ID, not a join URL; the video itself is not downloaded.',+ idempotent: true,+ },+ props: {+ meetingId: microsoftTeamsAiProps.meetingId({ required: true }),+ },+ async run(context) {+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: `/me/onlineMeetings/${context.propsValue.meetingId}/recordings`,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/list-meeting-transcripts.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/list-meeting-transcripts.tsnew file mode 100644index 00000000000..0e86ae39ac7--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/meetings/list-meeting-transcripts.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListMeetingTranscriptsOutputSchema } from '../../../output-schemas';++export const listMeetingTranscripts = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_meeting_transcripts',+ displayName: 'List Meeting Transcripts',+ description: 'Lists the transcripts of an online meeting the signed-in user organized.',+ audience: 'ai',+ outputSchema: microsoftTeamsListMeetingTranscriptsOutputSchema,+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the transcripts of one online meeting organized by the signed-in user, with each transcript ID and creation time. Takes the online meeting ID, not a join URL; read the text with Get Meeting Transcript Content.',+ idempotent: true,+ },+ props: {+ meetingId: microsoftTeamsAiProps.meetingId({ required: true }),+ },+ async run(context) {+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: `/me/onlineMeetings/${context.propsValue.meetingId}/transcripts`,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/members/get-team-member.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/members/get-team-member.tsnew file mode 100644index 00000000000..92776204d52--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/members/get-team-member.ts@@ -0,0 +1,34 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetChatMemberOutputSchema } from '../../../output-schemas';++export const getTeamMember = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_team_member',+ outputSchema: microsoftTeamsGetChatMemberOutputSchema,+ displayName: 'Get Team Member',+ description: 'Gets one membership of a team by its membership ID.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one team membership by its membership ID, with the user ID, display name, email and roles (owner or member). Membership IDs come from List Team Members; they are not user IDs.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ membershipId: Property.ShortText({+ displayName: 'Membership ID',+ description: 'The membership ID (the id field), from List Team Members.',+ required: true,+ }),+ },+ async run(context) {+ const { teamId, membershipId } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api(`/teams/${teamId}/members/${membershipId}`).get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/members/list-team-members.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/members/list-team-members.tsnew file mode 100644index 00000000000..2ef81e723a9--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/members/list-team-members.ts@@ -0,0 +1,58 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListTeamMembersOutputSchema } from '../../../output-schemas';++const MAX_LIMIT = 999;+const DEFAULT_LIMIT = 100;++export const listTeamMembers = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_team_members',+ outputSchema: microsoftTeamsListTeamMembersOutputSchema,+ displayName: 'List Team Members',+ description: 'Lists the members of a team, optionally only those with an exact email or display name.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the members of one team with each membership ID, user ID, email and roles, one page at a time; set Email or Display Name to find one person (exact match). Team IDs come from List Joined Teams; pass @odata.nextLink back as Next Page Link for the next page.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ email: Property.ShortText({+ displayName: 'Email',+ description: 'Only return the member with exactly this email address.',+ required: false,+ }),+ displayName: Property.ShortText({+ displayName: 'Display Name',+ description: 'Only return members with exactly this display name.',+ required: false,+ }),+ limit: microsoftTeamsAiProps.limit({ max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT }),+ nextLink: microsoftTeamsAiProps.nextLink(),+ },+ async run(context) {+ const { teamId, email, displayName, limit, nextLink } = context.propsValue;+ if (email && displayName) {+ throw new Error('Set either Email or Display Name, not both.');+ }+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: `/teams/${teamId}/members`,+ page: { limit, max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT },+ filter: buildFilter({ email, displayName }),+ nextLink,+ });+ },+});++function buildFilter({ email, displayName }: { email?: string; displayName?: string }): string | undefined {+ if (email) return `microsoft.graph.aadUserConversationMember/email eq '${email.replace(/'/g, "''")}'`;+ if (displayName) return `microsoft.graph.aadUserConversationMember/displayName eq '${displayName.replace(/'/g, "''")}'`;+ return undefined;+}diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/presence/get-my-presence.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/presence/get-my-presence.tsnew file mode 100644index 00000000000..e234979c56a--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/presence/get-my-presence.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetMyPresenceOutputSchema } from '../../../output-schemas';++export const getMyPresence = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_my_presence',+ outputSchema: microsoftTeamsGetMyPresenceOutputSchema,+ displayName: 'Get My Presence',+ description: "Gets the signed-in user's Teams presence.",+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ "Gets the signed-in user's current Teams availability (for example Available, Busy, Away), activity and status message. Use Get User Presence for someone else.",+ idempotent: true,+ },+ props: {},+ async run(context) {+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api('/me/presence').get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/presence/get-presences-by-user-ids.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/presence/get-presences-by-user-ids.tsnew file mode 100644index 00000000000..0bbe9050dd7--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/presence/get-presences-by-user-ids.ts@@ -0,0 +1,39 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetPresencesByUserIdsOutputSchema } from '../../../output-schemas';++export const getPresencesByUserIds = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_presences_by_user_ids',+ outputSchema: microsoftTeamsGetPresencesByUserIdsOutputSchema,+ displayName: 'Get Presences by User IDs',+ description: 'Gets the Teams presence of several users at once.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets the current Teams availability, activity and status message of up to 650 users in one call, by user ID (GUIDs from List Users or Get User). Use Get User Presence for a single user.',+ idempotent: true,+ },+ props: {+ userIds: Property.Array({+ displayName: 'User IDs',+ description: 'User IDs (GUIDs), from List Users or Get User. At most 650.',+ required: true,+ }),+ },+ async run(context) {+ const ids = context.propsValue.userIds.map((id) => String(id));+ if (ids.length === 0 || ids.length > MAX_IDS) {+ throw new Error(`User IDs must contain between 1 and ${MAX_IDS} IDs.`);+ }+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() =>+ client.api('/communications/getPresencesByUserId').post({ ids }),+ );+ },+});++const MAX_IDS = 650;diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/presence/get-user-presence.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/presence/get-user-presence.tsnew file mode 100644index 00000000000..0b55ca0b63f--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/presence/get-user-presence.ts@@ -0,0 +1,31 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetMyPresenceOutputSchema } from '../../../output-schemas';++export const getUserPresence = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_user_presence',+ outputSchema: microsoftTeamsGetMyPresenceOutputSchema,+ displayName: 'Get User Presence',+ description: "Gets a user's Teams presence.",+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ "Gets one user's current Teams availability (for example Available, Busy, Away), activity and status message by user ID. Use Get Presences by User IDs for several people at once and Get My Presence for the signed-in user.",+ idempotent: true,+ },+ props: {+ userId: microsoftTeamsAiProps.userId({+ required: true,+ description: 'The user ID (a GUID), from List Users or Get User.',+ }),+ },+ async run(context) {+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api(`/users/${context.propsValue.userId}/presence`).get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/search/search-messages.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/search/search-messages.tsnew file mode 100644index 00000000000..4089a6d3650--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/search/search-messages.ts@@ -0,0 +1,53 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsSearchMessagesOutputSchema } from '../../../output-schemas';++const MAX_LIMIT = 25;+const DEFAULT_LIMIT = 25;++export const searchMessages = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_search_messages',+ outputSchema: microsoftTeamsSearchMessagesOutputSchema,+ displayName: 'Search Messages',+ description: 'Searches the chat and channel messages the signed-in user can read.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Full-text search over the Teams chat and channel messages the signed-in user can read, returning matching messages with a summary and their chat or channel IDs. Page with Offset: when moreResultsAvailable is true, call again with Offset increased by Limit.',+ idempotent: true,+ },+ props: {+ query: Property.ShortText({+ displayName: 'Query',+ description: 'Keywords to search for. Supports KQL, for example from:alex budget.',+ required: true,+ }),+ limit: microsoftTeamsAiProps.limit({ max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT }),+ offset: Property.Number({+ displayName: 'Offset',+ description: 'How many results to skip, for the next page. Defaults to 0.',+ required: false,+ }),+ },+ async run(context) {+ const { query, limit, offset } = context.propsValue;+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() =>+ client.api('/search/query').post({+ requests: [+ {+ entityTypes: ['chatMessage'],+ query: { queryString: query },+ from: offset ?? 0,+ size: Math.min(Math.max(Math.trunc(limit ?? DEFAULT_LIMIT), 1), MAX_LIMIT),+ },+ ],+ }),+ );+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/get-team.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/get-team.tsnew file mode 100644index 00000000000..71617340cda--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/get-team.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetTeamOutputSchema } from '../../../output-schemas';++export const getTeam = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_team',+ outputSchema: microsoftTeamsGetTeamOutputSchema,+ displayName: 'Get Team',+ description: 'Gets a team by ID, with its settings.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one team by its ID, including its description, visibility, archive state, web URL and member, messaging, guest and fun settings. Team IDs come from List Joined Teams or List Teams.',+ idempotent: true,+ },+ props: {+ teamId: microsoftTeamsAiProps.teamId({ required: true }),+ },+ async run(context) {+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api(`/teams/${context.propsValue.teamId}`).get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-associated-teams.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-associated-teams.tsnew file mode 100644index 00000000000..fce3d53e2e3--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-associated-teams.ts@@ -0,0 +1,24 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListAssociatedTeamsOutputSchema } from '../../../output-schemas';++export const listAssociatedTeams = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_associated_teams',+ outputSchema: microsoftTeamsListAssociatedTeamsOutputSchema,+ displayName: 'List Associated Teams',+ description: 'Lists the teams the signed-in user is associated with, including teams reached through shared channels.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the teams the signed-in user is associated with: teams they are a direct member of plus teams whose shared channels they belong to, with each team ID and tenant ID. Use List Joined Teams for direct memberships only.',+ idempotent: true,+ },+ props: {},+ async run(context) {+ return await microsoftTeamsClient.list({ auth: context.auth, path: '/me/teamwork/associatedTeams' });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-deleted-teams.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-deleted-teams.tsnew file mode 100644index 00000000000..1dd07700695--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-deleted-teams.ts@@ -0,0 +1,24 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListDeletedTeamsOutputSchema } from '../../../output-schemas';++export const listDeletedTeams = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_deleted_teams',+ outputSchema: microsoftTeamsListDeletedTeamsOutputSchema,+ displayName: 'List Deleted Teams',+ description: 'Lists teams that were deleted and can still be restored.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists deleted teams that are still within their restore window, with each team ID. Read-only: restoring a team is not available.',+ idempotent: true,+ },+ props: {},+ async run(context) {+ return await microsoftTeamsClient.list({ auth: context.auth, path: '/teamwork/deletedTeams' });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-joined-teams.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-joined-teams.tsnew file mode 100644index 00000000000..e9e270acc1e--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-joined-teams.ts@@ -0,0 +1,24 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListJoinedTeamsOutputSchema } from '../../../output-schemas';++export const listJoinedTeams = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_joined_teams',+ outputSchema: microsoftTeamsListJoinedTeamsOutputSchema,+ displayName: 'List Joined Teams',+ description: 'Lists the teams the signed-in user is a direct member of.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists every team the signed-in user is a direct member of, with each team ID. Start here to get a team ID for channel, member and message actions; use List Teams to see teams across the organization.',+ idempotent: true,+ },+ props: {},+ async run(context) {+ return await microsoftTeamsClient.list({ auth: context.auth, path: '/me/joinedTeams' });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-teams.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-teams.tsnew file mode 100644index 00000000000..abd2d20fa8c--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/teams/list-teams.ts@@ -0,0 +1,43 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListTeamsOutputSchema } from '../../../output-schemas';++const MAX_LIMIT = 999;+const DEFAULT_LIMIT = 50;++export const listTeams = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_teams',+ outputSchema: microsoftTeamsListTeamsOutputSchema,+ displayName: 'List Teams',+ description: 'Lists teams in the organization, one page at a time.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists teams across the whole organization, not only the ones the signed-in user belongs to, one page at a time; pass @odata.nextLink back as Next Page Link for the next page. Use List Joined Teams for the user\'s own teams.',+ idempotent: true,+ },+ props: {+ filter: Property.ShortText({+ displayName: 'Filter',+ description: "An OData $filter on team properties, for example startswith(displayName, 'Sales').",+ required: false,+ }),+ limit: microsoftTeamsAiProps.limit({ max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT }),+ nextLink: microsoftTeamsAiProps.nextLink(),+ },+ async run(context) {+ const { filter, limit, nextLink } = context.propsValue;+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: '/teams',+ page: { limit, max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT },+ filter,+ nextLink,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/get-current-user.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/get-current-user.tsnew file mode 100644index 00000000000..143e073ba30--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/get-current-user.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetCurrentUserOutputSchema } from '../../../output-schemas';++export const getCurrentUser = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_current_user',+ outputSchema: microsoftTeamsGetCurrentUserOutputSchema,+ displayName: 'Get Current User',+ description: 'Gets the profile of the signed-in user.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ "Gets the signed-in user's profile: user ID, display name, email and user principal name. Use it to learn who the connection acts as, for example before creating a chat that must include the signed-in user.",+ idempotent: true,+ },+ props: {},+ async run(context) {+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api('/me').get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/get-teams-licensing-details.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/get-teams-licensing-details.tsnew file mode 100644index 00000000000..381e4b6275e--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/get-teams-licensing-details.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetTeamsLicensingDetailsOutputSchema } from '../../../output-schemas';++export const getTeamsLicensingDetails = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_teams_licensing_details',+ outputSchema: microsoftTeamsGetTeamsLicensingDetailsOutputSchema,+ displayName: 'Get Teams Licensing Details',+ description: 'Gets whether the signed-in user has a Teams license.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Reports whether the signed-in user has a Microsoft Teams license. Use it to explain a Teams error that may come from a missing license; it only covers the signed-in user.',+ idempotent: true,+ },+ props: {},+ async run(context) {+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api('/me/licenseDetails/getTeamsLicensingDetails').get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/get-user.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/get-user.tsnew file mode 100644index 00000000000..8ef253ce432--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/get-user.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsGetCurrentUserOutputSchema } from '../../../output-schemas';++export const getUser = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_get_user',+ outputSchema: microsoftTeamsGetCurrentUserOutputSchema,+ displayName: 'Get User',+ description: 'Gets a user by ID or user principal name.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ "Gets one user's basic profile (user ID, display name, mail, user principal name, job title) by user ID or user principal name. Use it to turn an email-style principal name into the user ID that chat and presence actions take.",+ idempotent: true,+ },+ props: {+ userId: microsoftTeamsAiProps.userId({ required: true }),+ },+ async run(context) {+ const client = microsoftTeamsClient.create({ auth: context.auth });+ return await microsoftTeamsClient.withRetry(() => client.api(`/users/${context.propsValue.userId}`).get());+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/list-users.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/list-users.tsnew file mode 100644index 00000000000..c96946c8d5f--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/ai/users/list-users.ts@@ -0,0 +1,43 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../../../auth';+import { microsoftTeamsAiProps } from '../../../common/ai-props';+import { microsoftTeamsClient } from '../../../common/client';+import { microsoftTeamsListUsersOutputSchema } from '../../../output-schemas';++const MAX_LIMIT = 999;+const DEFAULT_LIMIT = 100;++export const listUsers = createAction({+ auth: microsoftTeamsAuth,+ name: 'microsoft_teams_list_users',+ outputSchema: microsoftTeamsListUsersOutputSchema,+ displayName: 'List Users',+ description: 'Lists users in the organization, one page at a time.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ "Lists the organization's users with each user ID, display name, mail and user principal name, one page at a time; pass @odata.nextLink back as Next Page Link for the next page. Use Filter to find someone, for example startswith(displayName,'Ann') or mail eq '[email protected]'.",+ idempotent: true,+ },+ props: {+ filter: Property.ShortText({+ displayName: 'Filter',+ description: "An OData $filter on user properties, for example startswith(displayName,'Ann') or mail eq '[email protected]'.",+ required: false,+ }),+ limit: microsoftTeamsAiProps.limit({ max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT }),+ nextLink: microsoftTeamsAiProps.nextLink(),+ },+ async run(context) {+ const { filter, limit, nextLink } = context.propsValue;+ return await microsoftTeamsClient.list({+ auth: context.auth,+ path: '/users',+ page: { limit, max: MAX_LIMIT, defaultValue: DEFAULT_LIMIT },+ filter,+ nextLink,+ });+ },+});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/create-channel.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/create-channel.tsindex 967694dec0f..cf7dc0bb2f8 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/create-channel.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/create-channel.ts@@ -1,21 +1,23 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import { microsoftTeamsCreateChannelOutputSchema } from '../output-schemas';export const createChannelAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_create_channel',+ outputSchema: microsoftTeamsCreateChannelOutputSchema,classification: 'WRITE',displayName: 'Create Channel',description: 'Create a new channel in Microsoft Teams.',- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Creates a new standard channel inside a Microsoft Teams team, identified by team ID, with a display name and optional description. Use to provision a shared channel; for a members-restricted channel use Create Private Channel instead. Not idempotent — each call adds another channel even with the same name.',idempotent: false,},props: {- teamId: microsoftTeamsCommon.teamId,+ teamId: microsoftTeamsProps.teamId({ required: true }),channelDisplayName: Property.ShortText({displayName: 'Channel Name',required: true,@@ -28,8 +30,7 @@ export const createChannelAction = createAction({async run(context) {const { teamId, channelDescription, channelDisplayName } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });const channel = {displayName: channelDisplayName,diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/create-chat-and-send-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/create-chat-and-send-message.tsindex a570916a57e..e3d05a0874b 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/create-chat-and-send-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/create-chat-and-send-message.ts@@ -1,25 +1,26 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient } from '../common/graph';-import { getGraphBaseUrl } from '../common/microsoft-cloud';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';import { isNil } from '@activepieces/pieces-framework';-import { Chat } from '@microsoft/microsoft-graph-types';+import type { Chat, MicrosoftTeamsMe } from '../common/types';+import { microsoftTeamsCreateChatAndSendMessageOutputSchema } from '../output-schemas';export const createChatAndSendMessageAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_create_chat_and_send_message',+ outputSchema: microsoftTeamsCreateChatAndSendMessageOutputSchema,classification: 'WRITE',displayName: 'Create Chat & Send Message',description: 'Start a new chat and send an initial message.',- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Creates a new Microsoft Teams chat with one or more other members (one-on-one when a single member is given, otherwise a group chat) and posts an initial message into it; the current user is automatically added. Use to open a brand-new conversation; to message an existing chat use Send Chat Message instead. Not idempotent — each call may create another chat and posts another message.',idempotent: false,},props: {- teamId: microsoftTeamsCommon.teamId,- members:microsoftTeamsCommon.memberIds(true),+ teamId: microsoftTeamsProps.teamId({ required: true }),+ members:microsoftTeamsProps.memberIds({ required: true }),contentType: Property.StaticDropdown({displayName: 'Message Content Type',required: true,@@ -44,15 +45,12 @@ export const createChatAndSendMessageAction = createAction({throw new Error('For one-on-one chats, provide exactly one other member.');}- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);- const graphBaseUrl = getGraphBaseUrl(cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });+ const graphBaseUrl = microsoftTeamsClient.graphUrl({ auth: context.auth });- // Resolve current user to include as a member- const me = await client.api('/me').select('id,userPrincipalName').get();+ const me: MicrosoftTeamsMe = await client.api('/me').select('id,userPrincipalName').get();const currentUserBind = `${graphBaseUrl}/v1.0/users('${me.id}')`;- // Parse provided membersconst otherMembersRaw: string[] = members.map((member) => `${graphBaseUrl}/v1.0/users('${member}')`)@@ -74,10 +72,8 @@ export const createChatAndSendMessageAction = createAction({members: membersPayload,};- // Create or get existing chatconst chat = await client.api('/chats').post(chatBody);- // Send initial messageconst chatMessage = {body: {content: content,diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/create-private-channel.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/create-private-channel.tsindex a3c8405acef..96843870d76 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/create-private-channel.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/create-private-channel.ts@@ -1,21 +1,23 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient, withGraphRetry } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import { microsoftTeamsCreatePrivateChannelOutputSchema } from '../output-schemas';export const createPrivateChannelAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_create_private_channel',+ outputSchema: microsoftTeamsCreatePrivateChannelOutputSchema,classification: 'WRITE',displayName: 'Create Private Channel',description: 'Create a new private channel in a team.',- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Creates a new private (membership-restricted) channel inside a Microsoft Teams team, identified by team ID, with a display name and optional description. Use when access should be limited to specific members; for a standard open channel use Create Channel instead. Not idempotent — each call adds another channel.',idempotent: false,},props: {- teamId: microsoftTeamsCommon.teamId,+ teamId: microsoftTeamsProps.teamId({ required: true }),channelDisplayName: Property.ShortText({displayName: 'Channel Name',required: true,@@ -28,8 +30,7 @@ export const createPrivateChannelAction = createAction({async run(context) {const { teamId, channelDescription, channelDisplayName } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });const channel = {displayName: channelDisplayName,@@ -37,8 +38,7 @@ export const createPrivateChannelAction = createAction({membershipType: 'private',};- // https://learn.microsoft.com/graph/api/channel-post?view=graph-rest-1.0- return await withGraphRetry(() => client.api(`/teams/${teamId}/channels`).post(channel));+ return await microsoftTeamsClient.withRetry(() => client.api(`/teams/${teamId}/channels`).post(channel));},});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/delete-chat-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/delete-chat-message.tsindex fa3035ec322..88f3624b896 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/delete-chat-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/delete-chat-message.ts@@ -1,21 +1,24 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import type { MicrosoftTeamsMe } from '../common/types';+import { microsoftTeamsDeleteChatMessageOutputSchema } from '../output-schemas';export const deleteChatMessageAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_delete_chat_message',+ outputSchema: microsoftTeamsDeleteChatMessageOutputSchema,classification: 'DESTRUCTIVE',displayName: 'Delete Chat Message',description: 'Soft-Deletes a message in chat.You can only delete messages you sent.',- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Soft-deletes a message in a Microsoft Teams chat, identified by chat ID and message ID, on behalf of the authenticated user. Only messages the current user sent can be deleted. Effectively idempotent — re-running on an already-deleted message leaves it deleted.',idempotent: true,},props: {- chatId: microsoftTeamsCommon.chatId,+ chatId: microsoftTeamsProps.chatId({ required: true }),messageId: Property.ShortText({displayName: 'Message ID',required: true,@@ -25,11 +28,10 @@ export const deleteChatMessageAction = createAction({async run(context) {const { chatId, messageId } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });- const me = await client.api('/me').select('id,userPrincipalName').get();+ const me: MicrosoftTeamsMe = await client.api('/me').select('id,userPrincipalName').get();await client.api(`/users/${me.id}/chats/${chatId}/messages/${messageId}/softDelete`).post({});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/find-channel.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/find-channel.tsindex e1586749271..94d87bd13da 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/find-channel.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/find-channel.ts@@ -1,22 +1,24 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { PageCollection } from '@microsoft/microsoft-graph-client';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import type { Channel, MicrosoftTeamsPage } from '../common/types';+import { microsoftTeamsFindChannelOutputSchema } from '../output-schemas';export const findChannelAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_find_channel',+ outputSchema: microsoftTeamsFindChannelOutputSchema,classification: 'SEARCH',displayName: 'Find Channel',description: 'Finds channels by name.',- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Searches the channels of a Microsoft Teams team (by team ID) for ones whose display name exactly matches the given name. Use to resolve a channel name to its ID before posting or reading. Idempotent read-only lookup; match is exact, not a substring search.',idempotent: true,},props: {- teamId: microsoftTeamsCommon.teamId,+ teamId: microsoftTeamsProps.teamId({ required: true }),channelName: Property.ShortText({displayName: 'Channel Name',required: true,@@ -25,10 +27,9 @@ export const findChannelAction = createAction({async run(context) {const { teamId, channelName } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });- const response: PageCollection = await client+ const response: MicrosoftTeamsPage<Channel> = await client.api(`/teams/${teamId}/allChannels`).filter(`displayName eq '${channelName}'`).get();diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/find-team-member.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/find-team-member.tsindex 06366787dd0..efe05071d42 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/find-team-member.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/find-team-member.ts@@ -1,22 +1,24 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { PageCollection } from '@microsoft/microsoft-graph-client';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import type { ConversationMember, MicrosoftTeamsPage } from '../common/types';+import { microsoftTeamsFindTeamMemberOutputSchema } from '../output-schemas';export const findTeamMemberAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_find_team_member',+ outputSchema: microsoftTeamsFindTeamMemberOutputSchema,classification: 'SEARCH',displayName: 'Find Team Member',description: 'Finds a team member by email or display name.',- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Searches the members of a Microsoft Teams team (by team ID) for those matching a given email or display name, depending on the selected search mode. Use to resolve a person to their member record/ID before mentioning or messaging them. Idempotent read-only lookup; match is exact on the chosen field.',idempotent: true,},props: {- teamId: microsoftTeamsCommon.teamId,+ teamId: microsoftTeamsProps.teamId({ required: true }),searchBy: Property.StaticDropdown({displayName: 'Search By',required: true,@@ -38,12 +40,11 @@ export const findTeamMemberAction = createAction({async run(context) {const { teamId, searchBy, searchValue } = context.propsValue- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });const filter = searchBy == 'email' ?`microsoft.graph.aadUserConversationMember/email eq '${searchValue}'`:`microsoft.graph.aadUserConversationMember/displayName eq '${searchValue}'`;- const response: PageCollection = await client+ const response: MicrosoftTeamsPage<ConversationMember> = await client.api(`/teams/${teamId}/members`).filter(filter).get();diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/get-channel-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/get-channel-message.tsindex fd75789e896..d5c59092b4d 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/get-channel-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/get-channel-message.ts@@ -1,22 +1,24 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient, withGraphRetry } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import { microsoftTeamsGetChannelMessageOutputSchema } from '../output-schemas';export const getChannelMessageAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_get_channel_message',+ outputSchema: microsoftTeamsGetChannelMessageOutputSchema,classification: 'READ',displayName: 'Get Channel Message',description: 'Fetch a specific channel message by team, channel, and message ID (optionally a reply).',- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Retrieves a single channel message from Microsoft Teams by team ID, channel ID, and message ID; supply an optional reply ID to fetch a specific reply under that message instead. Use to read the content or metadata of a known channel post. Idempotent read-only lookup.',idempotent: true,},props: {- teamId: microsoftTeamsCommon.teamId,- channelId: microsoftTeamsCommon.channelId,+ teamId: microsoftTeamsProps.teamId({ required: true }),+ channelId: microsoftTeamsProps.channelId({ required: true }),messageId: Property.ShortText({displayName: 'Message ID',required: true,@@ -31,13 +33,11 @@ export const getChannelMessageAction = createAction({async run(context) {const { teamId, channelId, messageId, replyId } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });- // https://learn.microsoft.com/graph/api/chatmessage-get?view=graph-rest-1.0const base = `/teams/${teamId}/channels/${channelId}/messages/${messageId}`;const path = replyId ? `${base}/replies/${replyId}` : base;- return await withGraphRetry(() => client.api(path).get());+ return await microsoftTeamsClient.withRetry(() => client.api(path).get());},});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/get-chat-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/get-chat-message.tsindex 6d327fb1da9..507edfbfe20 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/get-chat-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/get-chat-message.ts@@ -1,21 +1,23 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient, withGraphRetry } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import { microsoftTeamsGetChatMessageOutputSchema } from '../output-schemas';export const getChatMessageAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_get_chat_message',+ outputSchema: microsoftTeamsGetChatMessageOutputSchema,classification: 'READ',displayName: 'Get Chat Message',description: 'Fetch a specific chat message by chat and message ID.',- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Retrieves a single message from a Microsoft Teams chat by chat ID and message ID. Use to read the content or metadata of a known chat message. Idempotent read-only lookup.',idempotent: true,},props: {- chatId: microsoftTeamsCommon.chatId,+ chatId: microsoftTeamsProps.chatId({ required: true }),messageId: Property.ShortText({displayName: 'Message ID',required: true,@@ -25,11 +27,9 @@ export const getChatMessageAction = createAction({async run(context) {const { chatId, messageId } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });- // https://learn.microsoft.com/graph/api/chatmessage-get?view=graph-rest-1.0- return await withGraphRetry(() => client.api(`/chats/${chatId}/messages/${messageId}`).get());+ return await microsoftTeamsClient.withRetry(() => client.api(`/chats/${chatId}/messages/${messageId}`).get());},});diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/get-meeting-recording.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/get-meeting-recording.tsindex 60618e4434a..cfb90c06cf2 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/get-meeting-recording.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/get-meeting-recording.ts@@ -1,7 +1,9 @@import { microsoftTeamsAuth } from '../auth';import { createAction } from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient, resolveMeetingId, withGraphRetry } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import { microsoftTeamsApi } from '../common/api';+import { microsoftTeamsGetMeetingRecordingOutputSchema } from '../output-schemas';export const getMeetingRecordingAction = createAction({auth: microsoftTeamsAuth,@@ -10,34 +12,32 @@ export const getMeetingRecordingAction = createAction({displayName: 'Get Meeting Recording',description:'Retrieves recordings for a Teams meeting. Provide a Recording to fetch its metadata; omit it to list all available recordings.',- audience: 'both',+ audience: 'human',+ outputSchema: microsoftTeamsGetMeetingRecordingOutputSchema,aiMetadata: {description: 'Retrieves recordings for a Microsoft Teams online meeting belonging to the authenticated user, resolved from a meeting identifier (join URL or ID). Operates in two modes: with a recording ID it fetches that recording\'s metadata; without one it lists all available recordings for the meeting. Idempotent read-only operation.',idempotent: true,},props: {- meetingIdentifierType: microsoftTeamsCommon.meetingIdentifierType,- meetingIdentifierValue: microsoftTeamsCommon.meetingIdentifierValue,- recordingId: microsoftTeamsCommon.recordingId,+ meetingIdentifierType: microsoftTeamsProps.meetingIdentifierType({ required: true }),+ meetingIdentifierValue: microsoftTeamsProps.meetingIdentifierValue({ required: true }),+ recordingId: microsoftTeamsProps.recordingId({ required: false }),},async run(context) {const { meetingIdentifierType, meetingIdentifierValue, recordingId } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });- const meetingId = await withGraphRetry(() =>- resolveMeetingId({ client, identifierType: meetingIdentifierType, identifierValue: meetingIdentifierValue }),+ const meetingId = await microsoftTeamsClient.withRetry(() =>+ microsoftTeamsApi.resolveMeetingId({ client, identifierType: meetingIdentifierType, identifierValue: meetingIdentifierValue }),);if (recordingId) {- // https://learn.microsoft.com/graph/api/callrecording-get?view=graph-rest-1.0- return await withGraphRetry(() =>+ return await microsoftTeamsClient.withRetry(() =>client.api(`/me/onlineMeetings/${meetingId}/recordings/${recordingId}`).get(),);}- // https://learn.microsoft.com/graph/api/onlinemeeting-list-recordings?view=graph-rest-1.0- return await withGraphRetry(() =>+ return await microsoftTeamsClient.withRetry(() =>client.api(`/me/onlineMeetings/${meetingId}/recordings`).get(),);},diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/get-meeting-transcript.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/get-meeting-transcript.tsindex 89a6ddacce2..1d3f7e722d5 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/get-meeting-transcript.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/get-meeting-transcript.ts@@ -1,8 +1,10 @@import { microsoftTeamsAuth } from '../auth';import { createAction } from '@activepieces/pieces-framework';import { ResponseType } from '@microsoft/microsoft-graph-client';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient, resolveMeetingId, withGraphRetry } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import { microsoftTeamsApi } from '../common/api';+import { microsoftTeamsGetMeetingTranscriptOutputSchema } from '../output-schemas';export const getMeetingTranscriptAction = createAction({auth: microsoftTeamsAuth,@@ -11,28 +13,27 @@ export const getMeetingTranscriptAction = createAction({displayName: 'Get Meeting Transcript',description:'Retrieves transcripts for a Teams meeting. Provide a Transcript to fetch its text content; omit it to list all available transcripts.',- audience: 'both',+ audience: 'human',+ outputSchema: microsoftTeamsGetMeetingTranscriptOutputSchema,aiMetadata: {description: 'Retrieves transcripts for a Microsoft Teams online meeting belonging to the authenticated user, resolved from a meeting identifier (join URL or ID). Operates in two modes: with a transcript ID it fetches that transcript\'s text content (VTT); without one it lists all available transcripts for the meeting. Idempotent read-only operation.',idempotent: true,},props: {- meetingIdentifierType: microsoftTeamsCommon.meetingIdentifierType,- meetingIdentifierValue: microsoftTeamsCommon.meetingIdentifierValue,- transcriptId: microsoftTeamsCommon.transcriptId,+ meetingIdentifierType: microsoftTeamsProps.meetingIdentifierType({ required: true }),+ meetingIdentifierValue: microsoftTeamsProps.meetingIdentifierValue({ required: true }),+ transcriptId: microsoftTeamsProps.transcriptId({ required: false }),},async run(context) {const { meetingIdentifierType, meetingIdentifierValue, transcriptId } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });- const meetingId = await withGraphRetry(() =>- resolveMeetingId({ client, identifierType: meetingIdentifierType, identifierValue: meetingIdentifierValue }),+ const meetingId = await microsoftTeamsClient.withRetry(() =>+ microsoftTeamsApi.resolveMeetingId({ client, identifierType: meetingIdentifierType, identifierValue: meetingIdentifierValue }),);if (transcriptId) {- // https://learn.microsoft.com/graph/api/calltranscript-get?view=graph-rest-1.0- const content = await withGraphRetry(() =>+ const content = await microsoftTeamsClient.withRetry(() =>client.api(`/me/onlineMeetings/${meetingId}/transcripts/${transcriptId}/content`).header('Accept', 'text/vtt')@@ -42,8 +43,7 @@ export const getMeetingTranscriptAction = createAction({return { content };}- // https://learn.microsoft.com/graph/api/onlinemeeting-list-transcripts?view=graph-rest-1.0- return await withGraphRetry(() =>+ return await microsoftTeamsClient.withRetry(() =>client.api(`/me/onlineMeetings/${meetingId}/transcripts`).get(),);},diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/reply-to-channel-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/reply-to-channel-message.tsindex d1d7d699585..f9866267a52 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/reply-to-channel-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/reply-to-channel-message.ts@@ -1,22 +1,24 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient, withGraphRetry } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import { microsoftTeamsGetChannelMessageOutputSchema } from '../output-schemas';export const replyToChannelMessageAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_reply_to_channel_message',+ outputSchema: microsoftTeamsGetChannelMessageOutputSchema,classification: 'WRITE',displayName: 'Reply to Channel Message',description: 'Post a reply to an existing channel message.',- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Posts a reply under an existing channel message thread in Microsoft Teams, identified by team ID, channel ID, and the parent message ID. Use to respond within a thread rather than start a new top-level message. Not idempotent — each call adds another reply.',idempotent: false,},props: {- teamId: microsoftTeamsCommon.teamId,- channelId: microsoftTeamsCommon.channelId,+ teamId: microsoftTeamsProps.teamId({ required: true }),+ channelId: microsoftTeamsProps.channelId({ required: true }),messageId: Property.ShortText({displayName: 'Message ID',required: true,@@ -42,8 +44,7 @@ export const replyToChannelMessageAction = createAction({async run(context) {const { teamId, channelId, messageId, contentType, content } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });const chatMessage = {body: {@@ -52,8 +53,7 @@ export const replyToChannelMessageAction = createAction({},};- // https://learn.microsoft.com/graph/api/chatmessage-post-replies?view=graph-rest-1.0- return await withGraphRetry(() =>+ return await microsoftTeamsClient.withRetry(() =>client.api(`/teams/${teamId}/channels/${channelId}/messages/${messageId}/replies`).post(chatMessage)diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/request-approval-channel-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/request-approval-channel-message.tsindex 7b9a17a199a..3704f87f175 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/request-approval-channel-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/request-approval-channel-message.ts@@ -1,14 +1,16 @@import { createAction, Property } from '@activepieces/pieces-framework';import { microsoftTeamsAuth } from '../auth';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';import { assertNotNullOrUndefined } from '@activepieces/pieces-framework';import { ExecutionType } from '@activepieces/pieces-framework';-import { ChatMessage } from '@microsoft/microsoft-graph-types';+import type { ChatMessage } from '../common/types';+import { requestApprovalDirectMessageOutputSchema } from '../output-schemas';export const requestApprovalInChannel = createAction({auth: microsoftTeamsAuth,name: 'request_approval_in_channel',+ outputSchema: requestApprovalDirectMessageOutputSchema,classification: 'WRITE',displayName: 'Request Approval in Channel',description: 'Send approval message to a channel and then wait until the message is approved or disapproved',@@ -18,8 +20,8 @@ export const requestApprovalInChannel = createAction({idempotent: false,},props: {- teamId: microsoftTeamsCommon.teamId,- channelId: microsoftTeamsCommon.channelId,+ teamId: microsoftTeamsProps.teamId({ required: true }),+ channelId: microsoftTeamsProps.channelId({ required: true }),message: Property.LongText({displayName: 'Message',required: true,@@ -28,15 +30,12 @@ export const requestApprovalInChannel = createAction({async run(context) {if (context.executionType === ExecutionType.BEGIN) {const { teamId, channelId, message } = context.propsValue;- const token = context.auth.access_token;-- assertNotNullOrUndefined(token, 'token');+ assertNotNullOrUndefined(context.auth.access_token, 'token');assertNotNullOrUndefined(teamId, 'teamId');assertNotNullOrUndefined(channelId, 'channelId');assertNotNullOrUndefined(message, 'message');- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });const attachmentId = Date.now().toString();const waitpoint = await context.run.createWaitpoint({@@ -76,14 +75,13 @@ export const requestApprovalInChannel = createAction({],};- // Send the message- const response = await client+ await client.api(`/teams/${teamId}/channels/${channelId}/messages`).post(chatMessage);context.run.waitForWaitpoint(waitpoint.id);return {- approved: false, // default approval is false+ approved: false,};} else {return {diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/request-approval-direct-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/request-approval-direct-message.tsindex b4df401f6fb..b5326e6593d 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/request-approval-direct-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/request-approval-direct-message.ts@@ -1,13 +1,15 @@import { createAction, Property } from '@activepieces/pieces-framework';import { microsoftTeamsAuth } from '../auth';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';import { assertNotNullOrUndefined } from '@activepieces/pieces-framework';import { ExecutionType } from '@activepieces/pieces-framework';+import { requestApprovalDirectMessageOutputSchema } from '../output-schemas';export const requestApprovalDirectMessage = createAction({auth: microsoftTeamsAuth,name: 'request_approval_direct_message',+ outputSchema: requestApprovalDirectMessageOutputSchema,classification: 'WRITE',displayName: 'Request Approval from a User',description:@@ -18,7 +20,7 @@ export const requestApprovalDirectMessage = createAction({idempotent: false,},props: {- chatId: microsoftTeamsCommon.chatId,+ chatId: microsoftTeamsProps.chatId({ required: true }),message: Property.LongText({displayName: 'Message',required: true,@@ -27,14 +29,11 @@ export const requestApprovalDirectMessage = createAction({async run(context) {if (context.executionType === ExecutionType.BEGIN) {const { chatId, message } = context.propsValue;- const token = context.auth.access_token;-- assertNotNullOrUndefined(token, 'token');+ assertNotNullOrUndefined(context.auth.access_token, 'token');assertNotNullOrUndefined(chatId, 'chatId');assertNotNullOrUndefined(message, 'message');- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });const attachmentId = Date.now().toString();const waitpoint = await context.run.createWaitpoint({type: 'WEBHOOK',@@ -73,15 +72,14 @@ export const requestApprovalDirectMessage = createAction({],};- // Send the message- const response = await client+ await client.api(`/chats/${chatId}/messages`).post(chatMessage);context.run.waitForWaitpoint(waitpoint.id);return {- approved: false, // default approval is false+ approved: false,};} else {return {diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/send-channel-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/send-channel-message.tsindex cd0a50a29a7..77a207cff5c 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/send-channel-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/send-channel-message.ts@@ -1,24 +1,25 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { PageCollection } from '@microsoft/microsoft-graph-client';-import { ConversationMember } from '@microsoft/microsoft-graph-types';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient, withGraphRetry } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import type { MicrosoftTeamsMember, MicrosoftTeamsPage } from '../common/types';+import { microsoftTeamsGetChannelMessageOutputSchema } from '../output-schemas';export const sendChannelMessageAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_send_channel_message',+ outputSchema: microsoftTeamsGetChannelMessageOutputSchema,classification: 'WRITE',displayName: 'Send Channel Message',description: "Sends a message to a teams's channel.",- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Posts a new top-level message to a Microsoft Teams channel, identified by team ID and channel ID. Use to broadcast to a channel rather than a private chat; to answer an existing thread use Reply to Channel Message instead. Supports @username mentions, which are resolved to team members before posting. Not idempotent — each call posts another message.',idempotent: false,},props: {- teamId: microsoftTeamsCommon.teamId,- channelId: microsoftTeamsCommon.channelId,+ teamId: microsoftTeamsProps.teamId({ required: true }),+ channelId: microsoftTeamsProps.channelId({ required: true }),contentType: Property.StaticDropdown({displayName: 'Content Type',required: true,@@ -46,8 +47,7 @@ export const sendChannelMessageAction = createAction({async run(context) {const { teamId, channelId, contentType, content } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });let messageContent = content;const messageMentions: Array<{@@ -71,15 +71,13 @@ export const sendChannelMessageAction = createAction({if (mentionHandles.length > 0) {const uniqueHandles = [...new Set(mentionHandles.map(normalize))];- // Build OData $filter to only fetch members matching any mentioned handle.- // Use startswith for email so "@username" matches "[email protected]".const filterClauses = uniqueHandles.flatMap((handle) => [`microsoft.graph.aadUserConversationMember/displayName eq '${handle}'`,`startswith(microsoft.graph.aadUserConversationMember/email, '${handle}@')`,]);- const members: ConversationMember[] = [];- let response: PageCollection = await withGraphRetry(() =>+ const members: MicrosoftTeamsMember[] = [];+ let response: MicrosoftTeamsPage<MicrosoftTeamsMember> = await microsoftTeamsClient.withRetry(() =>client.api(`/teams/${teamId}/members`).filter(filterClauses.join(' or '))@@ -87,27 +85,22 @@ export const sendChannelMessageAction = createAction({);while (response.value && response.value.length > 0) {- members.push(...(response.value as ConversationMember[]));+ members.push(...response.value);const nextLink = response['@odata.nextLink'];if (nextLink) {- response = await withGraphRetry(() => client.api(nextLink).get());+ response = await microsoftTeamsClient.withRetry(() => client.api(nextLink).get());} else {break;}}- const byHandle = new Map<string, ConversationMember>();+ const byHandle = new Map<string, MicrosoftTeamsMember>();for (const member of members) {- const typedMember = member as ConversationMember & {- userPrincipalName?: string;- userId?: string;- email?: string;- };const keys = [- typedMember.displayName,- typedMember.userPrincipalName,- typedMember.email,+ member.displayName,+ member.userPrincipalName,+ member.email,].filter((value): value is string => Boolean(value));for (const key of keys) {@@ -128,15 +121,11 @@ export const sendChannelMessageAction = createAction({if (!member) {return match;}- const typedMember = member as ConversationMember & {- userPrincipalName?: string;- userId?: string;- };const displayName =- typedMember.displayName ||- typedMember.userPrincipalName ||- typedMember.userId;- if (!displayName || !typedMember.userId) {+ member.displayName ||+ member.userPrincipalName ||+ member.userId;+ if (!displayName || !member.userId) {return match;}@@ -146,9 +135,9 @@ export const sendChannelMessageAction = createAction({mentionText: displayName,mentioned: {user: {- id: typedMember.userId,+ id: member.userId,displayName: displayName,- userPrincipalName: typedMember.userPrincipalName,+ userPrincipalName: member.userPrincipalName,},},});@@ -162,7 +151,6 @@ export const sendChannelMessageAction = createAction({}}- //https://learn.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=httpconst chatMessage: {body: {content: string;diff --git a/packages/pieces/community/microsoft-teams/src/lib/actions/send-chat-message.ts b/packages/pieces/community/microsoft-teams/src/lib/actions/send-chat-message.tsindex cfee979095d..5c0d5355cf8 100644--- a/packages/pieces/community/microsoft-teams/src/lib/actions/send-chat-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/actions/send-chat-message.ts@@ -1,21 +1,23 @@import { microsoftTeamsAuth } from '../auth';import { createAction, Property } from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient } from '../common/graph';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import { microsoftTeamsGetChatMessageOutputSchema } from '../output-schemas';export const sendChatMessageAction = createAction({auth: microsoftTeamsAuth,name: 'microsoft_teams_send_chat_message',+ outputSchema: microsoftTeamsGetChatMessageOutputSchema,classification: 'WRITE',displayName: 'Send Chat Message',description: 'Sends a message in an existing chat.',- audience: 'both',+ audience: 'human',aiMetadata: {description: 'Sends a message into an existing one-on-one or group chat in Microsoft Teams, identified by chat ID, as plain text or HTML. Use when the target chat already exists; to start a fresh chat use Create Chat & Send Message instead. Not idempotent — each call posts another message.',idempotent: false,},props: {- chatId: microsoftTeamsCommon.chatId,+ chatId: microsoftTeamsProps.chatId({ required: true }),contentType: Property.StaticDropdown({displayName: 'Content Type',required: true,@@ -42,8 +44,7 @@ export const sendChatMessageAction = createAction({async run(context) {const { chatId, contentType, content } = context.propsValue;- const cloud = context.auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(context.auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth: context.auth });const chatMessage = {body: {diff --git a/packages/pieces/community/microsoft-teams/src/lib/auth.ts b/packages/pieces/community/microsoft-teams/src/lib/auth.tsindex b8463046c1f..827d28baa5a 100644--- a/packages/pieces/community/microsoft-teams/src/lib/auth.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/auth.ts@@ -1,10 +1,19 @@-import {- PieceAuth,- PiecePropValueSchema,- Property,-} from '@activepieces/pieces-framework';-import { microsoftCloudProperty } from './common/microsoft-cloud';-import { createGraphClient, withGraphRetry } from './common/graph';+import { PieceAuth, Property } from '@activepieces/pieces-framework';+import { microsoftTeamsClient } from './common/client';++const cloudProperty = Property.StaticDropdown({+ displayName: 'Cloud Environment',+ description: 'Select your Microsoft cloud environment.',+ required: true,+ defaultValue: 'login.microsoftonline.com',+ options: {+ disabled: false,+ options: [+ { label: 'Commercial (Global)', value: 'login.microsoftonline.com' },+ { label: 'US Government (GCC High)', value: 'login.microsoftonline.us' },+ ],+ },+});const authDesc = `When you connect, Activepieces shows a **permissions** selector. Tick only the@@ -26,7 +35,7 @@ Leave **Tenant ID** as \`common\` for the default multi-tenant flow, or set it texport const microsoftTeamsAuth = PieceAuth.OAuth2({description: authDesc,props: {- cloud: microsoftCloudProperty,+ cloud: cloudProperty,tenantId: Property.ShortText({displayName: 'Tenant ID',description:@@ -53,7 +62,6 @@ export const microsoftTeamsAuth = PieceAuth.OAuth2({'TeamMember.Read.All','User.ReadBasic.All','Presence.Read.All',- // 'OnlineMeetings.Read','OnlineMeetingTranscript.Read.All','OnlineMeetingRecording.Read.All',],@@ -62,10 +70,10 @@ export const microsoftTeamsAuth = PieceAuth.OAuth2({tokenUrl: 'https://{cloud}/{tenantId}/oauth2/v2.0/token',validate: async ({ auth }) => {try {- const authValue = auth as PiecePropValueSchema<typeof microsoftTeamsAuth>;- const cloud = authValue.props?.['cloud'] as string | undefined;- const client = createGraphClient(authValue.access_token, cloud);- await withGraphRetry(() => client.api('/me').get());+ const client = microsoftTeamsClient.create({+ auth: { access_token: auth.access_token, props: auth.props },+ });+ await microsoftTeamsClient.withRetry(() => client.api('/me').get());return { valid: true };} catch (error) {return { valid: false, error: 'Invalid Credentials.' };diff --git a/packages/pieces/community/microsoft-teams/src/lib/common/ai-props.ts b/packages/pieces/community/microsoft-teams/src/lib/common/ai-props.tsnew file mode 100644index 00000000000..ffb0396c4d4--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/common/ai-props.ts@@ -0,0 +1,99 @@+import { Property } from '@activepieces/pieces-framework';++import type { PropParams } from './props';++function teamId<R extends boolean>({+ required,+ displayName = 'Team ID',+ description = 'The team ID, from List Joined Teams.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function channelId<R extends boolean>({+ required,+ displayName = 'Channel ID',+ description = 'The channel ID, from List Channels.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function chatId<R extends boolean>({+ required,+ displayName = 'Chat ID',+ description = 'The chat ID, from List Chats.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function userId<R extends boolean>({+ required,+ displayName = 'User ID',+ description = 'The user ID or user principal name, from List Users.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function meetingId<R extends boolean>({+ required,+ displayName = 'Meeting ID',+ description = 'The online meeting ID of a meeting the signed-in user organized (the long ID, not the numeric join ID or the join URL).',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function contentType() {+ return Property.StaticDropdown({+ displayName: 'Content Type',+ description: 'text or html. Must be html when Mentions is not empty.',+ required: true,+ defaultValue: 'text',+ options: {+ disabled: false,+ options: [+ { label: 'Text', value: 'text' },+ { label: 'HTML', value: 'html' },+ ],+ },+ });+}++function mentions() {+ return Property.Array({+ displayName: 'Mentions',+ description:+ 'Users to @mention. Item N must appear in Content as <at id="N">displayName</at> (N starts at 0), and Content Type must be html.',+ required: false,+ properties: {+ userId: Property.ShortText({+ displayName: 'User ID',+ description: 'The mentioned user ID (GUID), from List Team Members or List Users.',+ required: true,+ }),+ displayName: Property.ShortText({+ displayName: 'Display Name',+ description: 'The name shown for the mention; the same text as inside its <at> tag.',+ required: true,+ }),+ },+ });+}++function limit({ max, defaultValue }: { max: number; defaultValue: number }) {+ return Property.Number({+ displayName: 'Limit',+ description: `How many items to return on this page, 1 to ${max}. Defaults to ${defaultValue}.`,+ required: false,+ defaultValue,+ });+}++function nextLink() {+ return Property.ShortText({+ displayName: 'Next Page Link',+ description: 'The @odata.nextLink from the previous page. Leave empty for the first page.',+ required: false,+ });+}++export const microsoftTeamsAiProps = { teamId, channelId, chatId, userId, meetingId, contentType, mentions, limit, nextLink };diff --git a/packages/pieces/community/microsoft-teams/src/lib/common/api.ts b/packages/pieces/community/microsoft-teams/src/lib/common/api.tsnew file mode 100644index 00000000000..aebb0dd246e--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/common/api.ts@@ -0,0 +1,29 @@+import type { Client } from '@microsoft/microsoft-graph-client';++import type { MicrosoftTeamsPage } from './types';++async function resolveMeetingId({+ client,+ identifierType,+ identifierValue,+}: {+ client: Client;+ identifierType: string;+ identifierValue: string;+}): Promise<string> {+ if (identifierType === 'meetingId') return identifierValue;+ const filter =+ identifierType === 'joinWebUrl'+ ? `JoinWebUrl eq '${identifierValue}'`+ : `joinMeetingIdSettings/joinMeetingId eq '${identifierValue}'`;+ const response: MicrosoftTeamsPage<{ id: string }> = await client+ .api('/me/onlineMeetings')+ .filter(filter)+ .get();+ if (!response.value?.length) {+ throw new Error('No meeting found with the provided identifier.');+ }+ return response.value[0].id;+}++export const microsoftTeamsApi = { resolveMeetingId };diff --git a/packages/pieces/community/microsoft-teams/src/lib/common/client.ts b/packages/pieces/community/microsoft-teams/src/lib/common/client.tsnew file mode 100644index 00000000000..43b2c60fd26--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/common/client.ts@@ -0,0 +1,195 @@+import { tryCatch } from '@activepieces/pieces-framework';+import { Client, ResponseType } from '@microsoft/microsoft-graph-client';++import type {+ MicrosoftTeamsAuthValue,+ MicrosoftTeamsGraphError,+ MicrosoftTeamsPage,+ MicrosoftTeamsTokenClaims,+} from './types';++function graphUrl({ auth }: { auth: MicrosoftTeamsAuthValue }): string {+ const host = auth.props?.cloud ?? COMMERCIAL_LOGIN_HOST;+ return GRAPH_BASE_URLS[host] ?? GRAPH_BASE_URLS[COMMERCIAL_LOGIN_HOST];+}++function baseUrl({ auth }: { auth: MicrosoftTeamsAuthValue }): string {+ return `${graphUrl({ auth })}/v1.0/teams`;+}++function create({ auth }: { auth: MicrosoftTeamsAuthValue }): Client {+ return Client.initWithMiddleware({+ authProvider: {+ getAccessToken: () => Promise.resolve(auth.access_token),+ },+ baseUrl: graphUrl({ auth }),+ });+}++async function withRetry<T>(requestFn: () => Promise<T>): Promise<T> {+ let attempt = 0;+ let delayMs = INITIAL_DELAY_MS;++ while (attempt <= MAX_RETRIES) {+ try {+ return await requestFn();+ } catch (e) {+ const error: MicrosoftTeamsGraphError = typeof e === 'object' && e !== null ? e : {};+ const status = extractStatusCode({ error });+ const code = error.body?.error?.code ?? error.error?.code ?? error.code;+ if (attempt < MAX_RETRIES && shouldRetry({ statusCode: status, code })) {+ const retryAfterMs = parseRetryAfterMs({ error });+ await delay({ ms: Math.min(retryAfterMs ?? delayMs, MAX_DELAY_MS) });+ attempt++;+ if (!retryAfterMs) {+ delayMs = Math.min(delayMs * 2, MAX_DELAY_MS);+ }+ continue;+ }+ throw new Error(buildGraphErrorMessage({ error }));+ }+ }+ throw new Error('Unexpected error occured');+}++async function paginate<T>({+ auth,+ path,+ pageSize,+ maxItems,+ expand,+}: {+ auth: MicrosoftTeamsAuthValue;+ path: string;+ pageSize?: number;+ maxItems: number;+ expand?: string;+}): Promise<{ items: T[]; error: Error | null }> {+ const client = create({ auth });+ const items: T[] = [];+ const { error } = await tryCatch(async () => {+ let firstRequest = client.api(path);+ if (pageSize !== undefined) firstRequest = firstRequest.top(pageSize);+ if (expand) firstRequest = firstRequest.expand(expand);+ let response: MicrosoftTeamsPage<T> = await withRetry(() => firstRequest.get());+ while (response.value && response.value.length > 0) {+ for (const item of response.value) {+ items.push(item);+ if (items.length >= maxItems) break;+ }+ if (items.length >= maxItems) break;+ const nextLink = response['@odata.nextLink'];+ if (!nextLink) break;+ response = await withRetry(() => client.api(nextLink).get());+ }+ });+ return { items, error };+}++async function list<T>({+ auth,+ path,+ page,+ filter,+ nextLink,+}: {+ auth: MicrosoftTeamsAuthValue;+ path: string;+ page?: { limit: number | undefined; max: number; defaultValue: number };+ filter?: string;+ nextLink?: string;+}): Promise<MicrosoftTeamsPage<T>> {+ const client = create({ auth });+ if (nextLink) {+ assertGraphUrl({ auth, url: nextLink });+ return await withRetry(() => client.api(nextLink).get());+ }+ let request = client.api(path);+ if (page) request = request.top(Math.min(Math.max(Math.trunc(page.limit ?? page.defaultValue), 1), page.max));+ if (filter) request = request.filter(filter);+ return await withRetry(() => request.get());+}++async function getText({ auth, path, accept }: { auth: MicrosoftTeamsAuthValue; path: string; accept: string }): Promise<string> {+ const client = create({ auth });+ return await withRetry(() => client.api(path).header('Accept', accept).responseType(ResponseType.TEXT).get());+}++async function getBase64({ auth, path }: { auth: MicrosoftTeamsAuthValue; path: string }): Promise<string> {+ const client = create({ auth });+ const bytes: ArrayBuffer = await withRetry(() => client.api(path).responseType(ResponseType.ARRAYBUFFER).get());+ return Buffer.from(bytes).toString('base64');+}++async function signedInUser({ auth }: { auth: MicrosoftTeamsAuthValue }): Promise<{ id: string; tenantId: string }> {+ const payload = auth.access_token.split('.')[1] ?? '';+ const { data: claims } = await tryCatch(async (): Promise<MicrosoftTeamsTokenClaims> => JSON.parse(Buffer.from(payload, 'base64url').toString('utf8')));+ if (!claims?.oid || !claims.tid) {+ throw new Error('Could not read the signed-in user from the connection. Reconnect the Microsoft Teams connection.');+ }+ return { id: claims.oid, tenantId: claims.tid };+}++function assertGraphUrl({ auth, url }: { auth: MicrosoftTeamsAuthValue; url: string }): void {+ const origin = URL.canParse(url) ? new URL(url).origin : null;+ if (origin !== graphUrl({ auth })) {+ throw new Error(`Next Page Link must be an @odata.nextLink returned by a previous page (it starts with ${graphUrl({ auth })}/).`);+ }+}++async function delay({ ms }: { ms: number }): Promise<void> {+ return new Promise((resolve) => setTimeout(resolve, ms));+}++function parseRetryAfterMs({ error }: { error: MicrosoftTeamsGraphError }): number | null {+ const headers = error.headers ?? error.response?.headers ?? undefined;+ const retryAfter = headers?.['Retry-After'] ?? headers?.['retry-after'];+ if (!retryAfter) return null;+ const asNumber = Number(retryAfter);+ if (!Number.isNaN(asNumber)) return asNumber * 1000;+ const retryDate = Date.parse(retryAfter);+ if (!Number.isNaN(retryDate)) {+ return Math.max(0, retryDate - Date.now());+ }+ return null;+}++function extractStatusCode({ error }: { error: MicrosoftTeamsGraphError }): number {+ return (+ error.statusCode ??+ error.status ??+ error.response?.status ??+ error.response?.statusCode ??+ 0+ );+}++function shouldRetry({ statusCode, code }: { statusCode: number; code?: string }): boolean {+ if (statusCode === 429 || statusCode === 503 || statusCode === 504) return true;+ if (statusCode >= 500 && statusCode < 600) return true;+ if (code && /too\s*many\s*requests/i.test(code)) return true;+ return false;+}++function buildGraphErrorMessage({ error }: { error: MicrosoftTeamsGraphError }): string {+ const status = extractStatusCode({ error });+ const err = error.body?.error ?? error.error ?? {};+ const code = err.code ?? error.code;+ const message = err.message ?? error.message ?? 'Request failed';+ const inner = err.innerError ?? err.innererror ?? {};+ const requestId = inner['request-id'] ?? inner.requestId ?? error.requestId;+ return `Graph error (${status}${code ? ` ${code}` : ''})${requestId ? ` [request-id: ${requestId}]` : ''}: ${message}`;+}++export const microsoftTeamsClient = { graphUrl, baseUrl, create, withRetry, paginate, list, getText, getBase64, signedInUser };++const COMMERCIAL_LOGIN_HOST = 'login.microsoftonline.com';++const GRAPH_BASE_URLS: Record<string, string> = {+ [COMMERCIAL_LOGIN_HOST]: 'https://graph.microsoft.com',+ 'login.microsoftonline.us': 'https://graph.microsoft.us',+};++const MAX_RETRIES = 3;+const INITIAL_DELAY_MS = 1000;+const MAX_DELAY_MS = 10000;diff --git a/packages/pieces/community/microsoft-teams/src/lib/common/graph.ts b/packages/pieces/community/microsoft-teams/src/lib/common/graph.tsdeleted file mode 100644index 8f6d3047926..00000000000--- a/packages/pieces/community/microsoft-teams/src/lib/common/graph.ts+++ /dev/null@@ -1,157 +0,0 @@-import { Client, PageCollection } from '@microsoft/microsoft-graph-client';-import { tryCatch } from '@activepieces/pieces-framework';-import { getGraphBaseUrl } from './microsoft-cloud';--type GraphRetryOptions = {- maxRetries?: number;- initialDelayMs?: number;- maxDelayMs?: number;-};--export const createGraphClient = (accessToken: string, cloud?: string | null): Client => {- return Client.initWithMiddleware({- authProvider: {- getAccessToken: () => Promise.resolve(accessToken),- },- baseUrl: getGraphBaseUrl(cloud),- });-};--const delay = async (ms: number): Promise<void> =>- new Promise((resolve) => setTimeout(resolve, ms));--const parseRetryAfterMs = (error: any): number | null => {- const headers: Record<string, string> | undefined =- error?.headers ?? error?.response?.headers ?? undefined;- const retryAfter = headers?.['Retry-After'] ?? headers?.['retry-after'];- if (!retryAfter) return null;- const asNumber = Number(retryAfter);- if (!Number.isNaN(asNumber)) return asNumber * 1000;- // Retry-After can be HTTP-date; in that case, compute delta- const retryDate = Date.parse(retryAfter);- if (!Number.isNaN(retryDate)) {- return Math.max(0, retryDate - Date.now());- }- return null;-};--const extractStatusCode = (error: any): number => {- return (- error?.statusCode ??- error?.status ??- error?.response?.status ??- error?.response?.statusCode ??- 0- );-};--const shouldRetry = (statusCode: number, code?: string): boolean => {- // Retry on throttling and transient errors- if (statusCode === 429 || statusCode === 503 || statusCode === 504) return true;- // Optionally retry generic server errors- if (statusCode >= 500 && statusCode < 600) return true;- // Some SDKs surface codes like 'TooManyRequests'- if (code && /too\s*many\s*requests/i.test(code)) return true;- return false;-};--export const buildGraphErrorMessage = (error: any): string => {- const status = extractStatusCode(error);- const err = error?.body?.error ?? error?.error ?? {};- const code = err?.code ?? error?.code;- const message = err?.message ?? error?.message ?? 'Request failed';- const inner = err?.innerError ?? err?.innererror ?? {};- const requestId = inner?.['request-id'] ?? inner?.requestId ?? error?.requestId;- return `Graph error (${status}${code ? ` ${code}` : ''})${requestId ? ` [request-id: ${requestId}]` : ''}: ${message}`;-};--export const resolveMeetingId = async ({- client,- identifierType,- identifierValue,-}: {- client: Client;- identifierType: string;- identifierValue: string;-}): Promise<string> => {- if (identifierType === 'meetingId') return identifierValue;- const filter =- identifierType === 'joinWebUrl'- ? `JoinWebUrl eq '${identifierValue}'`- : `joinMeetingIdSettings/joinMeetingId eq '${identifierValue}'`;- const response = await client.api('/me/onlineMeetings').filter(filter).get();- if (!response.value?.length) {- throw new Error('No meeting found with the provided identifier.');- }- return response.value[0].id as string;-};--export const withGraphRetry = async <T>(- requestFn: () => Promise<T>,- options: GraphRetryOptions = {}-): Promise<T> => {- const maxRetries = options.maxRetries ?? 3;- const initialDelayMs = options.initialDelayMs ?? 1000;- const maxDelayMs = options.maxDelayMs ?? 10000;-- let attempt = 0;- let delayMs = initialDelayMs;-- while (attempt <= maxRetries) {- try {- return await requestFn();- } catch (e: any) {- const status = extractStatusCode(e);- const code = e?.body?.error?.code ?? e?.error?.code ?? e?.code;- if (attempt < maxRetries && shouldRetry(status, code)) {- const retryAfterMs = parseRetryAfterMs(e);- await delay(Math.min(retryAfterMs ?? delayMs, maxDelayMs));- attempt++;- if (!retryAfterMs) {- delayMs = Math.min(delayMs * 2, maxDelayMs);- }- continue;- }- throw new Error(buildGraphErrorMessage(e));- }- }- throw new Error("Unexpected error occured");-};--// Walks a paginated Graph list endpoint with retry, an item cap, and graceful failure.-// Returns whatever was collected before an error or the cap; the cap protects the 60s-// dropdown sandbox timeout from runaway pagination on accounts with very large lists.-export const paginateGraphList = async <T>(params: {- client: Client;- initialUrl: string;- // Omit on endpoints that don't support OData $top (e.g. /me/joinedTeams).- pageSize?: number;- maxItems: number;- expand?: string;-}): Promise<{ items: T[]; truncated: boolean; error: Error | null }> => {- const { client, initialUrl, pageSize, maxItems, expand } = params;- const items: T[] = [];- const { error } = await tryCatch(async () => {- let firstRequest = client.api(initialUrl);- if (pageSize !== undefined) firstRequest = firstRequest.top(pageSize);- if (expand) firstRequest = firstRequest.expand(expand);- let response: PageCollection = await withGraphRetry(() => firstRequest.get());- while (response.value && response.value.length > 0) {- for (const item of response.value as T[]) {- items.push(item);- if (items.length >= maxItems) break;- }- if (items.length >= maxItems) break;- const nextLink = response['@odata.nextLink'];- if (!nextLink) break;- response = await withGraphRetry(() => client.api(nextLink).get());- }- });- return {- items,- truncated: items.length >= maxItems,- error,- };-};--diff --git a/packages/pieces/community/microsoft-teams/src/lib/common/index.ts b/packages/pieces/community/microsoft-teams/src/lib/common/index.tsdeleted file mode 100644index 93e08c0fb0c..00000000000--- a/packages/pieces/community/microsoft-teams/src/lib/common/index.ts+++ /dev/null@@ -1,330 +0,0 @@-import { DropdownOption, OAuth2PropertyValue, PiecePropValueSchema, Property } from '@activepieces/pieces-framework';--import { PageCollection } from '@microsoft/microsoft-graph-client';-import { Team, Channel, Chat, ConversationMember, CallTranscript, CallRecording } from '@microsoft/microsoft-graph-types';-import { microsoftTeamsAuth } from '../auth';-import { createGraphClient, paginateGraphList, resolveMeetingId } from './graph';--export const microsoftTeamsCommon = {- teamId: Property.Dropdown({- auth: microsoftTeamsAuth,- displayName: 'Team ID',- refreshers: [],- required: true,- options: async ({ auth }) => {- if (!auth) {- return {- disabled: true,- placeholder: 'Please connect your account first.',- options: [],- };- }- const authValue = auth as PiecePropValueSchema<typeof microsoftTeamsAuth>;- const cloud = (auth as OAuth2PropertyValue).props?.['cloud'] as string | undefined;- const client = createGraphClient(authValue.access_token, cloud);-- // List Joined Teams : https://learn.microsoft.com/en-us/graph/api/user-list-joinedteams?view=graph-rest-1.0&tabs=http- // Note: this endpoint does not support OData $top — pageSize intentionally omitted.- const { items, error } = await paginateGraphList<Team>({- client,- initialUrl: '/me/joinedTeams',- maxItems: DROPDOWN_LIST_MAX,- });-- if (error && items.length === 0) {- return {- disabled: true,- placeholder: "Couldn't load teams — please retry.",- options: [],- };- }-- return {- disabled: false,- options: items.map((team) => ({ label: team.displayName!, value: team.id! })),- };- },- }),- channelId: Property.Dropdown({- auth: microsoftTeamsAuth,- displayName: 'Channel ID',- refreshers: ['teamId'],- required: true,- options: async ({ auth, teamId }) => {- if (!auth || !teamId) {- return {- disabled: true,- placeholder: 'Please connect your account first and select team.',- options: [],- };- }- const authValue = auth as PiecePropValueSchema<typeof microsoftTeamsAuth>;- const cloud = (auth as OAuth2PropertyValue).props?.['cloud'] as string | undefined;- const client = createGraphClient(authValue.access_token, cloud);-- // List Channels : https://learn.microsoft.com/en-us/graph/api/channel-list?view=graph-rest-1.0&tabs=http- // Note: this endpoint does not support OData $top — pageSize intentionally omitted.- const { items, error } = await paginateGraphList<Channel>({- client,- initialUrl: `/teams/${teamId}/channels`,- maxItems: DROPDOWN_LIST_MAX,- });-- if (error && items.length === 0) {- return {- disabled: true,- placeholder: "Couldn't load channels — please retry.",- options: [],- };- }-- return {- disabled: false,- options: items.map((channel) => ({ label: channel.displayName!, value: channel.id! })),- };- },- }),- memberId: (isRequired = false) => Property.Dropdown({- auth: microsoftTeamsAuth,- displayName: 'Member',- refreshers: ['teamId'],- required: isRequired,- options: async ({ auth, teamId }) => {- if (!auth || !teamId) {- return {- disabled: true,- placeholder: 'Please connect your account first and select team.',- options: [],- };- }- const authValue = auth as PiecePropValueSchema<typeof microsoftTeamsAuth>;- const cloud = (auth as OAuth2PropertyValue).props?.['cloud'] as string | undefined;- const client = createGraphClient(authValue.access_token, cloud);-- // Default page size on /teams/{id}/members is 100; explicit top() is- // intentionally omitted to stay compatible with this endpoint's OData support.- const { items, error } = await paginateGraphList<ConversationMember>({- client,- initialUrl: `/teams/${teamId}/members`,- maxItems: DROPDOWN_LIST_MAX,- });-- if (error && items.length === 0) {- return {- disabled: true,- placeholder: "Couldn't load members — please retry.",- options: [],- };- }-- return {- disabled: false,- options: items.map((member) => ({ label: member.displayName!, value: member.id! })),- };- },- }),- memberIds: (isRequired = false) => Property.MultiSelectDropdown({- auth: microsoftTeamsAuth,- displayName: 'Member',- refreshers: ['teamId'],- required: isRequired,- options: async ({ auth, teamId }) => {- if (!auth || !teamId) {- return {- disabled: true,- placeholder: 'Please connect your account first and select team.',- options: [],- };- }- const authValue = auth as PiecePropValueSchema<typeof microsoftTeamsAuth>;- const cloud = (auth as OAuth2PropertyValue).props?.['cloud'] as string | undefined;- const client = createGraphClient(authValue.access_token, cloud);-- // Default page size on /teams/{id}/members is 100; explicit top() is- // intentionally omitted to stay compatible with this endpoint's OData support.- const { items, error } = await paginateGraphList<ConversationMember>({- client,- initialUrl: `/teams/${teamId}/members`,- maxItems: DROPDOWN_LIST_MAX,- });-- if (error && items.length === 0) {- return {- disabled: true,- placeholder: "Couldn't load members — please retry.",- options: [],- };- }-- return {- disabled: false,- options: items.map((member) => ({ label: member.displayName!, value: member.id! })),- };- },- }),- // https://learn.microsoft.com/en-us/answers/questions/1858332/get-list-of-online-meetings-for-teams- meetingIdentifierType: Property.StaticDropdown({- displayName: 'Meeting Identifier Type',- description: 'Choose how to identify the meeting.',- required: true,- defaultValue: 'meetingId',- options: {- disabled: false,- options: [- { label: 'Meeting ID', value: 'meetingId' },- { label: 'Join Web URL', value: 'joinWebUrl' },- { label: 'Join Meeting ID', value: 'joinMeetingId' },- ],- },- }),- meetingIdentifierValue: Property.ShortText({- displayName: 'Meeting Identifier Value',- required: true,- }),- transcriptId: Property.Dropdown({- auth: microsoftTeamsAuth,- displayName: 'Transcript',- refreshers: ['meetingIdentifierType', 'meetingIdentifierValue'],- required: false,- options: async ({ auth, meetingIdentifierType, meetingIdentifierValue }) => {- if (!auth || !meetingIdentifierType || !meetingIdentifierValue) {- return {- disabled: true,- placeholder: 'Please connect your account first and select a meeting.',- options: [],- };- }- const authValue = auth as PiecePropValueSchema<typeof microsoftTeamsAuth>;- const cloud = (auth as OAuth2PropertyValue).props?.['cloud'] as string | undefined;- const client = createGraphClient(authValue.access_token, cloud);- const options: DropdownOption<string>[] = [];-- const meetingId = await resolveMeetingId({- client,- identifierType: meetingIdentifierType as string,- identifierValue: meetingIdentifierValue as string,- });-- // https://learn.microsoft.com/en-us/graph/api/onlinemeeting-list-transcripts?view=graph-rest-1.0- let response: PageCollection = await client.api(`/me/onlineMeetings/${meetingId}/transcripts`).get();- while (response.value.length > 0) {- for (const transcript of response.value as CallTranscript[]) {- const label = transcript.createdDateTime- ? new Date(transcript.createdDateTime).toLocaleString()- : transcript.id!;- options.push({ label, value: transcript.id! });- }- if (response['@odata.nextLink']) {- response = await client.api(response['@odata.nextLink']).get();- } else {- break;- }- }- return { disabled: false, options };- },- }),- recordingId: Property.Dropdown({- auth: microsoftTeamsAuth,- displayName: 'Recording',- refreshers: ['meetingIdentifierType', 'meetingIdentifierValue'],- required: false,- options: async ({ auth, meetingIdentifierType, meetingIdentifierValue }) => {- if (!auth || !meetingIdentifierType || !meetingIdentifierValue) {- return {- disabled: true,- placeholder: 'Please connect your account first and select a meeting.',- options: [],- };- }- const authValue = auth as PiecePropValueSchema<typeof microsoftTeamsAuth>;- const cloud = (auth as OAuth2PropertyValue).props?.['cloud'] as string | undefined;- const client = createGraphClient(authValue.access_token, cloud);- const options: DropdownOption<string>[] = [];-- const meetingId = await resolveMeetingId({- client,- identifierType: meetingIdentifierType as string,- identifierValue: meetingIdentifierValue as string,- });-- // https://learn.microsoft.com/en-us/graph/api/onlinemeeting-list-recordings?view=graph-rest-1.0- let response: PageCollection = await client.api(`/me/onlineMeetings/${meetingId}/recordings`).get();- while (response.value.length > 0) {- for (const recording of response.value as CallRecording[]) {- const label = recording.createdDateTime- ? new Date(recording.createdDateTime).toLocaleString()- : recording.id!;- options.push({ label, value: recording.id! });- }- if (response['@odata.nextLink']) {- response = await client.api(response['@odata.nextLink']).get();- } else {- break;- }- }- return { disabled: false, options };- },- }),- chatId: Property.Dropdown({- auth: microsoftTeamsAuth,- displayName: 'Chat ID',- refreshers: [],- required: true,- options: async ({ auth }) => {- if (!auth) {- return {- disabled: true,- placeholder: 'Please connect your account first and select team.',- options: [],- };- }- const authValue = auth as PiecePropValueSchema<typeof microsoftTeamsAuth>;- const cloud = (auth as OAuth2PropertyValue).props?.['cloud'] as string | undefined;- const client = createGraphClient(authValue.access_token, cloud);-- // List Chats : https://learn.microsoft.com/en-us/graph/api/chat-list?view=graph-rest-1.0&tabs=http- // Cap protects the 60s sandbox timeout and Graph throttling on /chats?$expand=members.- const { items, error } = await paginateGraphList<Chat>({- client,- initialUrl: '/chats',- expand: 'members',- pageSize: CHATS_PAGE_SIZE,- maxItems: DROPDOWN_LIST_MAX,- });-- if (error && items.length === 0) {- return {- disabled: true,- placeholder: "Couldn't load chats — please retry.",- options: [],- };- }-- return {- disabled: false,- options: items.map((chat) => {- const chatName =- chat.topic ??- chat.members- ?.filter((member: ConversationMember) => member.displayName)- .map((member: ConversationMember) => member.displayName)- .join(',');- return {- label: `(${CHAT_TYPE[chat.chatType! as keyof typeof CHAT_TYPE]} Chat) ${chatName || '(no title)'}`,- value: chat.id!,- };- }),- };- },- }),-};--const CHAT_TYPE = {- oneOnOne: '1 : 1',- group: 'Group',- meeting: 'Meeting',- unknownFutureValue: 'Unknown',-};--const CHATS_PAGE_SIZE = 50;-const DROPDOWN_LIST_MAX = 500;diff --git a/packages/pieces/community/microsoft-teams/src/lib/common/microsoft-cloud.ts b/packages/pieces/community/microsoft-teams/src/lib/common/microsoft-cloud.tsdeleted file mode 100644index 065a7056060..00000000000--- a/packages/pieces/community/microsoft-teams/src/lib/common/microsoft-cloud.ts+++ /dev/null@@ -1,36 +0,0 @@-import { OAuth2PropertyValue, Property } from '@activepieces/pieces-framework';--const COMMERCIAL_LOGIN_HOST = 'login.microsoftonline.com';-const GOV_LOGIN_HOST = 'login.microsoftonline.us';--const GRAPH_BASE_URLS: Record<string, string> = {- [COMMERCIAL_LOGIN_HOST]: 'https://graph.microsoft.com',- [GOV_LOGIN_HOST]: 'https://graph.microsoft.us',-};--export const microsoftCloudProperty = Property.StaticDropdown({- displayName: 'Cloud Environment',- description: 'Select your Microsoft cloud environment.',- required: true,- defaultValue: COMMERCIAL_LOGIN_HOST,- options: {- disabled: false,- options: [- { label: 'Commercial (Global)', value: COMMERCIAL_LOGIN_HOST },- { label: 'US Government (GCC High)', value: GOV_LOGIN_HOST },- ],- },-});--function resolveCloudHost(cloudLoginHost: string | undefined | null): string {- return cloudLoginHost ?? COMMERCIAL_LOGIN_HOST;-}--export function getMicrosoftCloudFromAuth(auth: OAuth2PropertyValue): string {- return resolveCloudHost(auth.props?.['cloud'] as string | undefined);-}--export function getGraphBaseUrl(cloudLoginHost: string | undefined | null): string {- const host = resolveCloudHost(cloudLoginHost);- return GRAPH_BASE_URLS[host] ?? GRAPH_BASE_URLS[COMMERCIAL_LOGIN_HOST];-}diff --git a/packages/pieces/community/microsoft-teams/src/lib/common/props.ts b/packages/pieces/community/microsoft-teams/src/lib/common/props.tsnew file mode 100644index 00000000000..434f8a19c16--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/common/props.ts@@ -0,0 +1,294 @@+import { DropdownOption, DropdownState, Property } from '@activepieces/pieces-framework';++import { microsoftTeamsAuth } from '../auth';+import { microsoftTeamsApi } from './api';+import { microsoftTeamsClient } from './client';++import type {+ CallRecording,+ CallTranscript,+ Channel,+ Chat,+ ConversationMember,+ MicrosoftTeamsPage,+ Team,+} from './types';++function teamId<R extends boolean>({ required, displayName = 'Team ID', description }: PropParams<R>) {+ return Property.Dropdown({+ auth: microsoftTeamsAuth,+ displayName,+ description,+ refreshers: [],+ required,+ options: async ({ auth }) => {+ if (!auth) {+ return disabledOptions({ placeholder: 'Please connect your account first.' });+ }+ const { items, error } = await microsoftTeamsClient.paginate<Team>({+ auth,+ path: '/me/joinedTeams',+ maxItems: DROPDOWN_LIST_MAX,+ });++ if (error && items.length === 0) {+ return disabledOptions({ placeholder: "Couldn't load teams — please retry." });+ }++ return {+ disabled: false,+ options: items.map((team) => ({ label: team.displayName ?? '', value: team.id ?? '' })),+ };+ },+ });+}++function channelId<R extends boolean>({ required, displayName = 'Channel ID', description }: PropParams<R>) {+ return Property.Dropdown({+ auth: microsoftTeamsAuth,+ displayName,+ description,+ refreshers: ['teamId'],+ required,+ options: async ({ auth, teamId }) => {+ if (!auth || !teamId) {+ return disabledOptions({ placeholder: 'Please connect your account first and select team.' });+ }+ const { items, error } = await microsoftTeamsClient.paginate<Channel>({+ auth,+ path: `/teams/${teamId}/channels`,+ maxItems: DROPDOWN_LIST_MAX,+ });++ if (error && items.length === 0) {+ return disabledOptions({ placeholder: "Couldn't load channels — please retry." });+ }++ return {+ disabled: false,+ options: items.map((channel) => ({ label: channel.displayName ?? '', value: channel.id ?? '' })),+ };+ },+ });+}++function memberIds<R extends boolean>({ required, displayName = 'Member', description }: PropParams<R>) {+ return Property.MultiSelectDropdown({+ auth: microsoftTeamsAuth,+ displayName,+ description,+ refreshers: ['teamId'],+ required,+ options: async ({ auth, teamId }) => {+ if (!auth || !teamId) {+ return disabledOptions({ placeholder: 'Please connect your account first and select team.' });+ }+ const { items, error } = await microsoftTeamsClient.paginate<ConversationMember>({+ auth,+ path: `/teams/${teamId}/members`,+ maxItems: DROPDOWN_LIST_MAX,+ });++ if (error && items.length === 0) {+ return disabledOptions({ placeholder: "Couldn't load members — please retry." });+ }++ return {+ disabled: false,+ options: items.map((member) => ({ label: member.displayName ?? '', value: member.id ?? '' })),+ };+ },+ });+}++function chatId<R extends boolean>({ required, displayName = 'Chat ID', description }: PropParams<R>) {+ return Property.Dropdown({+ auth: microsoftTeamsAuth,+ displayName,+ description,+ refreshers: [],+ required,+ options: async ({ auth }) => {+ if (!auth) {+ return disabledOptions({ placeholder: 'Please connect your account first and select team.' });+ }+ const { items, error } = await microsoftTeamsClient.paginate<Chat>({+ auth,+ path: '/chats',+ expand: 'members',+ pageSize: CHATS_PAGE_SIZE,+ maxItems: DROPDOWN_LIST_MAX,+ });++ if (error && items.length === 0) {+ return disabledOptions({ placeholder: "Couldn't load chats — please retry." });+ }++ return {+ disabled: false,+ options: items.map((chat) => {+ const chatName =+ chat.topic ??+ chat.members+ ?.filter((member: ConversationMember) => member.displayName)+ .map((member: ConversationMember) => member.displayName)+ .join(',');+ return {+ label: `(${chat.chatType ? CHAT_TYPE[chat.chatType] : undefined} Chat) ${chatName || '(no title)'}`,+ value: chat.id ?? '',+ };+ }),+ };+ },+ });+}++function meetingIdentifierType<R extends boolean>({+ required,+ displayName = 'Meeting Identifier Type',+ description = 'Choose how to identify the meeting.',+}: PropParams<R>) {+ return Property.StaticDropdown({+ displayName,+ description,+ required,+ defaultValue: 'meetingId',+ options: {+ disabled: false,+ options: [+ { label: 'Meeting ID', value: 'meetingId' },+ { label: 'Join Web URL', value: 'joinWebUrl' },+ { label: 'Join Meeting ID', value: 'joinMeetingId' },+ ],+ },+ });+}++function meetingIdentifierValue<R extends boolean>({+ required,+ displayName = 'Meeting Identifier Value',+ description,+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function transcriptId<R extends boolean>({ required, displayName = 'Transcript', description }: PropParams<R>) {+ return Property.Dropdown({+ auth: microsoftTeamsAuth,+ displayName,+ description,+ refreshers: ['meetingIdentifierType', 'meetingIdentifierValue'],+ required,+ options: async ({ auth, meetingIdentifierType, meetingIdentifierValue }) => {+ if (+ !auth ||+ !meetingIdentifierType ||+ !meetingIdentifierValue ||+ typeof meetingIdentifierType !== 'string' ||+ typeof meetingIdentifierValue !== 'string'+ ) {+ return disabledOptions({ placeholder: 'Please connect your account first and select a meeting.' });+ }+ const client = microsoftTeamsClient.create({ auth });+ const options: DropdownOption<string>[] = [];++ const meetingId = await microsoftTeamsApi.resolveMeetingId({+ client,+ identifierType: meetingIdentifierType,+ identifierValue: meetingIdentifierValue,+ });++ let response: MicrosoftTeamsPage<CallTranscript> = await client+ .api(`/me/onlineMeetings/${meetingId}/transcripts`)+ .get();+ while (response.value.length > 0) {+ for (const transcript of response.value) {+ const label = transcript.createdDateTime+ ? new Date(transcript.createdDateTime).toLocaleString()+ : transcript.id ?? '';+ options.push({ label, value: transcript.id ?? '' });+ }+ if (response['@odata.nextLink']) {+ response = await client.api(response['@odata.nextLink']).get();+ } else {+ break;+ }+ }+ return { disabled: false, options };+ },+ });+}++function recordingId<R extends boolean>({ required, displayName = 'Recording', description }: PropParams<R>) {+ return Property.Dropdown({+ auth: microsoftTeamsAuth,+ displayName,+ description,+ refreshers: ['meetingIdentifierType', 'meetingIdentifierValue'],+ required,+ options: async ({ auth, meetingIdentifierType, meetingIdentifierValue }) => {+ if (+ !auth ||+ !meetingIdentifierType ||+ !meetingIdentifierValue ||+ typeof meetingIdentifierType !== 'string' ||+ typeof meetingIdentifierValue !== 'string'+ ) {+ return disabledOptions({ placeholder: 'Please connect your account first and select a meeting.' });+ }+ const client = microsoftTeamsClient.create({ auth });+ const options: DropdownOption<string>[] = [];++ const meetingId = await microsoftTeamsApi.resolveMeetingId({+ client,+ identifierType: meetingIdentifierType,+ identifierValue: meetingIdentifierValue,+ });++ let response: MicrosoftTeamsPage<CallRecording> = await client+ .api(`/me/onlineMeetings/${meetingId}/recordings`)+ .get();+ while (response.value.length > 0) {+ for (const recording of response.value) {+ const label = recording.createdDateTime+ ? new Date(recording.createdDateTime).toLocaleString()+ : recording.id ?? '';+ options.push({ label, value: recording.id ?? '' });+ }+ if (response['@odata.nextLink']) {+ response = await client.api(response['@odata.nextLink']).get();+ } else {+ break;+ }+ }+ return { disabled: false, options };+ },+ });+}++function disabledOptions({ placeholder }: { placeholder: string }): DropdownState<never> {+ return { disabled: true, options: [], placeholder };+}++export const microsoftTeamsProps = {+ teamId,+ channelId,+ memberIds,+ chatId,+ meetingIdentifierType,+ meetingIdentifierValue,+ transcriptId,+ recordingId,+};++const CHAT_TYPE: Record<NonNullable<Chat['chatType']>, string> = {+ oneOnOne: '1 : 1',+ group: 'Group',+ meeting: 'Meeting',+ unknownFutureValue: 'Unknown',+};++const CHATS_PAGE_SIZE = 50;+const DROPDOWN_LIST_MAX = 500;++export type PropParams<R extends boolean> = { required: R; displayName?: string; description?: string };diff --git a/packages/pieces/community/microsoft-teams/src/lib/common/types.ts b/packages/pieces/community/microsoft-teams/src/lib/common/types.tsnew file mode 100644index 00000000000..ebae36fe67a--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/common/types.ts@@ -0,0 +1,64 @@+import type { AadUserConversationMember } from '@microsoft/microsoft-graph-types';++export type {+ CallRecording,+ CallTranscript,+ Channel,+ Chat,+ ChatMessage,+ ConversationMember,+ Team,+} from '@microsoft/microsoft-graph-types';++export type MicrosoftTeamsAuthValue = {+ access_token: string;+ props?: { cloud?: string | null };+};++export type MicrosoftTeamsPage<T> = {+ value: T[];+ '@odata.nextLink'?: string;+ '@odata.deltaLink'?: string;+};++export type MicrosoftTeamsMember = AadUserConversationMember & {+ userPrincipalName?: string;+};++export type MicrosoftTeamsMe = {+ id: string;+ userPrincipalName?: string;+};++export type MicrosoftTeamsTokenClaims = {+ oid?: string;+ tid?: string;+};++export type MicrosoftTeamsGraphError = {+ statusCode?: number;+ status?: number;+ code?: string;+ message?: string;+ requestId?: string;+ headers?: Record<string, string>;+ response?: {+ status?: number;+ statusCode?: number;+ headers?: Record<string, string>;+ };+ error?: MicrosoftTeamsGraphErrorBody;+ body?: { error?: MicrosoftTeamsGraphErrorBody };+};++type MicrosoftTeamsGraphErrorBody = {+ code?: string;+ message?: string;+ innerError?: MicrosoftTeamsGraphInnerError;+ innererror?: MicrosoftTeamsGraphInnerError;+};++type MicrosoftTeamsGraphInnerError = {+ 'request-id'?: string;+ requestId?: string;+};diff --git a/packages/pieces/community/microsoft-teams/src/lib/common/utils.ts b/packages/pieces/community/microsoft-teams/src/lib/common/utils.tsnew file mode 100644index 00000000000..33cf8cebae3--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/common/utils.ts@@ -0,0 +1,61 @@+function buildMessageBody({+ content,+ contentType,+ subject,+ mentions,+}: {+ content: string;+ contentType: string;+ subject?: string;+ mentions: unknown[];+}) {+ const type = CONTENT_TYPES.find((value) => value === contentType);+ if (!type) {+ throw new Error(`Content Type must be one of: ${CONTENT_TYPES.join(', ')}.`);+ }+ const parsed = mentions.map((item, index) => toMention({ item, index }));+ if (parsed.length > 0 && type !== 'html') {+ throw new Error('Mentions need Content Type html, with mention N written as <at id="N">displayName</at> in Content.');+ }+ const missing = parsed.map((_, index) => index).filter((index) => !content.includes(`<at id="${index}">`));+ if (missing.length > 0) {+ throw new Error(+ `Content is missing the mention tag for Mentions index ${missing.join(', ')}; write <at id="N">displayName</at> for each mention N.`,+ );+ }+ return {+ body: { content, contentType: type },+ ...(subject ? { subject } : {}),+ ...(parsed.length > 0+ ? {+ mentions: parsed.map((mention, index) => ({+ id: index,+ mentionText: mention.displayName,+ mentioned: {+ user: { id: mention.userId, displayName: mention.displayName, userIdentityType: 'aadUser' },+ },+ })),+ }+ : {}),+ };+}++function toMention({ item, index }: { item: unknown; index: number }): { userId: string; displayName: string } {+ if (+ typeof item !== 'object' ||+ item === null ||+ !('userId' in item) ||+ !('displayName' in item) ||+ typeof item.userId !== 'string' ||+ typeof item.displayName !== 'string' ||+ !item.userId ||+ !item.displayName+ ) {+ throw new Error(`Mentions item ${index} needs both a User ID and a Display Name.`);+ }+ return { userId: item.userId, displayName: item.displayName };+}++export const microsoftTeamsUtils = { buildMessageBody };++const CONTENT_TYPES = ['text', 'html'] as const;diff --git a/packages/pieces/community/microsoft-teams/src/lib/output-schemas.ts b/packages/pieces/community/microsoft-teams/src/lib/output-schemas.tsnew file mode 100644index 00000000000..1f26d8399b3--- /dev/null+++ b/packages/pieces/community/microsoft-teams/src/lib/output-schemas.ts@@ -0,0 +1,1011 @@+import { OutputSchema } from '@activepieces/pieces-framework';++const meetingOrganizerField: OutputSchema['fields'][number] = {+ key: 'meetingOrganizer',+ label: 'Meeting Organizer',+ children: [+ {+ key: 'user',+ label: 'User',+ children: [+ { key: 'id', label: 'User ID' },+ { key: 'displayName', label: 'Display Name' },+ { key: 'tenantId', label: 'Tenant ID' },+ ],+ },+ ],+};++const callTranscriptFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Transcript ID' },+ { key: 'meetingId', label: 'Meeting ID' },+ { key: 'callId', label: 'Call ID' },+ { key: 'contentCorrelationId', label: 'Content Correlation ID' },+ {+ key: 'transcriptContentUrl',+ label: 'Transcript Content URL',+ format: 'url',+ },+ { key: 'createdDateTime', label: 'Created At', format: 'datetime' },+ { key: 'endDateTime', label: 'Ended At', format: 'datetime' },+ meetingOrganizerField,+];++const callRecordingFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Recording ID' },+ { key: 'meetingId', label: 'Meeting ID' },+ { key: 'callId', label: 'Call ID' },+ { key: 'contentCorrelationId', label: 'Content Correlation ID' },+ { key: 'recordingContentUrl', label: 'Recording Content URL', format: 'url' },+ { key: 'createdDateTime', label: 'Created At', format: 'datetime' },+ { key: 'endDateTime', label: 'Ended At', format: 'datetime' },+ meetingOrganizerField,+];++const odataContextField: Field = {+ key: '@odata.context',+ label: 'OData Context',+ value: "['@odata.context']",+ format: 'url',+};++const odataCountField: Field = {+ key: '@odata.count',+ label: 'Items on This Page',+ value: "['@odata.count']",+ format: 'number',+};++const odataNextLinkField: Field = {+ key: '@odata.nextLink',+ label: 'Next Page Link',+ value: "['@odata.nextLink']",+ format: 'url',+};++const odataIdField: Field = {+ key: '@odata.id',+ label: 'OData ID',+ value: "['@odata.id']",+ format: 'url',+};++const odataTypeField: Field = {+ key: '@odata.type',+ label: 'OData Type',+ value: "['@odata.type']",+};++const identityUserFields: OutputSchema['fields'] = [+ odataTypeField,+ { key: 'id', label: 'User ID' },+ { key: 'displayName', label: 'Display Name' },+ { key: 'userIdentityType', label: 'User Identity Type' },+ { key: 'tenantId', label: 'Tenant ID' },+];++const identitySetFields: OutputSchema['fields'] = [+ { key: 'application', label: 'Application' },+ { key: 'device', label: 'Device' },+ { key: 'user', label: 'User', children: identityUserFields },+];++const channelFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Channel ID' },+ { key: 'createdDateTime', label: 'Created At', format: 'datetime' },+ { key: 'displayName', label: 'Display Name' },+ { key: 'description', label: 'Description' },+ {+ key: 'isFavoriteByDefault',+ label: 'Favorite by Default',+ format: 'boolean',+ },+ { key: 'email', label: 'Channel Email', format: 'email' },+ { key: 'tenantId', label: 'Tenant ID' },+ { key: 'webUrl', label: 'Web URL', format: 'url' },+ { key: 'membershipType', label: 'Membership Type' },+ { key: 'layoutType', label: 'Layout Type' },+ { key: 'isArchived', label: 'Archived', format: 'boolean' },+];++const channelSummaryField: Field = {+ key: 'summary',+ label: 'Summary',+ children: [+ { key: 'ownersCount', label: 'Owners', format: 'number' },+ { key: 'membersCount', label: 'Members', format: 'number' },+ { key: 'guestsCount', label: 'Guests', format: 'number' },+ {+ key: 'hasMembersFromOtherTenants',+ label: 'Has Members From Other Tenants',+ format: 'boolean',+ },+ ],+};++const conversationMemberFields: OutputSchema['fields'] = [+ odataTypeField,+ { key: 'id', label: 'Membership ID' },+ { key: 'roles', label: 'Roles' },+ { key: 'displayName', label: 'Display Name' },+ {+ key: 'visibleHistoryStartDateTime',+ label: 'History Visible From',+ format: 'datetime',+ },+ { key: 'userId', label: 'User ID' },+ { key: 'email', label: 'Email', format: 'email' },+ { key: 'tenantId', label: 'Tenant ID' },+];++const chatScalarFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Chat ID' },+ { key: 'topic', label: 'Topic' },+ { key: 'createdDateTime', label: 'Created At', format: 'datetime' },+ { key: 'lastUpdatedDateTime', label: 'Last Updated At', format: 'datetime' },+ { key: 'chatType', label: 'Chat Type' },+ { key: 'webUrl', label: 'Web URL', format: 'url' },+ { key: 'tenantId', label: 'Tenant ID' },+ {+ key: 'isHiddenForAllMembers',+ label: 'Hidden for All Members',+ format: 'boolean',+ },+];++const viewpointField: Field = {+ key: 'viewpoint',+ label: 'Viewpoint',+ children: [+ { key: 'isHidden', label: 'Hidden', format: 'boolean' },+ {+ key: 'lastMessageReadDateTime',+ label: 'Last Message Read At',+ format: 'datetime',+ },+ ],+};++const onlineMeetingInfoField: Field = {+ key: 'onlineMeetingInfo',+ label: 'Online Meeting Info',+ children: [+ { key: 'calendarEventId', label: 'Calendar Event ID' },+ { key: 'joinWebUrl', label: 'Join URL', format: 'url' },+ {+ key: 'organizer',+ label: 'Organizer',+ children: [+ { key: 'id', label: 'User ID' },+ { key: 'displayName', label: 'Display Name' },+ { key: 'userIdentityType', label: 'User Identity Type' },+ ],+ },+ ],+};++const chatFields: OutputSchema['fields'] = [+ ...chatScalarFields,+ { key: 'viewpoint', label: 'Viewpoint' },+ { key: 'onlineMeetingInfo', label: 'Online Meeting Info' },+];++const chatDetailFields: OutputSchema['fields'] = [+ ...chatScalarFields,+ viewpointField,+ onlineMeetingInfoField,+];++const mentionFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Mention ID', format: 'number' },+ { key: 'mentionText', label: 'Mention Text' },+ {+ key: 'mentioned',+ label: 'Mentioned',+ children: [+ { key: 'application', label: 'Application' },+ { key: 'device', label: 'Device' },+ { key: 'conversation', label: 'Conversation' },+ { key: 'tag', label: 'Tag' },+ { key: 'user', label: 'User', children: identityUserFields },+ ],+ },+];++const attachmentFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Attachment ID' },+ { key: 'contentType', label: 'Content Type' },+ { key: 'contentUrl', label: 'Content URL', format: 'url' },+ { key: 'content', label: 'Content' },+ { key: 'name', label: 'Name' },+ { key: 'thumbnailUrl', label: 'Thumbnail URL', format: 'image' },+ { key: 'teamsAppId', label: 'Teams App ID' },+];++const eventDetailField: Field = {+ key: 'eventDetail',+ label: 'Event Detail',+ children: [+ odataTypeField,+ { key: 'callId', label: 'Call ID' },+ { key: 'callRecordingDisplayName', label: 'Call Recording Name' },+ { key: 'callRecordingUrl', label: 'Call Recording URL', format: 'url' },+ {+ key: 'callRecordingDuration',+ label: 'Call Recording Duration',+ format: 'duration',+ },+ { key: 'callRecordingStatus', label: 'Call Recording Status' },+ {+ key: 'meetingOrganizer',+ label: 'Meeting Organizer',+ children: identitySetFields,+ },+ { key: 'initiator', label: 'Initiator', children: identitySetFields },+ ],+};++const channelIdentityField: Field = {+ key: 'channelIdentity',+ label: 'Channel Identity',+ children: [+ { key: 'teamId', label: 'Team ID' },+ { key: 'channelId', label: 'Channel ID' },+ ],+};++const messageCoreFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Message ID' },+ { key: 'replyToId', label: 'Reply To ID' },+ { key: 'etag', label: 'Etag' },+ { key: 'messageType', label: 'Message Type' },+ { key: 'createdDateTime', label: 'Created At', format: 'datetime' },+ {+ key: 'lastModifiedDateTime',+ label: 'Last Modified At',+ format: 'datetime',+ },+ { key: 'lastEditedDateTime', label: 'Last Edited At', format: 'datetime' },+ { key: 'deletedDateTime', label: 'Deleted At', format: 'datetime' },+ { key: 'subject', label: 'Subject' },+ { key: 'summary', label: 'Summary' },+ { key: 'chatId', label: 'Chat ID' },+ { key: 'importance', label: 'Importance' },+ { key: 'locale', label: 'Locale' },+ { key: 'webUrl', label: 'Web URL', format: 'url' },+ { key: 'policyViolation', label: 'Policy Violation' },+ { key: 'from', label: 'From', children: identitySetFields },+ {+ key: 'body',+ label: 'Body',+ children: [+ { key: 'contentType', label: 'Content Type' },+ { key: 'content', label: 'Content' },+ ],+ },+ { key: 'reactions', label: 'Reactions' },+];++const buildMessageFields = ({+ channel = false,+ eventDetail = false,+ attachments = false,+ mentions = false,+}: {+ channel?: boolean;+ eventDetail?: boolean;+ attachments?: boolean;+ mentions?: boolean;+}): OutputSchema['fields'] => [+ ...messageCoreFields,+ eventDetail+ ? eventDetailField+ : { key: 'eventDetail', label: 'Event Detail' },+ channel+ ? channelIdentityField+ : { key: 'channelIdentity', label: 'Channel Identity' },+ attachments+ ? {+ key: 'attachments',+ label: 'Attachments',+ labelKey: 'name',+ listItems: attachmentFields,+ }+ : { key: 'attachments', label: 'Attachments' },+ mentions+ ? {+ key: 'mentions',+ label: 'Mentions',+ labelKey: 'mentionText',+ listItems: mentionFields,+ }+ : { key: 'mentions', label: 'Mentions' },+];++const chatMessageFields = buildMessageFields({});+const chatMessageWithMentionsFields = buildMessageFields({ mentions: true });+const chatMessageHistoryFields = buildMessageFields({+ eventDetail: true,+ mentions: true,+});+const chatMessageWithAttachmentsFields = buildMessageFields({+ attachments: true,+});+const channelMessageFields = buildMessageFields({ channel: true });+const channelMessageWithMentionsFields = buildMessageFields({+ channel: true,+ mentions: true,+});++const presenceFields: OutputSchema['fields'] = [+ { key: 'id', label: 'User ID' },+ { key: 'availability', label: 'Availability' },+ { key: 'activity', label: 'Activity' },+ { key: 'sequenceNumber', label: 'Sequence Number' },+ { key: 'statusMessage', label: 'Status Message' },+ { key: 'workLocation', label: 'Work Location' },+ {+ key: 'outOfOfficeSettings',+ label: 'Out of Office Settings',+ children: [+ { key: 'message', label: 'Message' },+ { key: 'isOutOfOffice', label: 'Out of Office', format: 'boolean' },+ ],+ },+];++const userFields: OutputSchema['fields'] = [+ { key: 'id', label: 'User ID' },+ { key: 'displayName', label: 'Display Name' },+ { key: 'givenName', label: 'First Name' },+ { key: 'surname', label: 'Last Name' },+ { key: 'jobTitle', label: 'Job Title' },+ { key: 'mail', label: 'Email', format: 'email' },+ { key: 'userPrincipalName', label: 'User Principal Name', format: 'email' },+ { key: 'businessPhones', label: 'Business Phones' },+ { key: 'mobilePhone', label: 'Mobile Phone' },+ { key: 'officeLocation', label: 'Office Location' },+ { key: 'preferredLanguage', label: 'Preferred Language' },+];++const teamScalarFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Team ID' },+ { key: 'createdDateTime', label: 'Created At', format: 'datetime' },+ { key: 'displayName', label: 'Display Name' },+ { key: 'description', label: 'Description' },+ { key: 'internalId', label: 'Internal ID' },+ { key: 'classification', label: 'Classification' },+ { key: 'specialization', label: 'Specialization' },+ { key: 'visibility', label: 'Visibility' },+ { key: 'webUrl', label: 'Web URL', format: 'url' },+ { key: 'isArchived', label: 'Archived', format: 'boolean' },+ {+ key: 'isMembershipLimitedToOwners',+ label: 'Membership Limited to Owners',+ format: 'boolean',+ },+];++const teamSettingsFields: OutputSchema['fields'] = [+ {+ key: 'discoverySettings',+ label: 'Discovery Settings',+ children: [+ {+ key: 'showInTeamsSearchAndSuggestions',+ label: 'Show in Teams Search and Suggestions',+ format: 'boolean',+ },+ ],+ },+ { key: 'tagSettings', label: 'Tag Settings' },+ {+ key: 'memberSettings',+ label: 'Member Settings',+ children: [+ {+ key: 'allowCreateUpdateChannels',+ label: 'Allow Create and Update Channels',+ format: 'boolean',+ },+ {+ key: 'allowCreatePrivateChannels',+ label: 'Allow Create Private Channels',+ format: 'boolean',+ },+ {+ key: 'allowDeleteChannels',+ label: 'Allow Delete Channels',+ format: 'boolean',+ },+ {+ key: 'allowAddRemoveApps',+ label: 'Allow Add and Remove Apps',+ format: 'boolean',+ },+ {+ key: 'allowCreateUpdateRemoveTabs',+ label: 'Allow Create, Update and Remove Tabs',+ format: 'boolean',+ },+ {+ key: 'allowCreateUpdateRemoveConnectors',+ label: 'Allow Create, Update and Remove Connectors',+ format: 'boolean',+ },+ ],+ },+ {+ key: 'guestSettings',+ label: 'Guest Settings',+ children: [+ {+ key: 'allowCreateUpdateChannels',+ label: 'Allow Create and Update Channels',+ format: 'boolean',+ },+ {+ key: 'allowDeleteChannels',+ label: 'Allow Delete Channels',+ format: 'boolean',+ },+ ],+ },+ {+ key: 'messagingSettings',+ label: 'Messaging Settings',+ children: [+ {+ key: 'allowUserEditMessages',+ label: 'Allow Users to Edit Messages',+ format: 'boolean',+ },+ {+ key: 'allowUserDeleteMessages',+ label: 'Allow Users to Delete Messages',+ format: 'boolean',+ },+ {+ key: 'allowOwnerDeleteMessages',+ label: 'Allow Owners to Delete Messages',+ format: 'boolean',+ },+ {+ key: 'allowTeamMentions',+ label: 'Allow Team Mentions',+ format: 'boolean',+ },+ {+ key: 'allowChannelMentions',+ label: 'Allow Channel Mentions',+ format: 'boolean',+ },+ ],+ },+ {+ key: 'funSettings',+ label: 'Fun Settings',+ children: [+ { key: 'allowGiphy', label: 'Allow Giphy', format: 'boolean' },+ { key: 'giphyContentRating', label: 'Giphy Content Rating' },+ {+ key: 'allowStickersAndMemes',+ label: 'Allow Stickers and Memes',+ format: 'boolean',+ },+ {+ key: 'allowCustomMemes',+ label: 'Allow Custom Memes',+ format: 'boolean',+ },+ ],+ },+ {+ key: 'summary',+ label: 'Summary',+ children: [+ { key: 'ownersCount', label: 'Owners', format: 'number' },+ { key: 'membersCount', label: 'Members', format: 'number' },+ { key: 'guestsCount', label: 'Guests', format: 'number' },+ ],+ },+];++const teamFields: OutputSchema['fields'] = [+ ...teamScalarFields,+ { key: 'tenantId', label: 'Tenant ID' },+ { key: 'discoverySettings', label: 'Discovery Settings' },+ { key: 'tagSettings', label: 'Tag Settings' },+ { key: 'memberSettings', label: 'Member Settings' },+ { key: 'guestSettings', label: 'Guest Settings' },+ { key: 'messagingSettings', label: 'Messaging Settings' },+ { key: 'funSettings', label: 'Fun Settings' },+ { key: 'summary', label: 'Summary' },+];++const hostedContentFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Hosted Content ID' },+ { key: 'contentBase64', label: 'Content (Base64)' },+];++const messageActionFields: OutputSchema['fields'] = [+ { key: 'chatId', label: 'Chat ID' },+ { key: 'messageId', label: 'Message ID' },+];++export const microsoftTeamsCreateChannelOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ ...channelFields.filter((f) => f.key !== 'tenantId'),+ ],+};++export const microsoftTeamsCreateChatOutputSchema: OutputSchema = {+ fields: [odataContextField, ...chatFields],+};++export const microsoftTeamsCreateChatAndSendMessageOutputSchema: OutputSchema =+ {+ fields: [+ {+ key: 'chat',+ label: 'Chat',+ children: [odataContextField, ...chatFields],+ },+ {+ key: 'message',+ label: 'Message',+ children: [odataContextField, ...chatMessageFields],+ },+ ],+ };++export const microsoftTeamsCreatePrivateChannelOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ ...channelFields.filter((f) => f.key !== 'tenantId'),+ ],+};++export const microsoftTeamsDeleteChatMessageOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ ...messageActionFields,+ ],+};++export const microsoftTeamsFindChannelOutputSchema: OutputSchema = {+ fields: [+ { key: 'found', label: 'Found', format: 'boolean' },+ { key: 'result', label: 'Matching Channels', labelKey: 'displayName', listItems: [+ odataIdField,+ ...channelFields,+ ] },+ ],+};++export const microsoftTeamsFindTeamMemberOutputSchema: OutputSchema = {+ fields: [+ { key: 'found', label: 'Found', format: 'boolean' },+ { key: 'result', label: 'Matching Members', labelKey: 'displayName', listItems: conversationMemberFields },+ ],+};++export const microsoftTeamsGetChannelOutputSchema: OutputSchema = {+ fields: [odataContextField, ...channelFields, channelSummaryField],+};++export const microsoftTeamsGetChannelMessageOutputSchema: OutputSchema = {+ fields: [odataContextField, ...channelMessageFields],+};++export const microsoftTeamsGetChannelMessageByIdOutputSchema: OutputSchema = {+ fields: [odataContextField, ...channelMessageWithMentionsFields],+};++export const microsoftTeamsGetChannelMessageHostedContentOutputSchema: OutputSchema =+ {+ fields: hostedContentFields,+ };++export const microsoftTeamsGetChatOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ ...chatDetailFields,+ {+ key: '[email protected]',+ label: 'Members OData Context',+ value: "['[email protected]']",+ format: 'url',+ },+ { key: 'members', label: 'Members', labelKey: 'displayName', listItems: conversationMemberFields },+ ],+};++export const microsoftTeamsGetChatMemberOutputSchema: OutputSchema = {+ fields: [odataContextField, ...conversationMemberFields],+};++export const microsoftTeamsGetChatMessageOutputSchema: OutputSchema = {+ fields: [odataContextField, ...chatMessageFields],+};++export const microsoftTeamsGetChatMessageByIdOutputSchema: OutputSchema = {+ fields: [odataContextField, ...chatMessageWithMentionsFields],+};++export const microsoftTeamsGetChatMessageHostedContentOutputSchema: OutputSchema =+ {+ fields: [+ ...hostedContentFields.slice(0, 1),+ ...messageActionFields,+ ...hostedContentFields.slice(1),+ ],+ };++export const microsoftTeamsGetCurrentUserOutputSchema: OutputSchema = {+ fields: [odataContextField, ...userFields],+};++export const microsoftTeamsGetMyPresenceOutputSchema: OutputSchema = {+ fields: [odataContextField, ...presenceFields],+};++export const microsoftTeamsGetPresencesByUserIdsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ { key: 'value', label: 'Presences', labelKey: 'availability', listItems: presenceFields },+ ],+};++export const microsoftTeamsGetTeamOutputSchema: OutputSchema = {+ fields: [odataContextField, ...teamScalarFields, ...teamSettingsFields],+};++export const microsoftTeamsGetTeamsLicensingDetailsOutputSchema: OutputSchema =+ {+ fields: [+ odataContextField,+ { key: 'hasTeamsLicense', label: 'Has Teams License', format: 'boolean' },+ ],+ };++export const microsoftTeamsHideChatOutputSchema: OutputSchema = {+ fields: [{ key: 'success', label: 'Success', format: 'boolean' }],+};++export const microsoftTeamsListAllChannelsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ { key: 'value', label: 'Channels', labelKey: 'displayName', listItems: [odataIdField, ...channelFields] },+ ],+};++export const microsoftTeamsListAssociatedTeamsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ { key: 'value', label: 'Associated Teams', labelKey: 'displayName', listItems: [+ { key: 'id', label: 'Team ID' },+ { key: 'tenantId', label: 'Tenant ID' },+ { key: 'displayName', label: 'Display Name' },+ ] },+ ],+};++export const microsoftTeamsListChannelMessageHostedContentsOutputSchema: OutputSchema =+ {+ fields: [+ odataContextField,+ odataCountField,+ { key: 'value', label: 'Hosted Contents' },+ ],+ };++export const microsoftTeamsListChannelMessageRepliesOutputSchema: OutputSchema =+ {+ fields: [+ odataContextField,+ odataCountField,+ odataNextLinkField,+ { key: 'value', label: 'Replies', labelKey: 'id', listItems: channelMessageFields },+ ],+ };++export const microsoftTeamsListChannelMessagesOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ odataNextLinkField,+ { key: 'value', label: 'Messages', labelKey: 'subject', listItems: channelMessageWithMentionsFields },+ ],+};++export const microsoftTeamsListChannelsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ { key: 'value', label: 'Channels', labelKey: 'displayName', listItems: channelFields },+ ],+};++export const microsoftTeamsListChatMembersOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ { key: 'value', label: 'Members', labelKey: 'displayName', listItems: conversationMemberFields },+ ],+};++export const microsoftTeamsListChatMessagesOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ odataNextLinkField,+ { key: 'value', label: 'Messages', labelKey: 'id', listItems: chatMessageHistoryFields },+ ],+};++export const microsoftTeamsListChatsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ odataNextLinkField,+ { key: 'value', label: 'Chats', labelKey: 'topic', listItems: chatDetailFields },+ ],+};++export const microsoftTeamsListDeletedTeamsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ { key: 'value', label: 'Deleted Teams', labelKey: 'id', listItems: [{ key: 'id', label: 'Team ID' }] },+ ],+};++export const microsoftTeamsListIncomingChannelsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ { key: 'value', label: 'Channels', labelKey: 'displayName', listItems: channelFields },+ ],+};++export const microsoftTeamsListJoinedTeamsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ { key: 'value', label: 'Teams', labelKey: 'displayName', listItems: teamFields },+ ],+};++export const microsoftTeamsListPinnedChatMessagesOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ { key: 'value', label: 'Pinned Messages', labelKey: 'id', listItems: [+ { key: 'id', label: 'Pinned Message ID' },+ { key: 'message', label: 'Message', children: chatMessageFields },+ ] },+ ],+};++export const microsoftTeamsListTeamMembersOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ odataNextLinkField,+ { key: 'value', label: 'Members', labelKey: 'displayName', listItems: conversationMemberFields },+ ],+};++export const microsoftTeamsListTeamsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataCountField,+ { key: 'value', label: 'Teams', labelKey: 'displayName', listItems: teamFields.filter((f) => f.key !== 'tenantId') },+ ],+};++export const microsoftTeamsListUsersOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ odataNextLinkField,+ { key: 'value', label: 'Users', labelKey: 'displayName', listItems: userFields },+ ],+};++export const microsoftTeamsPinChatMessageOutputSchema: OutputSchema = {+ fields: [odataContextField, { key: 'id', label: 'Pinned Message ID' }],+};++export const microsoftTeamsSearchMessagesOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'value',+ label: 'Search Results',+ listItems: [+ { key: 'searchTerms', label: 'Search Terms' },+ {+ key: 'hitsContainers',+ label: 'Hit Containers',+ listItems: [+ {+ key: 'hits',+ label: 'Hits',+ labelKey: 'summary',+ listItems: [+ { key: 'hitId', label: 'Hit ID' },+ { key: 'rank', label: 'Rank', format: 'number' },+ { key: 'summary', label: 'Summary' },+ {+ key: 'resource',+ label: 'Message',+ children: [+ odataTypeField,+ { key: 'id', label: 'Message ID' },+ {+ key: 'createdDateTime',+ label: 'Created At',+ format: 'datetime',+ },+ {+ key: 'lastModifiedDateTime',+ label: 'Last Modified At',+ format: 'datetime',+ },+ { key: 'importance', label: 'Importance' },+ { key: 'webLink', label: 'Web Link', format: 'url' },+ {+ key: 'from',+ label: 'From',+ children: [+ { key: 'emailAddress', label: 'Email Address' },+ ],+ },+ {+ key: 'channelIdentity',+ label: 'Channel Identity',+ children: [+ { key: 'channelId', label: 'Channel ID' },+ { key: 'teamId', label: 'Team ID' },+ ],+ },+ { key: 'etag', label: 'Etag' },+ { key: 'chatId', label: 'Chat ID' },+ ],+ },+ ],+ },+ { key: 'total', label: 'Total Hits', format: 'number' },+ {+ key: 'moreResultsAvailable',+ label: 'More Results Available',+ format: 'boolean',+ },+ ],+ },+ ],+ },+ odataContextField,+ ],+};++export const microsoftTeamsSetChannelMessageReactionOutputSchema: OutputSchema =+ {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'reactionType', label: 'Reaction Type' },+ ],+ };++export const microsoftTeamsSetChatMessageReactionOutputSchema: OutputSchema = {+ fields: [+ { key: 'reactionSet', label: 'Reaction Set', format: 'boolean' },+ ...messageActionFields,+ { key: 'reactionType', label: 'Reaction Type' },+ ],+};++export const microsoftTeamsSoftDeleteChatMessageOutputSchema: OutputSchema = {+ fields: [+ { key: 'softDeleted', label: 'Soft Deleted', format: 'boolean' },+ ...messageActionFields,+ ],+};++export const microsoftTeamsUndoSoftDeleteChatMessageOutputSchema: OutputSchema =+ {+ fields: [+ { key: 'restored', label: 'Restored', format: 'boolean' },+ ...messageActionFields,+ ],+ };++export const microsoftTeamsUnsetChatMessageReactionOutputSchema: OutputSchema =+ {+ fields: [+ { key: 'reactionRemoved', label: 'Reaction Removed', format: 'boolean' },+ ...messageActionFields,+ { key: 'reactionType', label: 'Reaction Type' },+ ],+ };++export const microsoftTeamsUpdateChatMessageOutputSchema: OutputSchema = {+ fields: [+ { key: 'updated', label: 'Updated', format: 'boolean' },+ ...messageActionFields,+ ],+};++export const newChannelOutputSchema: OutputSchema = { fields: channelFields };++export const newChannelMessageOutputSchema: OutputSchema = {+ fields: channelMessageWithMentionsFields,+};++export const newChatOutputSchema: OutputSchema = {+ fields: [+ ...chatScalarFields,+ { key: 'onlineMeetingInfo', label: 'Online Meeting Info' },+ viewpointField,+ ],+};++export const newChatMessageOutputSchema: OutputSchema = {+ fields: chatMessageWithAttachmentsFields,+};++export const requestApprovalDirectMessageOutputSchema: OutputSchema = {+ fields: [{ key: 'approved', label: 'Approved', format: 'boolean' }],+};++export const microsoftTeamsListMeetingTranscriptsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ { key: 'value', label: 'Transcripts', labelKey: 'createdDateTime', listItems: callTranscriptFields },+ ],+};++export const microsoftTeamsGetMeetingTranscriptDetailsOutputSchema: OutputSchema =+ {+ fields: callTranscriptFields,+ };++export const microsoftTeamsGetMeetingTranscriptContentOutputSchema: OutputSchema =+ {+ fields: [+ { key: 'transcriptId', label: 'Transcript ID' },+ { key: 'format', label: 'Format' },+ { key: 'content', label: 'Content' },+ ],+ };++export const microsoftTeamsListMeetingRecordingsOutputSchema: OutputSchema = {+ fields: [+ odataContextField,+ { key: 'value', label: 'Recordings', labelKey: 'createdDateTime', listItems: callRecordingFields },+ ],+};++export const microsoftTeamsGetMeetingRecordingDetailsOutputSchema: OutputSchema =+ {+ fields: callRecordingFields,+ };++export const microsoftTeamsGetMeetingTranscriptOutputSchema: OutputSchema = {+ fields: [+ { key: 'content', label: 'Transcript Content' },+ { key: 'value', label: 'Transcripts', labelKey: 'createdDateTime', listItems: callTranscriptFields },+ ],+};++export const microsoftTeamsGetMeetingRecordingOutputSchema: OutputSchema = {+ fields: [+ ...callRecordingFields,+ { key: 'value', label: 'Recordings', labelKey: 'createdDateTime', listItems: callRecordingFields },+ ],+};++type Field = OutputSchema['fields'][number];diff --git a/packages/pieces/community/microsoft-teams/src/lib/triggers/new-channel-message.ts b/packages/pieces/community/microsoft-teams/src/lib/triggers/new-channel-message.tsindex 399621ce28b..790b3b269ba 100644--- a/packages/pieces/community/microsoft-teams/src/lib/triggers/new-channel-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/triggers/new-channel-message.ts@@ -5,13 +5,13 @@ import {AppConnectionValueForAuthProperty,TriggerStrategy,} from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient, withGraphRetry } from '../common/graph';-import { PageCollection } from '@microsoft/microsoft-graph-client';-import { ChatMessage } from '@microsoft/microsoft-graph-types';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import type { ChatMessage, MicrosoftTeamsPage } from '../common/types';import dayjs from 'dayjs';import { isNil } from '@activepieces/pieces-framework';+import { newChannelMessageOutputSchema } from '../output-schemas';type Props = {teamId: string;channelId: string;@@ -20,6 +20,7 @@ type Props = {export const newChannelMessageTrigger = createTrigger({auth: microsoftTeamsAuth,name: 'new-channel-message',+ outputSchema: newChannelMessageOutputSchema,classification: 'READ',displayName: 'New Channel Message',description: 'Triggers when a new message is posted in a channel.',@@ -27,8 +28,8 @@ export const newChannelMessageTrigger = createTrigger({description: 'Fires when a new message is posted in the selected Microsoft Teams channel (by team ID and channel ID). Each event represents the posted channel message and its content. Polls periodically, so events appear with a short delay rather than instantly.',},props: {- teamId: microsoftTeamsCommon.teamId,- channelId: microsoftTeamsCommon.channelId,+ teamId: microsoftTeamsProps.teamId({ required: true }),+ channelId: microsoftTeamsProps.channelId({ required: true }),},type: TriggerStrategy.POLLING,async onEnable(context) {@@ -89,13 +90,12 @@ const polling: Polling<AppConnectionValueForAuthProperty<typeof microsoftTeamsAustrategy: DedupeStrategy.TIMEBASED,async items({ auth, propsValue, lastFetchEpochMS, store }) {const { teamId, channelId } = propsValue;- const cloud = auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth });const messages: ChatMessage[] = [];if (lastFetchEpochMS === 0) {- const response: PageCollection = await withGraphRetry(() =>+ const response: MicrosoftTeamsPage<ChatMessage> = await microsoftTeamsClient.withRetry(() =>client.api(`/teams/${teamId}/channels/${channelId}/messages`).top(5).get(),);@@ -107,12 +107,10 @@ const polling: Polling<AppConnectionValueForAuthProperty<typeof microsoftTeamsAu(await store.get<string>('deltalink')) ??`/teams/${teamId}/channels/${channelId}/messages/delta`;let nextLink: string | null = requestUrl;-- // https://learn.microsoft.com/en-us/graph/api/chatmessage-delta?view=graph-rest-1.0&tabs=httpwhile (nextLink) {const url = nextLink;- const response: PageCollection = await withGraphRetry(() => client.api(url).get());- const channelMessages = response.value as ChatMessage[];+ const response: MicrosoftTeamsPage<ChatMessage> = await microsoftTeamsClient.withRetry(() => client.api(url).get());+ const channelMessages = response.value;if (Array.isArray(channelMessages)) {messages.push(...channelMessages);diff --git a/packages/pieces/community/microsoft-teams/src/lib/triggers/new-channel.ts b/packages/pieces/community/microsoft-teams/src/lib/triggers/new-channel.tsindex c3479ffedba..e381863b227 100644--- a/packages/pieces/community/microsoft-teams/src/lib/triggers/new-channel.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/triggers/new-channel.ts@@ -5,13 +5,13 @@ import {AppConnectionValueForAuthProperty,TriggerStrategy,} from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient, withGraphRetry } from '../common/graph';-import { PageCollection } from '@microsoft/microsoft-graph-client';-import { Channel } from '@microsoft/microsoft-graph-types';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import type { Channel, MicrosoftTeamsPage } from '../common/types';import dayjs from 'dayjs';import { isNil } from '@activepieces/pieces-framework';+import { newChannelOutputSchema } from '../output-schemas';type Props = {teamId: string;@@ -20,6 +20,7 @@ type Props = {export const newChannelTrigger = createTrigger({auth: microsoftTeamsAuth,name: 'new-channel',+ outputSchema: newChannelOutputSchema,classification: 'READ',displayName: 'New Channel',description: 'Triggers when a new channel is created in a team.',@@ -27,7 +28,7 @@ export const newChannelTrigger = createTrigger({description: 'Fires when a new channel is created within the selected Microsoft Teams team. Each event represents the newly created channel and its metadata. Polls periodically by creation time, so events appear with a short delay rather than instantly.',},props: {- teamId: microsoftTeamsCommon.teamId,+ teamId: microsoftTeamsProps.teamId({ required: true }),},type: TriggerStrategy.POLLING,async onEnable(context) {@@ -56,19 +57,18 @@ const polling: Polling<AppConnectionValueForAuthProperty<typeof microsoftTeamsAustrategy: DedupeStrategy.TIMEBASED,async items({ auth, propsValue, lastFetchEpochMS }) {const { teamId } = propsValue;- const cloud = auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth });const lastFetchDate = dayjs(lastFetchEpochMS).toISOString();const channels: Channel[] = [];const filter = lastFetchEpochMS === 0 ? '' : `?$filter=createdDateTime gt ${lastFetchDate}`;- let response: PageCollection = await withGraphRetry(() =>+ let response: MicrosoftTeamsPage<Channel> = await microsoftTeamsClient.withRetry(() =>client.api(`/teams/${teamId}/channels${filter}`).get(),);while (response.value && response.value.length > 0) {- for (const channel of response.value as Channel[]) {+ for (const channel of response.value) {if (isNil(channel.createdDateTime)) {continue;}@@ -76,7 +76,7 @@ const polling: Polling<AppConnectionValueForAuthProperty<typeof microsoftTeamsAu}const nextLink = response['@odata.nextLink'];if (lastFetchEpochMS !== 0 && nextLink) {- response = await withGraphRetry(() => client.api(nextLink).get());+ response = await microsoftTeamsClient.withRetry(() => client.api(nextLink).get());} else {break;}diff --git a/packages/pieces/community/microsoft-teams/src/lib/triggers/new-chat-message.ts b/packages/pieces/community/microsoft-teams/src/lib/triggers/new-chat-message.tsindex 21e5b735e16..d6cd046ffb1 100644--- a/packages/pieces/community/microsoft-teams/src/lib/triggers/new-chat-message.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/triggers/new-chat-message.ts@@ -5,13 +5,13 @@ import {AppConnectionValueForAuthProperty,TriggerStrategy,} from '@activepieces/pieces-framework';-import { microsoftTeamsCommon } from '../common';-import { createGraphClient, withGraphRetry } from '../common/graph';-import { PageCollection } from '@microsoft/microsoft-graph-client';-import { ChatMessage } from '@microsoft/microsoft-graph-types';+import { microsoftTeamsProps } from '../common/props';+import { microsoftTeamsClient } from '../common/client';+import type { ChatMessage, MicrosoftTeamsPage } from '../common/types';import dayjs from 'dayjs';import { isNil } from '@activepieces/pieces-framework';+import { newChatMessageOutputSchema } from '../output-schemas';type Props = {chatId: string;@@ -20,6 +20,7 @@ type Props = {export const newChatMessageTrigger = createTrigger({auth: microsoftTeamsAuth,name: 'new-chat-message',+ outputSchema: newChatMessageOutputSchema,classification: 'READ',displayName: 'New Chat Message',description: 'Triggers when a new message is received in a chat.',@@ -27,7 +28,7 @@ export const newChatMessageTrigger = createTrigger({description: 'Fires when a new message is received in the selected Microsoft Teams chat (by chat ID). Each event represents the new chat message and its content. Polls periodically, so events appear with a short delay rather than instantly.',},props: {- chatId: microsoftTeamsCommon.chatId,+ chatId: microsoftTeamsProps.chatId({ required: true }),},type: TriggerStrategy.POLLING,async onEnable(context) {@@ -84,29 +85,26 @@ const polling: Polling<AppConnectionValueForAuthProperty<typeof microsoftTeamsAustrategy: DedupeStrategy.TIMEBASED,async items({ auth, propsValue, lastFetchEpochMS, store }) {const { chatId } = propsValue;- const cloud = auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth });const messages: ChatMessage[] = [];if (lastFetchEpochMS === 0) {- const response: PageCollection = await withGraphRetry(() =>+ const response: MicrosoftTeamsPage<ChatMessage> = await microsoftTeamsClient.withRetry(() =>client.api(`/chats/${chatId}/messages`).top(5).get(),);if (!isNil(response.value)) {- messages.push(...(response.value as ChatMessage[]));+ messages.push(...response.value);}} else {const requestUrl =(await store.get<string>('deltalink')) ?? `/chats/${chatId}/messages/delta`;let nextLink: string | null = requestUrl;-- // https://learn.microsoft.com/graph/api/chatmessage-delta?view=graph-rest-1.0&tabs=httpwhile (nextLink) {const url = nextLink;- const response: PageCollection = await withGraphRetry(() => client.api(url).get());- const chatMessages = response.value as ChatMessage[];+ const response: MicrosoftTeamsPage<ChatMessage> = await microsoftTeamsClient.withRetry(() => client.api(url).get());+ const chatMessages = response.value;if (Array.isArray(chatMessages)) {messages.push(...chatMessages);diff --git a/packages/pieces/community/microsoft-teams/src/lib/triggers/new-chat.ts b/packages/pieces/community/microsoft-teams/src/lib/triggers/new-chat.tsindex db46581675f..587a2067ec9 100644--- a/packages/pieces/community/microsoft-teams/src/lib/triggers/new-chat.ts+++ b/packages/pieces/community/microsoft-teams/src/lib/triggers/new-chat.ts@@ -6,18 +6,17 @@ import {TriggerStrategy,} from '@activepieces/pieces-framework';import { isNil } from '@activepieces/pieces-framework';-import { createGraphClient, withGraphRetry } from '../common/graph';-import { PageCollection } from '@microsoft/microsoft-graph-client';-import { Chat, ChatType } from '@microsoft/microsoft-graph-types';+import { microsoftTeamsClient } from '../common/client';+import type { Chat, MicrosoftTeamsPage } from '../common/types';import dayjs from 'dayjs';+import { newChatOutputSchema } from '../output-schemas';-type Props = {- chatType?: ChatType;-};+type Props = Record<string, never>;export const newChatTrigger = createTrigger({auth: microsoftTeamsAuth,name: 'new-chat',+ outputSchema: newChatOutputSchema,classification: 'READ',displayName: 'New Chat',description: 'Triggers when a new chat is created.',@@ -27,16 +26,16 @@ export const newChatTrigger = createTrigger({props: {},type: TriggerStrategy.POLLING,async onEnable(context) {- await pollingHelper.onEnable(polling, { ...context, propsValue: context.propsValue as Props });+ await pollingHelper.onEnable(polling, context);},async onDisable(context) {- await pollingHelper.onDisable(polling, { ...context, propsValue: context.propsValue as Props });+ await pollingHelper.onDisable(polling, context);},async test(context) {- return await pollingHelper.test(polling, context as any);+ return await pollingHelper.test(polling, context);},async run(context) {- return await pollingHelper.poll(polling, context as any);+ return await pollingHelper.poll(polling, context);},sampleData: {id: '19:[email protected]',@@ -51,8 +50,7 @@ export const newChatTrigger = createTrigger({const polling: Polling<AppConnectionValueForAuthProperty<typeof microsoftTeamsAuth>, Props> = {strategy: DedupeStrategy.TIMEBASED,async items({ auth, lastFetchEpochMS }) {- const cloud = auth.props?.['cloud'] as string | undefined;- const client = createGraphClient(auth.access_token, cloud);+ const client = microsoftTeamsClient.create({ auth });const lastFetchDate = dayjs(lastFetchEpochMS).toISOString();const chats: Chat[] = [];@@ -61,12 +59,12 @@ const polling: Polling<AppConnectionValueForAuthProperty<typeof microsoftTeamsAu? '$top=10': `$filter=createdDateTime gt ${lastFetchDate}`;- let response: PageCollection = await withGraphRetry(() =>+ let response: MicrosoftTeamsPage<Chat> = await microsoftTeamsClient.withRetry(() =>client.api(`/chats?${filter}`).get(),);while (response.value && response.value.length > 0) {- for (const channel of response.value as Chat[]) {+ for (const channel of response.value) {if (isNil(channel.createdDateTime)) {continue;}@@ -74,7 +72,7 @@ const polling: Polling<AppConnectionValueForAuthProperty<typeof microsoftTeamsAu}const nextLink = response['@odata.nextLink'];if (lastFetchEpochMS !== 0 && nextLink) {- response = await withGraphRetry(() => client.api(nextLink).get());+ response = await microsoftTeamsClient.withRetry(() => client.api(nextLink).get());} else {break;}