Skip to content

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

feat(mattermost): let AI agents manage Mattermost posts, channels, teams, users and bots (#17162)

Kishan Parmar6dcda4a0b434
diff --git a/bun.lock b/bun.lock
index c8b9c369c87..8c556c13044 100644
--- a/bun.lock
+++ b/bun.lock
@@ -573,7 +573,7 @@
},
"packages/pieces/community/amazon-redshift": {
"name": "@activepieces/piece-amazon-redshift",
- "version": "0.0.1",
+ "version": "0.0.2",
"dependencies": {
"@activepieces/pieces-common": "workspace:*",
"@activepieces/pieces-framework": "workspace:*",
@@ -5751,7 +5751,7 @@
},
"packages/pieces/community/mattermost": {
"name": "@activepieces/piece-mattermost",
- "version": "0.5.1",
+ "version": "0.6.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/pieces/community/mattermost/package.json b/packages/pieces/community/mattermost/package.json
index 807635f20cb..7b5c3cb0621 100644
--- a/packages/pieces/community/mattermost/package.json
+++ b/packages/pieces/community/mattermost/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-mattermost",
- "version": "0.5.1",
+ "version": "0.6.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/mattermost/src/index.ts b/packages/pieces/community/mattermost/src/index.ts
index ec21a6948d1..b70d7be6957 100644
--- a/packages/pieces/community/mattermost/src/index.ts
+++ b/packages/pieces/community/mattermost/src/index.ts
@@ -1,53 +1,26 @@
import { createCustomApiCallAction } from '@activepieces/pieces-common';
-import {
- PieceAuth,
- Property,
- createPiece,
-} from '@activepieces/pieces-framework';
-import { PieceCategory } from '@activepieces/pieces-framework';
-import { sendMessage } from './lib/actions/send-message';
-
-const markdownDescription = `
-**Workspace URL**: The url of mattermost instance (e.g \`https://activepieces.mattermost.com\`)
-
-**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account
-`;
-
-export const mattermostAuth = PieceAuth.CustomAuth({
- description: markdownDescription,
- required: true,
- props: {
- workspace_url: Property.ShortText({
- displayName: 'Workspace URL',
- description:
- 'The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)',
- required: true,
- }),
- token: Property.ShortText({
- displayName: 'Bot Token',
- description: 'The bot token to use to authenticate',
- required: true,
- }),
- },
-});
+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';
+import { mattermostAiActions } from './lib/actions/ai';
+import { sendMessageAction } from './lib/actions/send-message';
+import { mattermostAuth } from './lib/auth';
+import { mattermostClient } from './lib/common/client';
export const mattermost = createPiece({
displayName: 'Mattermost',
description: 'Open-source, self-hosted Slack alternative',
-
logoUrl: 'https://cdn.activepieces.com/pieces/mattermost.png',
- minimumSupportedRelease: '0.30.0',
+ minimumSupportedRelease: '0.88.2',
categories: [PieceCategory.COMMUNICATION],
- authors: ["kishanprmr","MoShizzle","khaledmashaly","abuaboud"],
+ authors: ['kishanprmr', 'MoShizzle', 'khaledmashaly', 'abuaboud'],
auth: mattermostAuth,
actions: [
- sendMessage,
+ sendMessageAction,
+ ...mattermostAiActions,
createCustomApiCallAction({
- baseUrl: (auth) =>auth ?
- (auth.props.workspace_url) + '/api/v4' : '',
+ baseUrl: (auth) => (auth ? mattermostClient.baseUrl({ auth }) : ''),
auth: mattermostAuth,
authMapping: async (auth) => ({
- Authorization: `Bearer ${(auth ).props .token}`,
+ Authorization: `Bearer ${auth.props.token}`,
}),
}),
],
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/bots/assign-bot.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/assign-bot.ts
new file mode 100644
index 00000000000..7623713798c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/assign-bot.ts
@@ -0,0 +1,40 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAssignBotOutputSchema } from '../../../output-schemas';
+
+export const assignBotAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_assign_bot',
+ outputSchema: mattermostAssignBotOutputSchema,
+ displayName: 'Assign Bot Owner',
+ description: 'Makes a user the owner of a bot.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Transfers ownership of a bot to a user; pass "me" for the connected account. Takes the bot\'s user ID from Create Bot or List Bots. Needs the manage_bots permission.',
+ idempotent: true,
+ },
+ props: {
+ botUserId: Property.ShortText({
+ displayName: 'Bot User ID',
+ description: 'The bot\'s user ID (26 characters). Use Create Bot or List Bots to find it.',
+ required: true,
+ }),
+ userId: mattermostAiProps.userId({
+ required: true,
+ displayName: 'New Owner User ID',
+ }),
+ },
+ async run(context) {
+ const { botUserId, userId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/bots/${encodeURIComponent(botUserId)}/assign/${encodeURIComponent(userId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/bots/convert-bot-to-user.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/convert-bot-to-user.ts
new file mode 100644
index 00000000000..d3f59f09c1f
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/convert-bot-to-user.ts
@@ -0,0 +1,77 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostConvertBotToUserOutputSchema } from '../../../output-schemas';
+
+export const convertBotToUserAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_convert_bot_to_user',
+ outputSchema: mattermostConvertBotToUserOutputSchema,
+ displayName: 'Convert Bot to User',
+ description: 'Turns a bot account into a regular user account.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Turns a bot into a regular user account that signs in with the given email and password; the bot record is removed. Takes the bot\'s user ID from Create Bot or List Bots. Needs a system admin connection. Not idempotent: once converted the bot no longer exists.',
+ idempotent: false,
+ },
+ props: {
+ botUserId: Property.ShortText({
+ displayName: 'Bot User ID',
+ description: 'The bot\'s user ID (26 characters). Use Create Bot or List Bots to find it.',
+ required: true,
+ }),
+ email: Property.ShortText({
+ displayName: 'Email',
+ description: 'Email address for the new user account.',
+ required: true,
+ }),
+ password: Property.ShortText({
+ displayName: 'Password',
+ description: 'Password for the new user account; must meet the server\'s password rules.',
+ required: true,
+ }),
+ username: Property.ShortText({
+ displayName: 'Username',
+ description: 'New username. Defaults to the bot\'s username.',
+ required: false,
+ }),
+ firstName: Property.ShortText({
+ displayName: 'First Name',
+ description: 'First name of the user.',
+ required: false,
+ }),
+ lastName: Property.ShortText({
+ displayName: 'Last Name',
+ description: 'Last name of the user.',
+ required: false,
+ }),
+ setSystemAdmin: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Make System Admin',
+ description: '"true" to give the new user the system admin role. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const systemAdmin = mattermostUtils.parseBoolean({ value: p.setSystemAdmin });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/bots/${encodeURIComponent(p.botUserId)}/convert_to_user`,
+ redactBodyInErrors: true,
+ query: systemAdmin !== undefined ? { set_system_admin: String(systemAdmin) } : undefined,
+ body: {
+ email: p.email,
+ password: p.password,
+ username: p.username,
+ first_name: p.firstName,
+ last_name: p.lastName,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/bots/convert-user-to-bot.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/convert-user-to-bot.ts
new file mode 100644
index 00000000000..39dd9b905b3
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/convert-user-to-bot.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostConvertUserToBotOutputSchema } from '../../../output-schemas';
+
+export const convertUserToBotAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_convert_user_to_bot',
+ outputSchema: mattermostConvertUserToBotOutputSchema,
+ displayName: 'Convert User To Bot',
+ description: 'Converts a regular user account into a bot account.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Converts a regular user into a bot account: the user can no longer log in with a password. Needs a system admin connection. Undo with Convert Bot To User. The new bot owns itself; give it another owner with Assign Bot before Disable Bot, which otherwise never returns.',
+ idempotent: false,
+ },
+ props: {
+ userId: mattermostAiProps.userId({
+ required: true,
+ description: 'ID of the user to convert (26 characters). Use Get User By Username to find it.',
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/users/${encodeURIComponent(context.propsValue.userId)}/convert_to_bot`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/bots/create-bot.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/create-bot.ts
new file mode 100644
index 00000000000..90de9ebe1ce
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/create-bot.ts
@@ -0,0 +1,46 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAssignBotOutputSchema } from '../../../output-schemas';
+
+export const createBotAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_create_bot',
+ outputSchema: mattermostAssignBotOutputSchema,
+ displayName: 'Create Bot',
+ description: 'Creates a bot account.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a new bot account owned by the connected user. Needs bot account creation enabled on the server and a connection that is not itself a bot. Not idempotent: a taken username fails.',
+ idempotent: false,
+ },
+ props: {
+ username: Property.ShortText({
+ displayName: 'Username',
+ description: 'Unique bot username: lowercase letters, numbers, ".", "-" and "_".',
+ required: true,
+ }),
+ displayName: Property.ShortText({
+ displayName: 'Display Name',
+ description: 'Name shown for the bot.',
+ required: false,
+ }),
+ description: Property.ShortText({
+ displayName: 'Description',
+ description: 'What the bot is for.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { username, displayName, description } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/bots',
+ body: { username, display_name: displayName, description },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/bots/disable-bot.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/disable-bot.ts
new file mode 100644
index 00000000000..a939b529b9c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/disable-bot.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostDisableBotOutputSchema } from '../../../output-schemas';
+
+export const disableBotAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_disable_bot',
+ outputSchema: mattermostDisableBotOutputSchema,
+ displayName: 'Disable Bot',
+ description: 'Disables a bot account.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Disables a bot account so it can no longer post or authenticate; Enable Bot reverses it. Takes the bot\'s user ID from Create Bot or List Bots. Needs the manage_bots permission. A bot that owns itself (made by Convert User To Bot) must first get another owner with Assign Bot, or this call never returns.',
+ idempotent: true,
+ },
+ props: {
+ botUserId: Property.ShortText({
+ displayName: 'Bot User ID',
+ description: 'The bot\'s user ID (26 characters). Use Create Bot or List Bots to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/bots/${encodeURIComponent(context.propsValue.botUserId)}/disable`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/bots/enable-bot.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/enable-bot.ts
new file mode 100644
index 00000000000..7c7e8c04a92
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/enable-bot.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAssignBotOutputSchema } from '../../../output-schemas';
+
+export const enableBotAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_enable_bot',
+ outputSchema: mattermostAssignBotOutputSchema,
+ displayName: 'Enable Bot',
+ description: 'Re-enables a disabled bot account.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Re-enables a disabled bot account; the reverse of Disable Bot. Takes the bot\'s user ID from Create Bot or List Bots. Needs the manage_bots permission.',
+ idempotent: true,
+ },
+ props: {
+ botUserId: Property.ShortText({
+ displayName: 'Bot User ID',
+ description: 'The bot\'s user ID (26 characters). Use Create Bot or List Bots to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/bots/${encodeURIComponent(context.propsValue.botUserId)}/enable`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/bots/get-bot.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/get-bot.ts
new file mode 100644
index 00000000000..10e229ceefd
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/get-bot.ts
@@ -0,0 +1,44 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostAssignBotOutputSchema } from '../../../output-schemas';
+
+export const getBotAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_bot',
+ outputSchema: mattermostAssignBotOutputSchema,
+ displayName: 'Get Bot',
+ description: 'Gets a bot account by its user ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one bot account (username, display name, description, owner). Takes the bot\'s user ID from Create Bot or List Bots. A disabled bot is only found with Include Disabled set to "true".',
+ idempotent: true,
+ },
+ props: {
+ botUserId: Property.ShortText({
+ displayName: 'Bot User ID',
+ description: 'The bot\'s user ID (26 characters). Use Create Bot or List Bots to find it.',
+ required: true,
+ }),
+ includeDeleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Disabled',
+ description: '"true" to also find the bot if it is disabled. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { botUserId, includeDeleted } = context.propsValue;
+ const deleted = mattermostUtils.parseBoolean({ value: includeDeleted });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/bots/${encodeURIComponent(botUserId)}`,
+ query: deleted !== undefined ? { include_deleted: String(deleted) } : undefined,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/bots/list-bots.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/list-bots.ts
new file mode 100644
index 00000000000..0abd1c84334
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/list-bots.ts
@@ -0,0 +1,52 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListBotsOutputSchema } from '../../../output-schemas';
+
+export const listBotsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_bots',
+ outputSchema: mattermostListBotsOutputSchema,
+ displayName: 'List Bots',
+ description: 'Lists bot accounts.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a page of bot accounts with their user IDs, usernames and owners. Bots managed by other users need the read_others_bots permission. A bot\'s user_id is the Bot User ID the other bot actions take.',
+ idempotent: true,
+ },
+ props: {
+ includeDeleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Disabled',
+ description: '"true" to include disabled bots. Defaults to "false".',
+ }),
+ onlyOrphaned: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Only Orphaned',
+ description: '"true" to return only bots whose owner has been deactivated. Defaults to "false".',
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { includeDeleted, onlyOrphaned, page, perPage } = context.propsValue;
+ const deleted = mattermostUtils.parseBoolean({ value: includeDeleted });
+ const orphaned = mattermostUtils.parseBoolean({ value: onlyOrphaned });
+ const bots = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/bots',
+ query: {
+ ...mattermostUtils.paging({ page, perPage }),
+ ...(deleted !== undefined ? { include_deleted: String(deleted) } : {}),
+ ...(orphaned !== undefined ? { only_orphaned: String(orphaned) } : {}),
+ },
+ });
+ return { bots, count: bots.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/bots/update-bot.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/update-bot.ts
new file mode 100644
index 00000000000..863c2c6a1a5
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/bots/update-bot.ts
@@ -0,0 +1,58 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAssignBotOutputSchema } from '../../../output-schemas';
+
+export const updateBotAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_bot',
+ outputSchema: mattermostAssignBotOutputSchema,
+ displayName: 'Update Bot',
+ description: 'Changes a bot\'s username, display name or description.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Changes a bot\'s username, display name or description; only the fields given are changed. Takes the bot\'s user ID from Create Bot or List Bots. Needs the manage_bots permission.',
+ idempotent: true,
+ },
+ props: {
+ botUserId: Property.ShortText({
+ displayName: 'Bot User ID',
+ description: 'The bot\'s user ID (26 characters). Use Create Bot or List Bots to find it.',
+ required: true,
+ }),
+ username: Property.ShortText({
+ displayName: 'Username',
+ description: 'New unique username: lowercase letters, numbers, ".", "-" and "_".',
+ required: false,
+ }),
+ displayName: Property.ShortText({
+ displayName: 'Display Name',
+ description: 'New name shown for the bot.',
+ required: false,
+ }),
+ description: Property.ShortText({
+ displayName: 'Description',
+ description: 'New description of what the bot is for.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { botUserId, username, displayName, description } = context.propsValue;
+ if (username === undefined && displayName === undefined && description === undefined) {
+ throw new Error('Set at least one of Username, Display Name or Description.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/bots/${encodeURIComponent(botUserId)}`,
+ body: {
+ ...(username !== undefined ? { username } : {}),
+ ...(displayName !== undefined ? { display_name: displayName } : {}),
+ ...(description !== undefined ? { description } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/add-channel-member.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/add-channel-member.ts
new file mode 100644
index 00000000000..652fab710ad
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/add-channel-member.ts
@@ -0,0 +1,36 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostApi } from '../../../common/api';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAddChannelMemberOutputSchema } from '../../../output-schemas';
+
+export const addChannelMemberAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_add_channel_member',
+ outputSchema: mattermostAddChannelMemberOutputSchema,
+ displayName: 'Add Channel Member',
+ description: 'Adds a user to a channel.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds one user to a public or private channel; pass "me" to join a public channel as the connected user. The user must already be on the channel\'s team. Adding an existing member keeps the membership as it is.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ const { channelId, userId } = context.propsValue;
+ const memberId = userId === 'me' ? (await mattermostApi.getMe({ auth: context.auth })).id : userId;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/channels/${encodeURIComponent(channelId)}/members`,
+ body: { user_id: memberId },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/archive-channel.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/archive-channel.ts
new file mode 100644
index 00000000000..f665a26885e
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/archive-channel.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const archiveChannelAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_archive_channel',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Archive Channel',
+ description: 'Archives a public or private channel.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Archives (soft-deletes) a public or private channel: it becomes read-only and hidden, and its messages are kept. Restore Channel reverses it; nothing is permanently deleted. Direct and group messages cannot be archived.',
+ idempotent: false,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/channels/${encodeURIComponent(context.propsValue.channelId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/convert-group-message-to-channel.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/convert-group-message-to-channel.ts
new file mode 100644
index 00000000000..3c5ccfe57e8
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/convert-group-message-to-channel.ts
@@ -0,0 +1,51 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostConvertGroupMessageToChannelOutputSchema } from '../../../output-schemas';
+
+export const convertGroupMessageToChannelAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_convert_group_message_to_channel',
+ outputSchema: mattermostConvertGroupMessageToChannelOutputSchema,
+ displayName: 'Convert Group Message To Channel',
+ description: 'Converts a group message into a private channel in a team.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Turns a group message (type "G") into a private channel in a team, keeping its members and history. It cannot be converted back. The team must be one all members share, from List Group Message Common Teams.',
+ idempotent: false,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({
+ required: true,
+ displayName: 'Group Message Channel ID',
+ description: 'ID of a group message channel (type "G"). Use Search Group Messages or List User Channels to find it.',
+ }),
+ teamId: mattermostAiProps.teamId({
+ required: true,
+ description: 'ID of the team for the new private channel. Use List Group Message Common Teams to find one.',
+ }),
+ name: Property.ShortText({
+ displayName: 'Name',
+ description: 'Unique handle for the new channel\'s URL: lowercase letters, numbers, "-" and "_", e.g. "launch-crew".',
+ required: true,
+ }),
+ displayName: Property.ShortText({
+ displayName: 'Display Name',
+ description: 'Channel name shown to users.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { channelId, teamId, name, displayName } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/channels/${encodeURIComponent(channelId)}/convert_to_channel`,
+ body: { channel_id: channelId, team_id: teamId, name, display_name: displayName },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-channel-category.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-channel-category.ts
new file mode 100644
index 00000000000..45a2a4da9dd
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-channel-category.ts
@@ -0,0 +1,52 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostApi } from '../../../common/api';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateChannelCategoryOutputSchema } from '../../../output-schemas';
+
+export const createChannelCategoryAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_create_channel_category',
+ outputSchema: mattermostCreateChannelCategoryOutputSchema,
+ displayName: 'Create Sidebar Category',
+ description: 'Creates a custom sidebar category for a user in a team.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a custom category in a user\'s channel sidebar for one team, optionally moving channels into it from their current categories; pass "me" for the connected account. Only that user sees it. Not idempotent: each call adds a new category.',
+ idempotent: false,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ displayName: Property.ShortText({
+ displayName: 'Display Name',
+ description: 'Category name shown in the sidebar.',
+ required: true,
+ }),
+ channelIds: Property.Array({
+ displayName: 'Channel IDs',
+ description: 'IDs of channels the user belongs to, to move into this category. Use List User Team Channels to find them.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, displayName, channelIds } = context.propsValue;
+ const ownerId = userId === 'me' ? (await mattermostApi.getMe({ auth: context.auth })).id : userId;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/channels/categories`,
+ body: {
+ user_id: ownerId,
+ team_id: teamId,
+ display_name: displayName,
+ type: 'custom',
+ ...(channelIds && channelIds.length > 0 ? { channel_ids: channelIds } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-channel.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-channel.ts
new file mode 100644
index 00000000000..a4d58b9943c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-channel.ts
@@ -0,0 +1,68 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateChannelOutputSchema } from '../../../output-schemas';
+
+export const createChannelAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_create_channel',
+ outputSchema: mattermostCreateChannelOutputSchema,
+ displayName: 'Create Channel',
+ description: 'Creates a public or private channel in a team.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a public ("O") or private ("P") channel in a team; the connected user becomes its first member. For direct or group messages use Create Direct Channel or Create Group Message. Not idempotent: a taken name in the team fails.',
+ idempotent: false,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ name: Property.ShortText({
+ displayName: 'Name',
+ description: 'Unique handle used in the channel URL: lowercase letters, numbers, "-" and "_", e.g. "release-notes".',
+ required: true,
+ }),
+ displayName: Property.ShortText({
+ displayName: 'Display Name',
+ description: 'Channel name shown to users.',
+ required: true,
+ }),
+ type: Property.StaticDropdown({
+ displayName: 'Type',
+ description: '"O" for a public channel, "P" for a private channel.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Public', value: 'O' },
+ { label: 'Private', value: 'P' },
+ ],
+ },
+ }),
+ purpose: Property.ShortText({
+ displayName: 'Purpose',
+ description: 'Short description of what the channel is for.',
+ required: false,
+ }),
+ header: Property.ShortText({
+ displayName: 'Header',
+ description: 'Markdown text shown in the channel header.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { teamId, name, displayName, type, purpose, header } = context.propsValue;
+ if (type !== 'O' && type !== 'P') {
+ throw new Error(`Type must be "O" or "P", got "${type}".`);
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/channels',
+ body: { team_id: teamId, name, display_name: displayName, type, purpose, header },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-direct-channel.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-direct-channel.ts
new file mode 100644
index 00000000000..be1aacccc56
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-direct-channel.ts
@@ -0,0 +1,37 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostApi } from '../../../common/api';
+import { mattermostClient } from '../../../common/client';
+import { mattermostConvertGroupMessageToChannelOutputSchema } from '../../../output-schemas';
+
+export const createDirectChannelAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_create_direct_channel',
+ outputSchema: mattermostConvertGroupMessageToChannelOutputSchema,
+ displayName: 'Create Direct Channel',
+ description: 'Opens a direct message channel between the connected user and another user.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Opens the one-to-one direct message channel (type "D") between the connected user and another user, or returns it if it already exists; post into it with Create Post. For 3 to 8 people use Create Group Message.',
+ idempotent: true,
+ },
+ props: {
+ userId: Property.ShortText({
+ displayName: 'User ID',
+ description: 'ID (26 characters) of the other user. Use Get User By Username or Search Users to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const me = await mattermostApi.getMe({ auth: context.auth });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/channels/direct',
+ body: [me.id, context.propsValue.userId],
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-group-message.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-group-message.ts
new file mode 100644
index 00000000000..86f7d5c0cab
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/create-group-message.ts
@@ -0,0 +1,35 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostConvertGroupMessageToChannelOutputSchema } from '../../../output-schemas';
+
+export const createGroupMessageAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_create_group_message',
+ outputSchema: mattermostConvertGroupMessageToChannelOutputSchema,
+ displayName: 'Create Group Message',
+ description: 'Opens a group message channel with 3 to 8 people.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Opens a group message channel (type "G"), a direct conversation of 3 to 8 people including the connected user, or returns the existing one for the same people; post into it with Create Post. This is not a user group. For one other person use Create Direct Channel.',
+ idempotent: true,
+ },
+ props: {
+ userIds: Property.Array({
+ displayName: 'User IDs',
+ description: 'IDs of the 2 to 7 other users. The connected user is added automatically. Use Get User By Username or Search Users to find them.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/channels/group',
+ body: context.propsValue.userIds,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/delete-channel-category.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/delete-channel-category.ts
new file mode 100644
index 00000000000..51db14563a1
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/delete-channel-category.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const deleteChannelCategoryAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_delete_channel_category',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Delete Sidebar Category',
+ description: 'Deletes a custom sidebar category of a user.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Deletes a custom sidebar category of a user in a team; its channels move back to the default Channels category and no channel is affected. Only custom categories can be deleted; pass "me" for the connected account.',
+ idempotent: false,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ categoryId: Property.ShortText({
+ displayName: 'Category ID',
+ description: 'ID of a custom sidebar category. Use List Sidebar Categories to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, categoryId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/channels/categories/${encodeURIComponent(categoryId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-by-name.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-by-name.ts
new file mode 100644
index 00000000000..6e958e6645c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-by-name.ts
@@ -0,0 +1,45 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostCreateChannelOutputSchema } from '../../../output-schemas';
+
+export const getChannelByNameAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_channel_by_name',
+ outputSchema: mattermostCreateChannelOutputSchema,
+ displayName: 'Get Channel By Name',
+ description: 'Gets a channel by its handle within a team.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one channel by its unique handle (the name in its URL, e.g. "town-square") within a team; the usual way to turn a channel name into its ID. For a partial match use Search Channels.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ channelName: Property.ShortText({
+ displayName: 'Channel Name',
+ description: 'The channel\'s handle from its URL, e.g. "town-square", not its display name.',
+ required: true,
+ }),
+ includeDeleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Archived',
+ description: '"true" to also find an archived channel. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { teamId, channelName, includeDeleted } = context.propsValue;
+ const deleted = mattermostUtils.parseBoolean({ value: includeDeleted });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/${encodeURIComponent(teamId)}/channels/name/${encodeURIComponent(channelName)}`,
+ query: deleted !== undefined ? { include_deleted: String(deleted) } : undefined,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-category-order.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-category-order.ts
new file mode 100644
index 00000000000..47518ba319b
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-category-order.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetChannelCategoryOrderOutputSchema } from '../../../output-schemas';
+
+export const getChannelCategoryOrderAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_channel_category_order',
+ outputSchema: mattermostGetChannelCategoryOrderOutputSchema,
+ displayName: 'Get Sidebar Category Order',
+ description: 'Gets the order of a user\'s sidebar categories in a team.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the IDs of a user\'s sidebar categories in one team, top to bottom; pass "me" for the connected account. Change it with Update Sidebar Category Order.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ const { userId, teamId } = context.propsValue;
+ const order = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/channels/categories/order`,
+ });
+ return { order, count: order.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-category.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-category.ts
new file mode 100644
index 00000000000..6d8b34f9fd6
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-category.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateChannelCategoryOutputSchema } from '../../../output-schemas';
+
+export const getChannelCategoryAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_channel_category',
+ outputSchema: mattermostCreateChannelCategoryOutputSchema,
+ displayName: 'Get Sidebar Category',
+ description: 'Gets one of a user\'s sidebar categories.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one sidebar category of a user in a team, with its name, type, sorting and ordered channel IDs; pass "me" for the connected account.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ categoryId: Property.ShortText({
+ displayName: 'Category ID',
+ description: 'Sidebar category ID. Use List Sidebar Categories to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, categoryId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/channels/categories/${encodeURIComponent(categoryId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-member-counts.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-member-counts.ts
new file mode 100644
index 00000000000..d6e3d44c612
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-member-counts.ts
@@ -0,0 +1,35 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetChannelMemberCountsOutputSchema } from '../../../output-schemas';
+
+export const getChannelMemberCountsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_channel_member_counts',
+ outputSchema: mattermostGetChannelMemberCountsOutputSchema,
+ displayName: 'Get Channel Member Counts',
+ description: 'Gets the member count of several channels.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the member count of each given channel, keyed by channel ID. For one channel\'s pinned post and file counts too use Get Channel Stats.',
+ idempotent: true,
+ },
+ props: {
+ channelIds: Property.Array({
+ displayName: 'Channel IDs',
+ description: 'IDs of the channels to count. Use List User Channels or Search Channels to find them.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/channels/stats/member_count',
+ body: context.propsValue.channelIds,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-member.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-member.ts
new file mode 100644
index 00000000000..f6f6cd7147e
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-member.ts
@@ -0,0 +1,33 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAddChannelMemberOutputSchema } from '../../../output-schemas';
+
+export const getChannelMemberAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_channel_member',
+ outputSchema: mattermostAddChannelMemberOutputSchema,
+ displayName: 'Get Channel Member',
+ description: 'Gets one user\'s membership in a channel.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns a user\'s membership in a channel: channel roles, notification settings, and message counts; pass "me" for the connected account. Fails if the user is not a member.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ const { channelId, userId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/channels/${encodeURIComponent(channelId)}/members/${encodeURIComponent(userId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-members-by-ids.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-members-by-ids.ts
new file mode 100644
index 00000000000..59a66e549ee
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-members-by-ids.ts
@@ -0,0 +1,39 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetChannelMembersByIdsOutputSchema } from '../../../output-schemas';
+
+export const getChannelMembersByIdsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_channel_members_by_ids',
+ outputSchema: mattermostGetChannelMembersByIdsOutputSchema,
+ displayName: 'Get Channel Members By IDs',
+ description: 'Gets the channel memberships of several users.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the memberships in one channel of the given users; users not in the channel are left out, so it doubles as a membership check. For one user use Get Channel Member.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ userIds: Property.Array({
+ displayName: 'User IDs',
+ description: 'User IDs (26 characters) to look up. Use Get User By Username or Search Users to find them.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { channelId, userIds } = context.propsValue;
+ const members = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/channels/${encodeURIComponent(channelId)}/members/ids`,
+ body: userIds,
+ });
+ return { members, count: members.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-stats.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-stats.ts
new file mode 100644
index 00000000000..92c3dc5c488
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-stats.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetChannelStatsOutputSchema } from '../../../output-schemas';
+
+export const getChannelStatsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_channel_stats',
+ outputSchema: mattermostGetChannelStatsOutputSchema,
+ displayName: 'Get Channel Stats',
+ description: 'Gets a channel\'s member, pinned post and file counts.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns counts for one channel: members, pinned posts and files. For member counts of several channels at once use Get Channel Member Counts.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/channels/${encodeURIComponent(context.propsValue.channelId)}/stats`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-unread.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-unread.ts
new file mode 100644
index 00000000000..1c56bf77509
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel-unread.ts
@@ -0,0 +1,33 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetChannelUnreadOutputSchema } from '../../../output-schemas';
+
+export const getChannelUnreadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_channel_unread',
+ outputSchema: mattermostGetChannelUnreadOutputSchema,
+ displayName: 'Get Channel Unread',
+ description: 'Gets a user\'s unread message and mention counts in a channel.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns how many unread messages and mentions a user has in one channel; pass "me" for the connected account. Clear them with Mark Channels Read.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ channelId: mattermostAiProps.channelId({ required: true }),
+ },
+ async run(context) {
+ const { userId, channelId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/channels/${encodeURIComponent(channelId)}/unread`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel.ts
new file mode 100644
index 00000000000..3867172529b
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channel.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateChannelOutputSchema } from '../../../output-schemas';
+
+export const getChannelAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_channel',
+ outputSchema: mattermostCreateChannelOutputSchema,
+ displayName: 'Get Channel',
+ description: 'Gets a channel by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one channel by ID: type ("O" public, "P" private, "D" direct, "G" group message), names, header, purpose and team. To look up by name use Get Channel By Name.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/channels/${encodeURIComponent(context.propsValue.channelId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channels-by-ids.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channels-by-ids.ts
new file mode 100644
index 00000000000..c0117d5697b
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/get-channels-by-ids.ts
@@ -0,0 +1,39 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetChannelsByIdsOutputSchema } from '../../../output-schemas';
+
+export const getChannelsByIdsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_channels_by_ids',
+ outputSchema: mattermostGetChannelsByIdsOutputSchema,
+ displayName: 'Get Channels By IDs',
+ description: 'Gets several public channels of a team by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the public channels of one team matching a list of channel IDs. For a single channel of any type use Get Channel.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ channelIds: Property.Array({
+ displayName: 'Channel IDs',
+ description: 'IDs of public channels in the team. Use Search Channels or List Public Channels to find them.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { teamId, channelIds } = context.propsValue;
+ const channels = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/teams/${encodeURIComponent(teamId)}/channels/ids`,
+ body: channelIds,
+ });
+ return { channels, count: channels.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-all-channels.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-all-channels.ts
new file mode 100644
index 00000000000..88a306e4876
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-all-channels.ts
@@ -0,0 +1,52 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListAllChannelsOutputSchema } from '../../../output-schemas';
+
+export const listAllChannelsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_all_channels',
+ outputSchema: mattermostListAllChannelsOutputSchema,
+ displayName: 'List All Channels',
+ description: 'Lists public and private channels across all teams.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a page of public and private channels across every team. Needs the manage_system permission; to list one team\'s channels use List Public Channels, or Search All Channels to filter by text.',
+ idempotent: true,
+ },
+ props: {
+ excludeDefaultChannels: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Exclude Default Channels',
+ description: '"true" to leave out default channels such as Town Square and Off-Topic. Defaults to "false".',
+ }),
+ includeDeleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Archived',
+ description: '"true" to include archived channels. Defaults to "false".',
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { excludeDefaultChannels, includeDeleted, page, perPage } = context.propsValue;
+ const excludeDefault = mattermostUtils.parseBoolean({ value: excludeDefaultChannels });
+ const deleted = mattermostUtils.parseBoolean({ value: includeDeleted });
+ const channels = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/channels',
+ query: {
+ ...mattermostUtils.paging({ page, perPage }),
+ ...(excludeDefault !== undefined ? { exclude_default_channels: String(excludeDefault) } : {}),
+ ...(deleted !== undefined ? { include_deleted: String(deleted) } : {}),
+ },
+ });
+ return { channels, count: channels.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-archived-channels.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-archived-channels.ts
new file mode 100644
index 00000000000..e0067741a20
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-archived-channels.ts
@@ -0,0 +1,37 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListArchivedChannelsOutputSchema } from '../../../output-schemas';
+
+export const listArchivedChannelsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_archived_channels',
+ outputSchema: mattermostListArchivedChannelsOutputSchema,
+ displayName: 'List Archived Channels',
+ description: 'Lists the archived channels of a team.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a page of a team\'s archived channels, the ones Archive Channel hid. Pass a channel\'s ID to Restore Channel to bring it back.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { teamId, page, perPage } = context.propsValue;
+ const channels = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/${encodeURIComponent(teamId)}/channels/deleted`,
+ query: mattermostUtils.paging({ page, perPage }),
+ });
+ return { channels, count: channels.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-channel-categories.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-channel-categories.ts
new file mode 100644
index 00000000000..4b50d82ef64
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-channel-categories.ts
@@ -0,0 +1,33 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListChannelCategoriesOutputSchema } from '../../../output-schemas';
+
+export const listChannelCategoriesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_channel_categories',
+ outputSchema: mattermostListChannelCategoriesOutputSchema,
+ displayName: 'List Sidebar Categories',
+ description: 'Lists a user\'s sidebar categories in a team, with their channels.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a user\'s sidebar categories in one team (Favorites, Channels, Direct Messages and custom ones), each with its channel IDs in display order, plus the category order; pass "me" for the connected account. These are personal sidebar groupings, not team settings.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ const { userId, teamId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/channels/categories`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-channel-members.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-channel-members.ts
new file mode 100644
index 00000000000..0b9a86288db
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-channel-members.ts
@@ -0,0 +1,37 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListChannelMembersOutputSchema } from '../../../output-schemas';
+
+export const listChannelMembersAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_channel_members',
+ outputSchema: mattermostListChannelMembersOutputSchema,
+ displayName: 'List Channel Members',
+ description: 'Lists the members of a channel.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a page of a channel\'s memberships: user ID, channel roles, and notification settings. Use Get User for each member\'s profile; for specific users use Get Channel Members By IDs.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { channelId, page, perPage } = context.propsValue;
+ const members = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/channels/${encodeURIComponent(channelId)}/members`,
+ query: mattermostUtils.paging({ page, perPage }),
+ });
+ return { members, count: members.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-channel-timezones.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-channel-timezones.ts
new file mode 100644
index 00000000000..1fffb063134
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-channel-timezones.ts
@@ -0,0 +1,32 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListChannelTimezonesOutputSchema } from '../../../output-schemas';
+
+export const listChannelTimezonesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_channel_timezones',
+ outputSchema: mattermostListChannelTimezonesOutputSchema,
+ displayName: 'List Channel Timezones',
+ description: 'Lists the timezones of a channel\'s members.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the distinct timezone names (e.g. "Europe/Berlin") used by the members of a channel, useful for picking a meeting or reminder time.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ },
+ async run(context) {
+ const timezones = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/channels/${encodeURIComponent(context.propsValue.channelId)}/timezones`,
+ });
+ return { timezones, count: timezones.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-group-channel-common-teams.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-group-channel-common-teams.ts
new file mode 100644
index 00000000000..7743332cea7
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-group-channel-common-teams.ts
@@ -0,0 +1,36 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListGroupChannelCommonTeamsOutputSchema } from '../../../output-schemas';
+
+export const listGroupChannelCommonTeamsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_group_channel_common_teams',
+ outputSchema: mattermostListGroupChannelCommonTeamsOutputSchema,
+ displayName: 'List Group Message Common Teams',
+ description: 'Lists the teams every member of a group message belongs to.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the teams that all active members of a group message share; empty when there are none. Use it to pick the team for Convert Group Message To Channel.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({
+ required: true,
+ displayName: 'Group Message Channel ID',
+ description: 'ID of a group message channel (type "G"). Use Search Group Messages or List User Channels to find it.',
+ }),
+ },
+ async run(context) {
+ const teams = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/channels/${encodeURIComponent(context.propsValue.channelId)}/common_teams`,
+ });
+ return { teams, count: teams.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-pinned-posts.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-pinned-posts.ts
new file mode 100644
index 00000000000..9a5f0c3d00a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-pinned-posts.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListFlaggedPostsOutputSchema } from '../../../output-schemas';
+
+export const listPinnedPostsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_pinned_posts',
+ outputSchema: mattermostListFlaggedPostsOutputSchema,
+ displayName: 'List Pinned Posts',
+ description: 'Lists the pinned posts of a channel.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns every pinned post in a channel. Pin or unpin a post with Pin Post or Unpin Post.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/channels/${encodeURIComponent(context.propsValue.channelId)}/pinned`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-private-channels.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-private-channels.ts
new file mode 100644
index 00000000000..7e234deb65b
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-private-channels.ts
@@ -0,0 +1,37 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostGetChannelsByIdsOutputSchema } from '../../../output-schemas';
+
+export const listPrivateChannelsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_private_channels',
+ outputSchema: mattermostGetChannelsByIdsOutputSchema,
+ displayName: 'List Private Channels',
+ description: 'Lists all private channels of a team.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a page of every private channel in a team, including ones the connected user is not in. Needs the manage_system permission; regular users can see their own private channels with List User Team Channels.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { teamId, page, perPage } = context.propsValue;
+ const channels = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/${encodeURIComponent(teamId)}/channels/private`,
+ query: mattermostUtils.paging({ page, perPage }),
+ });
+ return { channels, count: channels.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-public-channels.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-public-channels.ts
new file mode 100644
index 00000000000..d5d9fd1906d
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-public-channels.ts
@@ -0,0 +1,37 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostGetChannelsByIdsOutputSchema } from '../../../output-schemas';
+
+export const listPublicChannelsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_public_channels',
+ outputSchema: mattermostGetChannelsByIdsOutputSchema,
+ displayName: 'List Public Channels',
+ description: 'Lists the public channels of a team.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a page of a team\'s active public channels, whether or not the connected user is a member. For the channels a user belongs to use List User Team Channels; to filter by text use Search Channels.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { teamId, page, perPage } = context.propsValue;
+ const channels = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/${encodeURIComponent(teamId)}/channels`,
+ query: mattermostUtils.paging({ page, perPage }),
+ });
+ return { channels, count: channels.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-user-channels.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-user-channels.ts
new file mode 100644
index 00000000000..215f6abc2ab
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-user-channels.ts
@@ -0,0 +1,41 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListArchivedChannelsOutputSchema } from '../../../output-schemas';
+
+export const listUserChannelsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_user_channels',
+ outputSchema: mattermostListArchivedChannelsOutputSchema,
+ displayName: 'List User Channels',
+ description: 'Lists every channel a user belongs to across all teams.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns every channel a user is a member of across all teams, including private channels and direct and group messages; pass "me" for the connected account. For one team use List User Team Channels.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ includeDeleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Archived',
+ description: '"true" to include archived channels. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { userId, includeDeleted } = context.propsValue;
+ const deleted = mattermostUtils.parseBoolean({ value: includeDeleted });
+ const channels = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/channels`,
+ query: deleted !== undefined ? { include_deleted: String(deleted) } : undefined,
+ });
+ return { channels, count: channels.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-user-team-channel-memberships.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-user-team-channel-memberships.ts
new file mode 100644
index 00000000000..9c59853bba1
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-user-team-channel-memberships.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListChannelMembersOutputSchema } from '../../../output-schemas';
+
+export const listUserTeamChannelMembershipsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_user_team_channel_memberships',
+ outputSchema: mattermostListChannelMembersOutputSchema,
+ displayName: 'List User Channel Memberships',
+ description: 'Lists a user\'s channel memberships and roles in a team.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns every channel membership of a user in one team, with channel roles, unread counts and notification settings; pass "me" for the connected account. For the channels themselves use List User Team Channels.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ const { userId, teamId } = context.propsValue;
+ const members = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/channels/members`,
+ });
+ return { members, count: members.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-user-team-channels.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-user-team-channels.ts
new file mode 100644
index 00000000000..d9d60b721e0
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/list-user-team-channels.ts
@@ -0,0 +1,42 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListArchivedChannelsOutputSchema } from '../../../output-schemas';
+
+export const listUserTeamChannelsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_user_team_channels',
+ outputSchema: mattermostListArchivedChannelsOutputSchema,
+ displayName: 'List User Team Channels',
+ description: 'Lists the channels a user belongs to in a team.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns every channel a user is a member of in one team, including private channels and direct and group messages; pass "me" for the connected account. Across all teams use List User Channels.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ includeDeleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Archived',
+ description: '"true" to include archived channels. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, includeDeleted } = context.propsValue;
+ const deleted = mattermostUtils.parseBoolean({ value: includeDeleted });
+ const channels = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/channels`,
+ query: deleted !== undefined ? { include_deleted: String(deleted) } : undefined,
+ });
+ return { channels, count: channels.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/mark-channels-read.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/mark-channels-read.ts
new file mode 100644
index 00000000000..3f053350054
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/mark-channels-read.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostMarkChannelsReadOutputSchema } from '../../../output-schemas';
+
+export const markChannelsReadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_mark_channels_read',
+ outputSchema: mattermostMarkChannelsReadOutputSchema,
+ displayName: 'Mark Channels Read',
+ description: 'Marks channels as read for a user.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Marks one or more channels as read up to now for a user, clearing their unread and mention counts; pass "me" for the connected account.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ channelIds: Property.Array({
+ displayName: 'Channel IDs',
+ description: 'IDs of the channels to mark read. Use List User Channels to find them.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, channelIds } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/channels/members/${encodeURIComponent(userId)}/mark_read`,
+ body: channelIds,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/move-channel.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/move-channel.ts
new file mode 100644
index 00000000000..f2f47a7b517
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/move-channel.ts
@@ -0,0 +1,45 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostCreateChannelOutputSchema } from '../../../output-schemas';
+
+export const moveChannelAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_move_channel',
+ outputSchema: mattermostCreateChannelOutputSchema,
+ displayName: 'Move Channel',
+ description: 'Moves a channel to another team.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Moves a public or private channel, with its messages, to another team. Fails if some members are not in the target team unless Force is "true", which removes them from the channel. Needs the manage_system permission.',
+ idempotent: false,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ teamId: mattermostAiProps.teamId({
+ required: true,
+ displayName: 'Target Team ID',
+ description: 'ID (26 characters) of the team to move the channel to. Use List Teams or Get Team By Name to find it.',
+ }),
+ force: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Force',
+ description: '"true" to remove channel members who are not in the target team and move anyway. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { channelId, teamId, force } = context.propsValue;
+ const forceMove = mattermostUtils.parseBoolean({ value: force });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/channels/${encodeURIComponent(channelId)}/move`,
+ body: { team_id: teamId, ...(forceMove !== undefined ? { force: forceMove } : {}) },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/patch-channel.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/patch-channel.ts
new file mode 100644
index 00000000000..0c65a97c6df
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/patch-channel.ts
@@ -0,0 +1,88 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateChannelOutputSchema } from '../../../output-schemas';
+
+export const patchChannelAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_patch_channel',
+ outputSchema: mattermostCreateChannelOutputSchema,
+ displayName: 'Update Channel',
+ description: 'Updates a channel\'s name, display name, purpose or header.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Changes a channel\'s name, display name, purpose or header; fields left empty stay as they are, and Clear Fields empties purpose or header. Direct and group messages only accept a header. Set at least one field. To switch public/private use Update Channel Privacy.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ name: Property.ShortText({
+ displayName: 'Name',
+ description: 'New unique handle used in the channel URL: lowercase letters, numbers, "-" and "_". The default channel cannot be renamed.',
+ required: false,
+ }),
+ displayName: Property.ShortText({
+ displayName: 'Display Name',
+ description: 'New channel name shown to users.',
+ required: false,
+ }),
+ purpose: Property.ShortText({
+ displayName: 'Purpose',
+ description: 'New short description of what the channel is for.',
+ required: false,
+ }),
+ header: Property.ShortText({
+ displayName: 'Header',
+ description: 'New Markdown text shown in the channel header.',
+ required: false,
+ }),
+ clearFields: Property.StaticMultiSelectDropdown({
+ displayName: 'Clear Fields',
+ description: 'Fields to empty: "purpose" and/or "header". Do not also set a value for a cleared field.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Purpose', value: 'purpose' },
+ { label: 'Header', value: 'header' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ const { channelId, name, displayName, purpose, header, clearFields } = context.propsValue;
+ const cleared = clearFields ?? [];
+ for (const field of cleared) {
+ if (field !== 'purpose' && field !== 'header') {
+ throw new Error(`Clear Fields accepts "purpose" or "header", got "${field}".`);
+ }
+ }
+ if (cleared.includes('purpose') && purpose !== undefined) {
+ throw new Error('Purpose is both set and listed in Clear Fields; pick one.');
+ }
+ if (cleared.includes('header') && header !== undefined) {
+ throw new Error('Header is both set and listed in Clear Fields; pick one.');
+ }
+ const body = {
+ ...(name !== undefined ? { name } : {}),
+ ...(displayName !== undefined ? { display_name: displayName } : {}),
+ ...(purpose !== undefined ? { purpose } : {}),
+ ...(header !== undefined ? { header } : {}),
+ ...(cleared.includes('purpose') ? { purpose: '' } : {}),
+ ...(cleared.includes('header') ? { header: '' } : {}),
+ };
+ if (Object.keys(body).length === 0) {
+ throw new Error('Set at least one of Name, Display Name, Purpose, Header or Clear Fields.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/channels/${encodeURIComponent(channelId)}/patch`,
+ body,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/remove-channel-member.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/remove-channel-member.ts
new file mode 100644
index 00000000000..b6c0c22f305
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/remove-channel-member.ts
@@ -0,0 +1,33 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const removeChannelMemberAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_remove_channel_member',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Remove Channel Member',
+ description: 'Removes a user from a channel.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Removes one user from a public or private channel; pass "me" to leave it as the connected user. Add Channel Member reverses it. Members cannot be removed from direct or group messages or the default channel.',
+ idempotent: false,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ const { channelId, userId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/channels/${encodeURIComponent(channelId)}/members/${encodeURIComponent(userId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/restore-channel.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/restore-channel.ts
new file mode 100644
index 00000000000..c049ee6f3e8
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/restore-channel.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateChannelOutputSchema } from '../../../output-schemas';
+
+export const restoreChannelAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_restore_channel',
+ outputSchema: mattermostCreateChannelOutputSchema,
+ displayName: 'Restore Channel',
+ description: 'Restores an archived channel.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Unarchives a channel archived by Archive Channel, making it active again. Find archived channels with List Archived Channels. Fails if the channel is not archived.',
+ idempotent: false,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({
+ required: true,
+ description: 'ID (26 characters) of the archived channel. Use List Archived Channels to find it.',
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/channels/${encodeURIComponent(context.propsValue.channelId)}/restore`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/search-all-channels.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/search-all-channels.ts
new file mode 100644
index 00000000000..067528a3c16
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/search-all-channels.ts
@@ -0,0 +1,80 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostSearchAllChannelsOutputSchema } from '../../../output-schemas';
+
+export const searchAllChannelsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_search_all_channels',
+ outputSchema: mattermostSearchAllChannelsOutputSchema,
+ displayName: 'Search All Channels',
+ description: 'Searches public and private channels across all teams.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Searches public and private channels across all teams by name, display name or purpose. An admin-level search; to search one team\'s channels as a regular member use Search Channels.',
+ idempotent: true,
+ },
+ props: {
+ term: Property.ShortText({
+ displayName: 'Term',
+ description: 'Text to match against the channel name, display name and purpose.',
+ required: true,
+ }),
+ teamIds: Property.Array({
+ displayName: 'Team IDs',
+ description: 'Only channels in these teams. Use List Teams to find them.',
+ required: false,
+ }),
+ publicOnly: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Public',
+ description: '"true" to return public channels. Combine with Private to get both; leave both empty for both.',
+ }),
+ privateOnly: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Private',
+ description: '"true" to return private channels. Combine with Public to get both; leave both empty for both.',
+ }),
+ deleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Archived Only',
+ description: '"true" to return only archived channels.',
+ }),
+ excludeDefaultChannels: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Exclude Default Channels',
+ description: '"true" to leave out default channels such as Town Square and Off-Topic.',
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { term, teamIds, publicOnly, privateOnly, deleted, excludeDefaultChannels, page, perPage } =
+ context.propsValue;
+ const isPublic = mattermostUtils.parseBoolean({ value: publicOnly });
+ const isPrivate = mattermostUtils.parseBoolean({ value: privateOnly });
+ const isDeleted = mattermostUtils.parseBoolean({ value: deleted });
+ const excludeDefault = mattermostUtils.parseBoolean({ value: excludeDefaultChannels });
+ const paging = mattermostUtils.paging({ page, perPage });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/channels/search',
+ body: {
+ term,
+ page: Number(paging.page),
+ per_page: Number(paging.per_page),
+ ...(teamIds && teamIds.length > 0 ? { team_ids: teamIds } : {}),
+ ...(isPublic !== undefined ? { public: isPublic } : {}),
+ ...(isPrivate !== undefined ? { private: isPrivate } : {}),
+ ...(isDeleted !== undefined ? { deleted: isDeleted } : {}),
+ ...(excludeDefault !== undefined ? { exclude_default_channels: excludeDefault } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/search-channels.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/search-channels.ts
new file mode 100644
index 00000000000..d1cb7955102
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/search-channels.ts
@@ -0,0 +1,39 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetChannelsByIdsOutputSchema } from '../../../output-schemas';
+
+export const searchChannelsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_search_channels',
+ outputSchema: mattermostGetChannelsByIdsOutputSchema,
+ displayName: 'Search Channels',
+ description: 'Searches a team\'s public channels by name.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Finds a team\'s public channels whose name or display name matches the term; users without permission to list the team\'s channels only get channels they belong to. Across all teams use Search All Channels; for an exact handle use Get Channel By Name.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ term: Property.ShortText({
+ displayName: 'Term',
+ description: 'Text to match against the channel name and display name.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { teamId, term } = context.propsValue;
+ const channels = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/teams/${encodeURIComponent(teamId)}/channels/search`,
+ body: { term },
+ });
+ return { channels, count: channels.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/search-group-channels.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/search-group-channels.ts
new file mode 100644
index 00000000000..bf4713fadd6
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/search-group-channels.ts
@@ -0,0 +1,36 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListArchivedChannelsOutputSchema } from '../../../output-schemas';
+
+export const searchGroupChannelsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_search_group_channels',
+ outputSchema: mattermostListArchivedChannelsOutputSchema,
+ displayName: 'Search Group Messages',
+ description: 'Searches the connected user\'s group messages by member username.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Finds the connected user\'s group message channels (type "G", 3 to 8 people) whose members\' usernames match the term. For channels by name use Search Channels.',
+ idempotent: true,
+ },
+ props: {
+ term: Property.ShortText({
+ displayName: 'Term',
+ description: 'Text to match against the usernames of the group message members.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const channels = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/channels/group/search',
+ body: { term: context.propsValue.term },
+ });
+ return { channels, count: channels.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/set-channel-members.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/set-channel-members.ts
new file mode 100644
index 00000000000..32744dd853e
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/set-channel-members.ts
@@ -0,0 +1,70 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostSetChannelMembersOutputSchema } from '../../../output-schemas';
+
+export const setChannelMembersAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_set_channel_members',
+ outputSchema: mattermostSetChannelMembersOutputSchema,
+ displayName: 'Set Channel Members',
+ description: 'Replaces a channel\'s whole member list; everyone not listed is removed.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Replaces the full member list of a public or private channel: listed users are added and EVERYONE NOT LISTED IS REMOVED. To add or remove one person use Add Channel Member or Remove Channel Member instead. Channel Admins, when given, become the only channel admins. Needs the manage_system permission and server 11.7+; direct and group messages are rejected.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ members: Property.Array({
+ displayName: 'Members',
+ description: 'User IDs that should be in the channel afterwards. Every current member not listed here (or in Channel Admins) is removed.',
+ required: true,
+ }),
+ channelAdmins: Property.Array({
+ displayName: 'Channel Admins',
+ description: 'User IDs that should be channel admins afterwards; they are also kept as members and every other member is demoted. Leave empty to keep existing admin roles.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { channelId, members, channelAdmins } = context.propsValue;
+ const admins = channelAdmins ?? [];
+ if (members.length === 0 && admins.length === 0) {
+ throw new Error('Members is empty, which would remove everyone from the channel. List the users who should stay.');
+ }
+ const response = await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/channels/${encodeURIComponent(channelId)}/members`,
+ body: { members, ...(admins.length > 0 ? { channel_admins: admins } : {}) },
+ });
+ const batches = parseNdjson({ response });
+ const interrupted = batches.find(
+ (batch) => typeof batch === 'object' && batch !== null && 'error' in batch,
+ );
+ if (interrupted !== undefined) {
+ throw new Error(
+ `Set Channel Members stopped part-way; membership may be partly changed. Batches applied before it stopped: ${JSON.stringify(batches)}`,
+ );
+ }
+ return { batches, count: batches.length };
+ },
+});
+
+function parseNdjson({ response }: { response: unknown }): unknown[] {
+ if (response === undefined || response === null) {
+ return [];
+ }
+ if (typeof response !== 'string') {
+ return [response];
+ }
+ return response
+ .split('\n')
+ .filter((line) => line.trim().length > 0)
+ .map((line): unknown => JSON.parse(line));
+}
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-categories.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-categories.ts
new file mode 100644
index 00000000000..b0de33d670f
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-categories.ts
@@ -0,0 +1,64 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUpdateChannelCategoriesOutputSchema } from '../../../output-schemas';
+
+export const updateChannelCategoriesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_channel_categories',
+ outputSchema: mattermostUpdateChannelCategoriesOutputSchema,
+ displayName: 'Update Sidebar Categories',
+ description: 'Updates several of a user\'s sidebar categories at once.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Updates several sidebar categories of a user in one team in a single call, e.g. moving a channel from one category to another by giving both new channel lists; pass "me" for the connected account. Keys left out of a category stay as they are. Category IDs come from List Sidebar Categories. For one category use Update Sidebar Category.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ categories: Property.Array({
+ displayName: 'Categories',
+ description:
+ 'Category changes, each an object with "id" plus any of "display_name", "channel_ids" (the full ordered list for that category), "sorting" ("alpha", "recent" or "manual"), "muted" and "collapsed" (true/false). Example: [{"id": "abc", "channel_ids": ["c1", "c2"]}].',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, categories } = context.propsValue;
+ if (categories.length === 0) {
+ throw new Error('Categories is empty; give at least one category change.');
+ }
+ const path = `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/channels/categories`;
+ const current = await mattermostClient.request<{ categories: Record<string, unknown>[] }>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path,
+ });
+ const merged = categories.map((change, index) => {
+ if (!isRecord(change) || typeof change['id'] !== 'string') {
+ throw new Error(`Categories item ${index} must be an object with a string "id".`);
+ }
+ const existing = current.categories.find((category) => category['id'] === change['id']);
+ if (existing === undefined) {
+ throw new Error(`Categories item ${index}: no sidebar category "${change['id']}" for this user and team.`);
+ }
+ return { ...existing, ...change };
+ });
+ const updated = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path,
+ body: merged,
+ });
+ return { categories: updated, count: updated.length };
+ },
+});
+
+function isRecord(value: unknown): value is Record<string, unknown> {
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
+}
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-category-order.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-category-order.ts
new file mode 100644
index 00000000000..a762bccb476
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-category-order.ts
@@ -0,0 +1,40 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetChannelCategoryOrderOutputSchema } from '../../../output-schemas';
+
+export const updateChannelCategoryOrderAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_channel_category_order',
+ outputSchema: mattermostGetChannelCategoryOrderOutputSchema,
+ displayName: 'Update Sidebar Category Order',
+ description: 'Reorders a user\'s sidebar categories in a team.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Sets the top-to-bottom order of a user\'s sidebar categories in one team; pass "me" for the connected account. The list must contain every category ID from Get Sidebar Category Order, rearranged.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ order: Property.Array({
+ displayName: 'Category IDs In Order',
+ description: 'All of the user\'s category IDs for this team, top to bottom.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, order } = context.propsValue;
+ const updated = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/channels/categories/order`,
+ body: order,
+ });
+ return { order: updated, count: updated.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-category.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-category.ts
new file mode 100644
index 00000000000..13e1977c793
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-category.ts
@@ -0,0 +1,95 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostCreateChannelCategoryOutputSchema } from '../../../output-schemas';
+
+export const updateChannelCategoryAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_channel_category',
+ outputSchema: mattermostCreateChannelCategoryOutputSchema,
+ displayName: 'Update Sidebar Category',
+ description: 'Renames, reorders, mutes or collapses one of a user\'s sidebar categories.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Changes one sidebar category of a user in a team: name, channel list and order, sorting, muted or collapsed; pass "me" for the connected account. Fields left empty stay as they are. Channel IDs replaces the category\'s whole channel list. Set at least one field; to change several categories at once use Update Sidebar Categories.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ categoryId: Property.ShortText({
+ displayName: 'Category ID',
+ description: 'Sidebar category ID. Use List Sidebar Categories to find it.',
+ required: true,
+ }),
+ displayName: Property.ShortText({
+ displayName: 'Display Name',
+ description: 'New category name. Only custom categories can be renamed.',
+ required: false,
+ }),
+ channelIds: Property.Array({
+ displayName: 'Channel IDs',
+ description: 'The full ordered list of channel IDs for this category; channels added here leave their old category.',
+ required: false,
+ }),
+ sorting: Property.StaticDropdown({
+ displayName: 'Sorting',
+ description: '"alpha" for alphabetical, "recent" for most recent activity, "manual" for the Channel IDs order.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Alphabetical', value: 'alpha' },
+ { label: 'Recent Activity', value: 'recent' },
+ { label: 'Manual', value: 'manual' },
+ ],
+ },
+ }),
+ muted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Muted',
+ description: '"true" to mute every channel in the category, "false" to unmute.',
+ }),
+ collapsed: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Collapsed',
+ description: '"true" to collapse the category in the sidebar, "false" to expand it.',
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, categoryId, displayName, channelIds, sorting, muted, collapsed } =
+ context.propsValue;
+ if (sorting !== undefined && sorting !== 'alpha' && sorting !== 'recent' && sorting !== 'manual') {
+ throw new Error(`Sorting must be "alpha", "recent" or "manual", got "${sorting}".`);
+ }
+ const isMuted = mattermostUtils.parseBoolean({ value: muted });
+ const isCollapsed = mattermostUtils.parseBoolean({ value: collapsed });
+ const changes = {
+ ...(displayName !== undefined ? { display_name: displayName } : {}),
+ ...(channelIds && channelIds.length > 0 ? { channel_ids: channelIds } : {}),
+ ...(sorting !== undefined ? { sorting } : {}),
+ ...(isMuted !== undefined ? { muted: isMuted } : {}),
+ ...(isCollapsed !== undefined ? { collapsed: isCollapsed } : {}),
+ };
+ if (Object.keys(changes).length === 0) {
+ throw new Error('Set at least one of Display Name, Channel IDs, Sorting, Muted or Collapsed.');
+ }
+ const path = `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/channels/categories/${encodeURIComponent(categoryId)}`;
+ const current = await mattermostClient.request<Record<string, unknown>>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path,
+ });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path,
+ body: { ...current, ...changes },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-member-roles.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-member-roles.ts
new file mode 100644
index 00000000000..8b42a0e9c0a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-member-roles.ts
@@ -0,0 +1,49 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const updateChannelMemberRolesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_channel_member_roles',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Update Channel Member Role',
+ description: 'Makes a channel member a channel admin or a regular member.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Promotes a channel member to channel admin or demotes them to a regular member. The user must already be in the channel (Add Channel Member). Needs the manage_channel_roles permission.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ userId: mattermostAiProps.userId({ required: true }),
+ role: Property.StaticDropdown({
+ displayName: 'Role',
+ description: '"admin" for channel admin, "member" for a regular channel member.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Channel Admin', value: 'admin' },
+ { label: 'Member', value: 'member' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ const { channelId, userId, role } = context.propsValue;
+ if (role !== 'admin' && role !== 'member') {
+ throw new Error(`Role must be "admin" or "member", got "${role}".`);
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/channels/${encodeURIComponent(channelId)}/members/${encodeURIComponent(userId)}/schemeRoles`,
+ body: { scheme_admin: role === 'admin', scheme_user: true },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-notify-props.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-notify-props.ts
new file mode 100644
index 00000000000..1625ec5d65a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-notify-props.ts
@@ -0,0 +1,81 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+const LEVELS = ['all', 'mention', 'none', 'default'] as const;
+const EMAIL_LEVELS = ['true', 'false', 'default'] as const;
+const MARK_UNREAD_LEVELS = ['all', 'mention'] as const;
+
+export const updateChannelNotifyPropsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_channel_notify_props',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Update Channel Notifications',
+ description: 'Changes a user\'s notification settings for a channel.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Changes a user\'s email, push and desktop notification levels and unread marking for one channel; pass "me" for the connected account. Fields left empty stay as they are; "default" falls back to the user\'s global setting. Set at least one field.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ userId: mattermostAiProps.userId({ required: true }),
+ desktop: levelDropdown({ displayName: 'Desktop', options: LEVELS }),
+ push: levelDropdown({ displayName: 'Push', options: LEVELS }),
+ email: levelDropdown({ displayName: 'Email', options: EMAIL_LEVELS }),
+ markUnread: levelDropdown({ displayName: 'Mark Unread', options: MARK_UNREAD_LEVELS }),
+ },
+ async run(context) {
+ const { channelId, userId, desktop, push, email, markUnread } = context.propsValue;
+ checkLevel({ field: 'Desktop', value: desktop, allowed: LEVELS });
+ checkLevel({ field: 'Push', value: push, allowed: LEVELS });
+ checkLevel({ field: 'Email', value: email, allowed: EMAIL_LEVELS });
+ checkLevel({ field: 'Mark Unread', value: markUnread, allowed: MARK_UNREAD_LEVELS });
+ const body = {
+ ...(desktop !== undefined ? { desktop } : {}),
+ ...(push !== undefined ? { push } : {}),
+ ...(email !== undefined ? { email } : {}),
+ ...(markUnread !== undefined ? { mark_unread: markUnread } : {}),
+ };
+ if (Object.keys(body).length === 0) {
+ throw new Error('Set at least one of Desktop, Push, Email or Mark Unread.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/channels/${encodeURIComponent(channelId)}/members/${encodeURIComponent(userId)}/notify_props`,
+ body,
+ });
+ },
+});
+
+function levelDropdown({ displayName, options }: { displayName: string; options: readonly string[] }) {
+ return Property.StaticDropdown({
+ displayName,
+ description: `One of ${options.map((option) => `"${option}"`).join(', ')}.`,
+ required: false,
+ options: {
+ disabled: false,
+ options: options.map((option) => ({ label: option, value: option })),
+ },
+ });
+}
+
+function checkLevel({
+ field,
+ value,
+ allowed,
+}: {
+ field: string;
+ value: string | undefined;
+ allowed: readonly string[];
+}): void {
+ if (value !== undefined && !allowed.includes(value)) {
+ throw new Error(`${field} must be one of ${allowed.join(', ')}, got "${value}".`);
+ }
+}
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-privacy.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-privacy.ts
new file mode 100644
index 00000000000..e609b8f91e3
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/channels/update-channel-privacy.ts
@@ -0,0 +1,48 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateChannelOutputSchema } from '../../../output-schemas';
+
+export const updateChannelPrivacyAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_channel_privacy',
+ outputSchema: mattermostCreateChannelOutputSchema,
+ displayName: 'Update Channel Privacy',
+ description: 'Converts a channel between public and private.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Makes a channel public ("O") or private ("P"). Converting to private hides it from non-members; converting back makes its history visible to the whole team. Direct and group messages cannot be converted.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ privacy: Property.StaticDropdown({
+ displayName: 'Privacy',
+ description: '"O" for a public channel, "P" for a private channel.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Public', value: 'O' },
+ { label: 'Private', value: 'P' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ const { channelId, privacy } = context.propsValue;
+ if (privacy !== 'O' && privacy !== 'P') {
+ throw new Error(`Privacy must be "O" or "P", got "${privacy}".`);
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/channels/${encodeURIComponent(channelId)}/privacy`,
+ body: { privacy },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/commands/create-command.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/create-command.ts
new file mode 100644
index 00000000000..c2677292a4c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/create-command.ts
@@ -0,0 +1,100 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostCreateCommandOutputSchema } from '../../../output-schemas';
+
+export const createCommandAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_create_command',
+ outputSchema: mattermostCreateCommandOutputSchema,
+ displayName: 'Create Slash Command',
+ description: 'Creates a custom slash command in a team.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a custom slash command in a team that calls the given URL when a user types "/<trigger>". Needs custom slash commands enabled on the server. Not idempotent: a trigger word already used in the team fails.',
+ idempotent: false,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ trigger: Property.ShortText({
+ displayName: 'Trigger Word',
+ description: 'Word that runs the command, without the leading "/", e.g. "deploy".',
+ required: true,
+ }),
+ url: Property.ShortText({
+ displayName: 'Request URL',
+ description: 'URL Mattermost calls when the command runs.',
+ required: true,
+ }),
+ method: Property.StaticDropdown({
+ displayName: 'Request Method',
+ description: '"P" for POST, "G" for GET.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'POST', value: 'P' },
+ { label: 'GET', value: 'G' },
+ ],
+ },
+ }),
+ displayName: Property.ShortText({
+ displayName: 'Title',
+ description: 'Command title shown in the integrations list.',
+ required: false,
+ }),
+ description: Property.ShortText({
+ displayName: 'Description',
+ description: 'What the command does.',
+ required: false,
+ }),
+ username: Property.ShortText({
+ displayName: 'Response Username',
+ description: 'Username the command\'s responses are posted as.',
+ required: false,
+ }),
+ autoComplete: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Autocomplete',
+ description: '"true" to list the command in the slash-command autocomplete. Defaults to "false".',
+ }),
+ autoCompleteDesc: Property.ShortText({
+ displayName: 'Autocomplete Description',
+ description: 'Description shown in autocomplete.',
+ required: false,
+ }),
+ autoCompleteHint: Property.ShortText({
+ displayName: 'Autocomplete Hint',
+ description: 'Argument hint shown in autocomplete, e.g. "[environment]".',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ if (p.method !== 'P' && p.method !== 'G') {
+ throw new Error(`Request Method must be "P" or "G", got "${p.method}".`);
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/commands',
+ body: {
+ team_id: p.teamId,
+ trigger: p.trigger,
+ url: p.url,
+ method: p.method,
+ display_name: p.displayName,
+ description: p.description,
+ username: p.username,
+ auto_complete: mattermostUtils.parseBoolean({ value: p.autoComplete }),
+ auto_complete_desc: p.autoCompleteDesc,
+ auto_complete_hint: p.autoCompleteHint,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/commands/delete-command.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/delete-command.ts
new file mode 100644
index 00000000000..1113b47f0a9
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/delete-command.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const deleteCommandAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_delete_command',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Delete Slash Command',
+ description: 'Deletes a custom slash command.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a custom slash command. Takes the ID from List Slash Commands or Create Slash Command. Needs the manage_slash_commands permission in the command\'s team. Not idempotent: a second call fails because the command is gone.',
+ idempotent: false,
+ },
+ props: {
+ commandId: Property.ShortText({
+ displayName: 'Command ID',
+ description: 'Custom slash command ID (26 characters). Use List Slash Commands or Create Slash Command to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/commands/${encodeURIComponent(context.propsValue.commandId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/commands/execute-command.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/execute-command.ts
new file mode 100644
index 00000000000..bf8a8e43243
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/execute-command.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostExecuteCommandOutputSchema } from '../../../output-schemas';
+
+export const executeCommandAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_execute_command',
+ outputSchema: mattermostExecuteCommandOutputSchema,
+ displayName: 'Execute Slash Command',
+ description: 'Runs a slash command in a channel as the connected user.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Runs a built-in or custom slash command in a channel as the connected user, exactly as if typed there, and returns the command\'s response. Use List Slash Commands to see which triggers exist in the team. Not idempotent: the command\'s effect happens again on each call.',
+ idempotent: false,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ command: Property.ShortText({
+ displayName: 'Command',
+ description: 'Full command with its leading "/" and arguments, e.g. "/echo hello".',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { channelId, command } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/commands/execute',
+ body: { channel_id: channelId, command },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/commands/get-command.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/get-command.ts
new file mode 100644
index 00000000000..9e6f2b57525
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/get-command.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateCommandOutputSchema } from '../../../output-schemas';
+
+export const getCommandAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_command',
+ outputSchema: mattermostCreateCommandOutputSchema,
+ displayName: 'Get Slash Command',
+ description: 'Gets a custom slash command by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one custom slash command with its trigger, request URL, method and token. Takes the ID from List Slash Commands or Create Slash Command. Needs the manage_slash_commands permission in the command\'s team.',
+ idempotent: true,
+ },
+ props: {
+ commandId: Property.ShortText({
+ displayName: 'Command ID',
+ description: 'Custom slash command ID (26 characters). Use List Slash Commands or Create Slash Command to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/commands/${encodeURIComponent(context.propsValue.commandId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/commands/list-commands.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/list-commands.ts
new file mode 100644
index 00000000000..1221cff5a8a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/list-commands.ts
@@ -0,0 +1,44 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListCommandsOutputSchema } from '../../../output-schemas';
+
+export const listCommandsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_commands',
+ outputSchema: mattermostListCommandsOutputSchema,
+ displayName: 'List Slash Commands',
+ description: 'Lists the slash commands of a team.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the slash commands available in a team: the built-in system commands plus the custom ones the connection may manage, or only the custom ones with Custom Only set to "true". Listing custom commands needs the manage_slash_commands permission.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ customOnly: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Custom Only',
+ description: '"true" to return only custom slash commands. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { teamId, customOnly } = context.propsValue;
+ const custom = mattermostUtils.parseBoolean({ value: customOnly });
+ const commands = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/commands',
+ query: {
+ team_id: teamId,
+ ...(custom !== undefined ? { custom_only: String(custom) } : {}),
+ },
+ });
+ return { commands, count: commands.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/commands/move-command.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/move-command.ts
new file mode 100644
index 00000000000..b7f9a07ec58
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/move-command.ts
@@ -0,0 +1,41 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const moveCommandAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_move_command',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Move Slash Command',
+ description: 'Moves a custom slash command to another team.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Moves a custom slash command to another team. Takes the ID from List Slash Commands or Create Slash Command. Needs the manage_slash_commands permission in both teams; fails if the trigger word is already used in the destination team.',
+ idempotent: true,
+ },
+ props: {
+ commandId: Property.ShortText({
+ displayName: 'Command ID',
+ description: 'Custom slash command ID (26 characters). Use List Slash Commands or Create Slash Command to find it.',
+ required: true,
+ }),
+ teamId: mattermostAiProps.teamId({
+ required: true,
+ displayName: 'Destination Team ID',
+ }),
+ },
+ async run(context) {
+ const { commandId, teamId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/commands/${encodeURIComponent(commandId)}/move`,
+ body: { team_id: teamId },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/commands/regenerate-command-token.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/regenerate-command-token.ts
new file mode 100644
index 00000000000..95fa62ae616
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/regenerate-command-token.ts
@@ -0,0 +1,32 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+
+export const regenerateCommandTokenAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_regenerate_command_token',
+ displayName: 'Regenerate Slash Command Token',
+ description: 'Replaces a custom slash command\'s verification token.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Issues a new verification token for a custom slash command; the old token stops working, so the receiving service must be updated. Takes the ID from List Slash Commands or Create Slash Command. Not idempotent: each call issues a different token.',
+ idempotent: false,
+ },
+ props: {
+ commandId: Property.ShortText({
+ displayName: 'Command ID',
+ description: 'Custom slash command ID (26 characters). Use List Slash Commands or Create Slash Command to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/commands/${encodeURIComponent(context.propsValue.commandId)}/regen_token`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/commands/update-command.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/update-command.ts
new file mode 100644
index 00000000000..b1bcc26b8b3
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/commands/update-command.ts
@@ -0,0 +1,111 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostCreateCommandOutputSchema } from '../../../output-schemas';
+
+export const updateCommandAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_command',
+ outputSchema: mattermostCreateCommandOutputSchema,
+ displayName: 'Update Slash Command',
+ description: 'Changes a custom slash command\'s settings.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Changes a custom slash command\'s trigger, URL, method, title, description, response username or autocomplete settings; fields not given keep their value. Takes the ID from List Slash Commands or Create Slash Command. Use Move Slash Command to change its team.',
+ idempotent: true,
+ },
+ props: {
+ commandId: Property.ShortText({
+ displayName: 'Command ID',
+ description: 'Custom slash command ID (26 characters). Use List Slash Commands or Create Slash Command to find it.',
+ required: true,
+ }),
+ trigger: Property.ShortText({
+ displayName: 'Trigger Word',
+ description: 'Word that runs the command, without the leading "/", e.g. "deploy".',
+ required: false,
+ }),
+ url: Property.ShortText({
+ displayName: 'Request URL',
+ description: 'URL Mattermost calls when the command runs.',
+ required: false,
+ }),
+ method: Property.StaticDropdown({
+ displayName: 'Request Method',
+ description: '"P" for POST, "G" for GET.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'POST', value: 'P' },
+ { label: 'GET', value: 'G' },
+ ],
+ },
+ }),
+ displayName: Property.ShortText({
+ displayName: 'Title',
+ description: 'Command title shown in the integrations list.',
+ required: false,
+ }),
+ description: Property.ShortText({
+ displayName: 'Description',
+ description: 'What the command does.',
+ required: false,
+ }),
+ username: Property.ShortText({
+ displayName: 'Response Username',
+ description: 'Username the command\'s responses are posted as.',
+ required: false,
+ }),
+ autoComplete: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Autocomplete',
+ description: '"true" to list the command in the slash-command autocomplete, "false" to hide it.',
+ }),
+ autoCompleteDesc: Property.ShortText({
+ displayName: 'Autocomplete Description',
+ description: 'Description shown in autocomplete.',
+ required: false,
+ }),
+ autoCompleteHint: Property.ShortText({
+ displayName: 'Autocomplete Hint',
+ description: 'Argument hint shown in autocomplete, e.g. "[environment]".',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ if (p.method !== undefined && p.method !== 'P' && p.method !== 'G') {
+ throw new Error(`Request Method must be "P" or "G", got "${p.method}".`);
+ }
+ const autoComplete = mattermostUtils.parseBoolean({ value: p.autoComplete });
+ const path = `/commands/${encodeURIComponent(p.commandId)}`;
+ const current = await mattermostClient.request<Record<string, unknown>>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path,
+ });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path,
+ body: {
+ ...current,
+ ...(p.trigger !== undefined ? { trigger: p.trigger } : {}),
+ ...(p.url !== undefined ? { url: p.url } : {}),
+ ...(p.method !== undefined ? { method: p.method } : {}),
+ ...(p.displayName !== undefined ? { display_name: p.displayName } : {}),
+ ...(p.description !== undefined ? { description: p.description } : {}),
+ ...(p.username !== undefined ? { username: p.username } : {}),
+ ...(autoComplete !== undefined ? { auto_complete: autoComplete } : {}),
+ ...(p.autoCompleteDesc !== undefined ? { auto_complete_desc: p.autoCompleteDesc } : {}),
+ ...(p.autoCompleteHint !== undefined ? { auto_complete_hint: p.autoCompleteHint } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/create-emoji.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/create-emoji.ts
new file mode 100644
index 00000000000..72fac33432a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/create-emoji.ts
@@ -0,0 +1,46 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostApi } from '../../../common/api';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateEmojiOutputSchema } from '../../../output-schemas';
+
+export const createEmojiAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_create_emoji',
+ outputSchema: mattermostCreateEmojiOutputSchema,
+ displayName: 'Create Custom Emoji',
+ description: 'Uploads an image as a custom emoji.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Uploads an image (GIF, PNG or JPEG, up to 512 KB) as a custom emoji with the given name. Needs custom emoji enabled on the server. Not idempotent: a taken name fails.',
+ idempotent: false,
+ },
+ props: {
+ name: Property.ShortText({
+ displayName: 'Name',
+ description: 'Emoji name without colons: lowercase letters, numbers, "-", "+" and "_", e.g. "party_parrot".',
+ required: true,
+ }),
+ image: Property.File({
+ displayName: 'Image',
+ description: 'GIF, PNG or JPEG image, up to 512 KB.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { name, image } = context.propsValue;
+ const me = await mattermostApi.getMe({ auth: context.auth });
+ const form = new FormData();
+ form.append('image', new Blob([new Uint8Array(image.data)]), image.filename);
+ form.append('emoji', JSON.stringify({ name, creator_id: me.id }));
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/emoji',
+ body: form,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/delete-emoji.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/delete-emoji.ts
new file mode 100644
index 00000000000..26de45a3a63
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/delete-emoji.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const deleteEmojiAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_delete_emoji',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Delete Custom Emoji',
+ description: 'Deletes a custom emoji.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a custom emoji; existing reactions with it stop rendering. Needs to be the emoji\'s creator or have manage_team / manage_system permission. Not idempotent: a second call fails because the emoji is gone.',
+ idempotent: false,
+ },
+ props: {
+ emojiId: Property.ShortText({
+ displayName: 'Emoji ID',
+ description: 'Custom emoji ID (26 characters). Use List Custom Emojis, Search Custom Emojis or Get Custom Emoji By Name to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/emoji/${encodeURIComponent(context.propsValue.emojiId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emoji-by-name.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emoji-by-name.ts
new file mode 100644
index 00000000000..b00d8c5b45b
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emoji-by-name.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateEmojiOutputSchema } from '../../../output-schemas';
+
+export const getEmojiByNameAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_emoji_by_name',
+ outputSchema: mattermostCreateEmojiOutputSchema,
+ displayName: 'Get Custom Emoji By Name',
+ description: 'Gets a custom emoji by its name.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one custom emoji (ID, name, creator) by its exact name. Built-in emoji like "thumbsup" are not found. Use Get Custom Emojis By Names for several at once.',
+ idempotent: true,
+ },
+ props: {
+ emojiName: Property.ShortText({
+ displayName: 'Emoji Name',
+ description: 'Exact custom emoji name without colons, e.g. "party_parrot".',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/emoji/name/${encodeURIComponent(context.propsValue.emojiName)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emoji-image.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emoji-image.ts
new file mode 100644
index 00000000000..9ef5237e4d6
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emoji-image.ts
@@ -0,0 +1,37 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostDownloadFileOutputSchema } from '../../../output-schemas';
+
+export const getEmojiImageAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_emoji_image',
+ outputSchema: mattermostDownloadFileOutputSchema,
+ displayName: 'Get Custom Emoji Image',
+ description: 'Downloads the image of a custom emoji.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Downloads a custom emoji\'s image (GIF, PNG or JPEG) and returns it as a file. Takes the emoji ID from List Custom Emojis, Search Custom Emojis or Get Custom Emoji By Name.',
+ idempotent: true,
+ },
+ props: {
+ emojiId: Property.ShortText({
+ displayName: 'Emoji ID',
+ description: 'Custom emoji ID (26 characters). Use List Custom Emojis, Search Custom Emojis or Get Custom Emoji By Name to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { emojiId } = context.propsValue;
+ const download = await mattermostClient.download({
+ auth: context.auth,
+ path: `/emoji/${encodeURIComponent(emojiId)}/image`,
+ });
+ const extension = download.contentType?.split('/')[1]?.split(';')[0] ?? 'png';
+ const fileName = download.fileName ?? `${emojiId}.${extension}`;
+ const file = await context.files.write({ fileName, data: download.data });
+ return { file, fileName, contentType: download.contentType, size: download.data.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emoji.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emoji.ts
new file mode 100644
index 00000000000..2c5c4d47fa0
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emoji.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateEmojiOutputSchema } from '../../../output-schemas';
+
+export const getEmojiAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_emoji',
+ outputSchema: mattermostCreateEmojiOutputSchema,
+ displayName: 'Get Custom Emoji',
+ description: 'Gets a custom emoji by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one custom emoji (ID, name, creator) by its ID. Use Get Custom Emoji By Name when only the name is known.',
+ idempotent: true,
+ },
+ props: {
+ emojiId: Property.ShortText({
+ displayName: 'Emoji ID',
+ description: 'Custom emoji ID (26 characters). Use List Custom Emojis, Search Custom Emojis or Get Custom Emoji By Name to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/emoji/${encodeURIComponent(context.propsValue.emojiId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emojis-by-names.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emojis-by-names.ts
new file mode 100644
index 00000000000..a035a8bee3a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/get-emojis-by-names.ts
@@ -0,0 +1,36 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetEmojisByNamesOutputSchema } from '../../../output-schemas';
+
+export const getEmojisByNamesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_emojis_by_names',
+ outputSchema: mattermostGetEmojisByNamesOutputSchema,
+ displayName: 'Get Custom Emojis By Names',
+ description: 'Gets several custom emoji by their names.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the custom emoji matching the given exact names (up to 200); names that match no custom emoji are left out. Needs server 9.2 or later.',
+ idempotent: true,
+ },
+ props: {
+ names: Property.Array({
+ displayName: 'Emoji Names',
+ description: 'Exact custom emoji names without colons, e.g. ["party_parrot"].',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const emojis = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/emoji/names',
+ body: context.propsValue.names,
+ });
+ return { emojis, count: emojis.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/list-emojis.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/list-emojis.ts
new file mode 100644
index 00000000000..a51d7a26159
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/list-emojis.ts
@@ -0,0 +1,48 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostGetEmojisByNamesOutputSchema } from '../../../output-schemas';
+
+export const listEmojisAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_emojis',
+ outputSchema: mattermostGetEmojisByNamesOutputSchema,
+ displayName: 'List Custom Emojis',
+ description: 'Lists the server\'s custom emoji.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a page of the server\'s custom emoji (ID, name, creator); built-in emoji are not included. Use Search Custom Emojis to find one by name fragment.',
+ idempotent: true,
+ },
+ props: {
+ sort: Property.StaticDropdown({
+ displayName: 'Sort',
+ description: '"name" to sort by emoji name. Defaults to no sorting.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [{ label: 'Name', value: 'name' }],
+ },
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { sort, page, perPage } = context.propsValue;
+ const emojis = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/emoji',
+ query: {
+ ...mattermostUtils.paging({ page, perPage }),
+ ...(sort ? { sort } : {}),
+ },
+ });
+ return { emojis, count: emojis.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/search-emojis.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/search-emojis.ts
new file mode 100644
index 00000000000..a77d641f8e3
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/emoji/search-emojis.ts
@@ -0,0 +1,44 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostGetEmojisByNamesOutputSchema } from '../../../output-schemas';
+
+export const searchEmojisAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_search_emojis',
+ outputSchema: mattermostGetEmojisByNamesOutputSchema,
+ displayName: 'Search Custom Emojis',
+ description: 'Searches custom emoji by name.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Finds custom emoji whose name contains the term (or starts with it, with Prefix Only set to "true"); returns at most 200. Built-in emoji are not included.',
+ idempotent: true,
+ },
+ props: {
+ term: Property.ShortText({
+ displayName: 'Term',
+ description: 'Text to match against emoji names.',
+ required: true,
+ }),
+ prefixOnly: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Prefix Only',
+ description: '"true" to match only names starting with the term. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { term, prefixOnly } = context.propsValue;
+ const emojis = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/emoji/search',
+ body: { term, prefix_only: mattermostUtils.parseBoolean({ value: prefixOnly }) },
+ });
+ return { emojis, count: emojis.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/files/download-file.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/files/download-file.ts
new file mode 100644
index 00000000000..2727bfc8be8
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/files/download-file.ts
@@ -0,0 +1,36 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostDownloadFileOutputSchema } from '../../../output-schemas';
+
+export const downloadFileAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_download_file',
+ outputSchema: mattermostDownloadFileOutputSchema,
+ displayName: 'Download File',
+ description: 'Downloads a file uploaded to Mattermost.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Downloads a file uploaded to Mattermost and returns it as a file. Needs read access to the file\'s channel. Use Get File Info for the name, size and type without downloading.',
+ idempotent: true,
+ },
+ props: {
+ fileId: Property.ShortText({
+ displayName: 'File ID',
+ description: 'File ID (26 characters). Use Upload File, Search Files or List Post Files to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { fileId } = context.propsValue;
+ const download = await mattermostClient.download({
+ auth: context.auth,
+ path: `/files/${encodeURIComponent(fileId)}`,
+ });
+ const fileName = download.fileName ?? fileId;
+ const file = await context.files.write({ fileName, data: download.data });
+ return { file, fileName, contentType: download.contentType, size: download.data.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-info.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-info.ts
new file mode 100644
index 00000000000..2d5e43f4e67
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-info.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetFileInfoOutputSchema } from '../../../output-schemas';
+
+export const getFileInfoAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_file_info',
+ outputSchema: mattermostGetFileInfoOutputSchema,
+ displayName: 'Get File Info',
+ description: 'Gets a file\'s name, size, type and post.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns a file\'s stored metadata (name, extension, size, MIME type, uploader, post and channel) without downloading it. Use Download File for the contents. Needs read access to the file\'s channel.',
+ idempotent: true,
+ },
+ props: {
+ fileId: Property.ShortText({
+ displayName: 'File ID',
+ description: 'File ID (26 characters). Use Upload File, Search Files or List Post Files to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/files/${encodeURIComponent(context.propsValue.fileId)}/info`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-preview.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-preview.ts
new file mode 100644
index 00000000000..d1f2f1870b3
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-preview.ts
@@ -0,0 +1,36 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostDownloadFileOutputSchema } from '../../../output-schemas';
+
+export const getFilePreviewAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_file_preview',
+ outputSchema: mattermostDownloadFileOutputSchema,
+ displayName: 'Get File Preview',
+ description: 'Downloads a preview of an image file.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Downloads the larger JPEG preview Mattermost made for an image file. Only image files have one; others fail. Needs read access to the file\'s channel.',
+ idempotent: true,
+ },
+ props: {
+ fileId: Property.ShortText({
+ displayName: 'File ID',
+ description: 'File ID (26 characters). Use Upload File, Search Files or List Post Files to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { fileId } = context.propsValue;
+ const download = await mattermostClient.download({
+ auth: context.auth,
+ path: `/files/${encodeURIComponent(fileId)}/preview`,
+ });
+ const fileName = download.fileName ?? `${fileId}-preview.jpg`;
+ const file = await context.files.write({ fileName, data: download.data });
+ return { file, fileName, contentType: download.contentType, size: download.data.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-public-link.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-public-link.ts
new file mode 100644
index 00000000000..9da322d1c5d
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-public-link.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetFilePublicLinkOutputSchema } from '../../../output-schemas';
+
+export const getFilePublicLinkAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_file_public_link',
+ outputSchema: mattermostGetFilePublicLinkOutputSchema,
+ displayName: 'Get File Public Link',
+ description: 'Gets a link that opens a file without signing in.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns a public link anyone can open without a Mattermost account. Needs public file links enabled on the server, and the file must already be attached to a post. Needs read access to the file\'s channel.',
+ idempotent: true,
+ },
+ props: {
+ fileId: Property.ShortText({
+ displayName: 'File ID',
+ description: 'File ID (26 characters). Use Upload File, Search Files or List Post Files to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/files/${encodeURIComponent(context.propsValue.fileId)}/link`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-thumbnail.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-thumbnail.ts
new file mode 100644
index 00000000000..014206668dc
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/files/get-file-thumbnail.ts
@@ -0,0 +1,36 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostDownloadFileOutputSchema } from '../../../output-schemas';
+
+export const getFileThumbnailAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_file_thumbnail',
+ outputSchema: mattermostDownloadFileOutputSchema,
+ displayName: 'Get File Thumbnail',
+ description: 'Downloads a small thumbnail of an image file.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Downloads the small JPEG thumbnail Mattermost made for an image file. Only image files have one; others fail. Needs read access to the file\'s channel.',
+ idempotent: true,
+ },
+ props: {
+ fileId: Property.ShortText({
+ displayName: 'File ID',
+ description: 'File ID (26 characters). Use Upload File, Search Files or List Post Files to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { fileId } = context.propsValue;
+ const download = await mattermostClient.download({
+ auth: context.auth,
+ path: `/files/${encodeURIComponent(fileId)}/thumbnail`,
+ });
+ const fileName = download.fileName ?? `${fileId}-thumbnail.jpg`;
+ const file = await context.files.write({ fileName, data: download.data });
+ return { file, fileName, contentType: download.contentType, size: download.data.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/files/search-files.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/files/search-files.ts
new file mode 100644
index 00000000000..76b80c703f5
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/files/search-files.ts
@@ -0,0 +1,56 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostSearchFilesOutputSchema } from '../../../output-schemas';
+
+export const searchFilesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_search_files',
+ outputSchema: mattermostSearchFilesOutputSchema,
+ displayName: 'Search Files',
+ description: 'Searches files by name, extension or content.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Searches files posted in one team, or in all of the connected user\'s teams when Team ID is empty, by name, extension and (when content extraction is on) content. Terms accept "from:username", "in:channel-name" and "ext:pdf". Returns file IDs for Download File and Get File Info.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({
+ required: false,
+ description: 'Team ID (26 characters) to search in. Leave empty to search all of the connected user\'s teams. Use List Teams or Get Team By Name to find it.',
+ }),
+ terms: Property.ShortText({
+ displayName: 'Terms',
+ description: 'Search terms, e.g. "report ext:pdf from:alice in:town-square".',
+ required: true,
+ }),
+ isOrSearch: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Match Any Term',
+ description: '"true" to match files with any of the terms instead of all of them. Defaults to "false".',
+ }),
+ includeDeletedChannels: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Archived Channels',
+ description: '"true" to also search files in archived channels. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { teamId, terms, isOrSearch, includeDeletedChannels } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: teamId ? `/teams/${encodeURIComponent(teamId)}/files/search` : '/files/search',
+ body: {
+ terms,
+ is_or_search: mattermostUtils.parseBoolean({ value: isOrSearch }) ?? false,
+ include_deleted_channels: mattermostUtils.parseBoolean({ value: includeDeletedChannels }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/files/upload-file.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/files/upload-file.ts
new file mode 100644
index 00000000000..1c791985b5a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/files/upload-file.ts
@@ -0,0 +1,46 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUploadFileOutputSchema } from '../../../output-schemas';
+
+export const uploadFileAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_upload_file',
+ outputSchema: mattermostUploadFileOutputSchema,
+ displayName: 'Upload File',
+ description: 'Uploads a file to a channel so it can be attached to a post.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Uploads a file into a channel and returns its file ID; the file stays hidden until a post attaches it, so pass the ID to Create Post (File IDs) or Create Bookmark. Not idempotent: each call stores a new file.',
+ idempotent: false,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ file: Property.File({
+ displayName: 'File',
+ description: 'File to upload.',
+ required: true,
+ }),
+ fileName: Property.ShortText({
+ displayName: 'File Name',
+ description: 'Name to store the file under, with extension. Defaults to the file\'s own name.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { channelId, file, fileName } = context.propsValue;
+ const form = new FormData();
+ form.append('channel_id', channelId);
+ form.append('files', new Blob([new Uint8Array(file.data)]), fileName ?? file.filename);
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/files',
+ body: form,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/index.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/index.ts
new file mode 100644
index 00000000000..d7b8f244c35
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/index.ts
@@ -0,0 +1,361 @@
+import { assignBotAction } from './bots/assign-bot';
+import { convertBotToUserAction } from './bots/convert-bot-to-user';
+import { convertUserToBotAction } from './bots/convert-user-to-bot';
+import { createBotAction } from './bots/create-bot';
+import { disableBotAction } from './bots/disable-bot';
+import { enableBotAction } from './bots/enable-bot';
+import { getBotAction } from './bots/get-bot';
+import { listBotsAction } from './bots/list-bots';
+import { updateBotAction } from './bots/update-bot';
+import { addChannelMemberAction } from './channels/add-channel-member';
+import { archiveChannelAction } from './channels/archive-channel';
+import { convertGroupMessageToChannelAction } from './channels/convert-group-message-to-channel';
+import { createChannelCategoryAction } from './channels/create-channel-category';
+import { createChannelAction } from './channels/create-channel';
+import { createDirectChannelAction } from './channels/create-direct-channel';
+import { createGroupMessageAction } from './channels/create-group-message';
+import { deleteChannelCategoryAction } from './channels/delete-channel-category';
+import { getChannelByNameAction } from './channels/get-channel-by-name';
+import { getChannelCategoryOrderAction } from './channels/get-channel-category-order';
+import { getChannelCategoryAction } from './channels/get-channel-category';
+import { getChannelMemberCountsAction } from './channels/get-channel-member-counts';
+import { getChannelMemberAction } from './channels/get-channel-member';
+import { getChannelMembersByIdsAction } from './channels/get-channel-members-by-ids';
+import { getChannelStatsAction } from './channels/get-channel-stats';
+import { getChannelUnreadAction } from './channels/get-channel-unread';
+import { getChannelAction } from './channels/get-channel';
+import { getChannelsByIdsAction } from './channels/get-channels-by-ids';
+import { listAllChannelsAction } from './channels/list-all-channels';
+import { listArchivedChannelsAction } from './channels/list-archived-channels';
+import { listChannelCategoriesAction } from './channels/list-channel-categories';
+import { listChannelMembersAction } from './channels/list-channel-members';
+import { listChannelTimezonesAction } from './channels/list-channel-timezones';
+import { listGroupChannelCommonTeamsAction } from './channels/list-group-channel-common-teams';
+import { listPinnedPostsAction } from './channels/list-pinned-posts';
+import { listPrivateChannelsAction } from './channels/list-private-channels';
+import { listPublicChannelsAction } from './channels/list-public-channels';
+import { listUserChannelsAction } from './channels/list-user-channels';
+import { listUserTeamChannelMembershipsAction } from './channels/list-user-team-channel-memberships';
+import { listUserTeamChannelsAction } from './channels/list-user-team-channels';
+import { markChannelsReadAction } from './channels/mark-channels-read';
+import { moveChannelAction } from './channels/move-channel';
+import { patchChannelAction } from './channels/patch-channel';
+import { removeChannelMemberAction } from './channels/remove-channel-member';
+import { restoreChannelAction } from './channels/restore-channel';
+import { searchAllChannelsAction } from './channels/search-all-channels';
+import { searchChannelsAction } from './channels/search-channels';
+import { searchGroupChannelsAction } from './channels/search-group-channels';
+import { setChannelMembersAction } from './channels/set-channel-members';
+import { updateChannelCategoriesAction } from './channels/update-channel-categories';
+import { updateChannelCategoryOrderAction } from './channels/update-channel-category-order';
+import { updateChannelCategoryAction } from './channels/update-channel-category';
+import { updateChannelMemberRolesAction } from './channels/update-channel-member-roles';
+import { updateChannelNotifyPropsAction } from './channels/update-channel-notify-props';
+import { updateChannelPrivacyAction } from './channels/update-channel-privacy';
+import { createCommandAction } from './commands/create-command';
+import { deleteCommandAction } from './commands/delete-command';
+import { executeCommandAction } from './commands/execute-command';
+import { getCommandAction } from './commands/get-command';
+import { listCommandsAction } from './commands/list-commands';
+import { moveCommandAction } from './commands/move-command';
+import { regenerateCommandTokenAction } from './commands/regenerate-command-token';
+import { updateCommandAction } from './commands/update-command';
+import { createEmojiAction } from './emoji/create-emoji';
+import { deleteEmojiAction } from './emoji/delete-emoji';
+import { getEmojiByNameAction } from './emoji/get-emoji-by-name';
+import { getEmojiImageAction } from './emoji/get-emoji-image';
+import { getEmojiAction } from './emoji/get-emoji';
+import { getEmojisByNamesAction } from './emoji/get-emojis-by-names';
+import { listEmojisAction } from './emoji/list-emojis';
+import { searchEmojisAction } from './emoji/search-emojis';
+import { downloadFileAction } from './files/download-file';
+import { getFileInfoAction } from './files/get-file-info';
+import { getFilePreviewAction } from './files/get-file-preview';
+import { getFilePublicLinkAction } from './files/get-file-public-link';
+import { getFileThumbnailAction } from './files/get-file-thumbnail';
+import { searchFilesAction } from './files/search-files';
+import { uploadFileAction } from './files/upload-file';
+import { createPostAction } from './posts/create-post';
+import { deletePostAction } from './posts/delete-post';
+import { getPostEditHistoryAction } from './posts/get-post-edit-history';
+import { getPostInfoAction } from './posts/get-post-info';
+import { getPostThreadAction } from './posts/get-post-thread';
+import { getPostAction } from './posts/get-post';
+import { getPostsByIdsAction } from './posts/get-posts-by-ids';
+import { listChannelPostsAction } from './posts/list-channel-posts';
+import { listFlaggedPostsAction } from './posts/list-flagged-posts';
+import { listPostFilesAction } from './posts/list-post-files';
+import { listUnreadPostsAction } from './posts/list-unread-posts';
+import { markPostUnreadAction } from './posts/mark-post-unread';
+import { patchPostAction } from './posts/patch-post';
+import { pinPostAction } from './posts/pin-post';
+import { restorePostVersionAction } from './posts/restore-post-version';
+import { searchPostsAction } from './posts/search-posts';
+import { sendEphemeralPostAction } from './posts/send-ephemeral-post';
+import { setPostReminderAction } from './posts/set-post-reminder';
+import { unpinPostAction } from './posts/unpin-post';
+import { deletePreferencesAction } from './preferences/delete-preferences';
+import { getPreferenceAction } from './preferences/get-preference';
+import { listPreferencesByCategoryAction } from './preferences/list-preferences-by-category';
+import { listPreferencesAction } from './preferences/list-preferences';
+import { savePreferencesAction } from './preferences/save-preferences';
+import { addReactionAction } from './reactions/add-reaction';
+import { listReactionsAction } from './reactions/list-reactions';
+import { removeReactionAction } from './reactions/remove-reaction';
+import { countUserReportsAction } from './reports/count-user-reports';
+import { listUserReportsAction } from './reports/list-user-reports';
+import { getRoleByNameAction } from './roles/get-role-by-name';
+import { getRoleAction } from './roles/get-role';
+import { getRolesByNamesAction } from './roles/get-roles-by-names';
+import { listRolesAction } from './roles/list-roles';
+import { patchRoleAction } from './roles/patch-role';
+import { clearCustomStatusAction } from './status/clear-custom-status';
+import { getUserStatusAction } from './status/get-user-status';
+import { getUserStatusesAction } from './status/get-user-statuses';
+import { removeRecentCustomStatusAction } from './status/remove-recent-custom-status';
+import { setCustomStatusAction } from './status/set-custom-status';
+import { updateUserStatusAction } from './status/update-user-status';
+import { addTeamMemberAction } from './teams/add-team-member';
+import { addTeamMembersAction } from './teams/add-team-members';
+import { archiveTeamAction } from './teams/archive-team';
+import { checkTeamExistsAction } from './teams/check-team-exists';
+import { createTeamAction } from './teams/create-team';
+import { getTeamByNameAction } from './teams/get-team-by-name';
+import { getTeamIconAction } from './teams/get-team-icon';
+import { getTeamInviteInfoAction } from './teams/get-team-invite-info';
+import { getTeamMemberAction } from './teams/get-team-member';
+import { getTeamMembersByIdsAction } from './teams/get-team-members-by-ids';
+import { getTeamStatsAction } from './teams/get-team-stats';
+import { getTeamUnreadAction } from './teams/get-team-unread';
+import { getTeamAction } from './teams/get-team';
+import { invalidateEmailInvitesAction } from './teams/invalidate-email-invites';
+import { inviteUsersByEmailAction } from './teams/invite-users-by-email';
+import { joinTeamByInviteAction } from './teams/join-team-by-invite';
+import { listTeamMembersAction } from './teams/list-team-members';
+import { listTeamUnreadsAction } from './teams/list-team-unreads';
+import { listTeamsAction } from './teams/list-teams';
+import { listUserTeamMembershipsAction } from './teams/list-user-team-memberships';
+import { listUserTeamsAction } from './teams/list-user-teams';
+import { patchTeamAction } from './teams/patch-team';
+import { regenerateTeamInviteIdAction } from './teams/regenerate-team-invite-id';
+import { removeTeamIconAction } from './teams/remove-team-icon';
+import { removeTeamMemberAction } from './teams/remove-team-member';
+import { restoreTeamAction } from './teams/restore-team';
+import { searchTeamsAction } from './teams/search-teams';
+import { setTeamIconAction } from './teams/set-team-icon';
+import { updateTeamMemberRolesAction } from './teams/update-team-member-roles';
+import { updateTeamPrivacyAction } from './teams/update-team-privacy';
+import { followThreadAction } from './threads/follow-thread';
+import { getThreadAction } from './threads/get-thread';
+import { listThreadsAction } from './threads/list-threads';
+import { markAllThreadsReadAction } from './threads/mark-all-threads-read';
+import { markThreadReadAction } from './threads/mark-thread-read';
+import { markThreadUnreadAction } from './threads/mark-thread-unread';
+import { unfollowThreadAction } from './threads/unfollow-thread';
+import { createUserAction } from './users/create-user';
+import { deleteDraftAction } from './users/delete-draft';
+import { deleteThreadDraftAction } from './users/delete-thread-draft';
+import { getFilteredUserStatsAction } from './users/get-filtered-user-stats';
+import { getServerLimitsAction } from './users/get-server-limits';
+import { getUserByEmailAction } from './users/get-user-by-email';
+import { getUserByUsernameAction } from './users/get-user-by-username';
+import { getUserDefaultImageAction } from './users/get-user-default-image';
+import { getUserImageAction } from './users/get-user-image';
+import { getUserStatsAction } from './users/get-user-stats';
+import { getUserAction } from './users/get-user';
+import { getUsersByIdsAction } from './users/get-users-by-ids';
+import { getUsersByUsernamesAction } from './users/get-users-by-usernames';
+import { listDraftsAction } from './users/list-drafts';
+import { listGroupChannelUsersAction } from './users/list-group-channel-users';
+import { listKnownUsersAction } from './users/list-known-users';
+import { listUserChannelMembershipsAction } from './users/list-user-channel-memberships';
+import { listUsersAction } from './users/list-users';
+import { patchUserAction } from './users/patch-user';
+import { resetUserImageAction } from './users/reset-user-image';
+import { searchUsersAction } from './users/search-users';
+import { setUserActiveAction } from './users/set-user-active';
+import { setUserImageAction } from './users/set-user-image';
+import { updateUserRolesAction } from './users/update-user-roles';
+import { upsertDraftAction } from './users/upsert-draft';
+
+export const mattermostAiActions = [
+ assignBotAction,
+ convertBotToUserAction,
+ convertUserToBotAction,
+ createBotAction,
+ disableBotAction,
+ enableBotAction,
+ getBotAction,
+ listBotsAction,
+ updateBotAction,
+ addChannelMemberAction,
+ archiveChannelAction,
+ convertGroupMessageToChannelAction,
+ createChannelCategoryAction,
+ createChannelAction,
+ createDirectChannelAction,
+ createGroupMessageAction,
+ deleteChannelCategoryAction,
+ getChannelByNameAction,
+ getChannelCategoryOrderAction,
+ getChannelCategoryAction,
+ getChannelMemberCountsAction,
+ getChannelMemberAction,
+ getChannelMembersByIdsAction,
+ getChannelStatsAction,
+ getChannelUnreadAction,
+ getChannelAction,
+ getChannelsByIdsAction,
+ listAllChannelsAction,
+ listArchivedChannelsAction,
+ listChannelCategoriesAction,
+ listChannelMembersAction,
+ listChannelTimezonesAction,
+ listGroupChannelCommonTeamsAction,
+ listPinnedPostsAction,
+ listPrivateChannelsAction,
+ listPublicChannelsAction,
+ listUserChannelsAction,
+ listUserTeamChannelMembershipsAction,
+ listUserTeamChannelsAction,
+ markChannelsReadAction,
+ moveChannelAction,
+ patchChannelAction,
+ removeChannelMemberAction,
+ restoreChannelAction,
+ searchAllChannelsAction,
+ searchChannelsAction,
+ searchGroupChannelsAction,
+ setChannelMembersAction,
+ updateChannelCategoriesAction,
+ updateChannelCategoryOrderAction,
+ updateChannelCategoryAction,
+ updateChannelMemberRolesAction,
+ updateChannelNotifyPropsAction,
+ updateChannelPrivacyAction,
+ createCommandAction,
+ deleteCommandAction,
+ executeCommandAction,
+ getCommandAction,
+ listCommandsAction,
+ moveCommandAction,
+ regenerateCommandTokenAction,
+ updateCommandAction,
+ createEmojiAction,
+ deleteEmojiAction,
+ getEmojiByNameAction,
+ getEmojiImageAction,
+ getEmojiAction,
+ getEmojisByNamesAction,
+ listEmojisAction,
+ searchEmojisAction,
+ downloadFileAction,
+ getFileInfoAction,
+ getFilePreviewAction,
+ getFilePublicLinkAction,
+ getFileThumbnailAction,
+ searchFilesAction,
+ uploadFileAction,
+ createPostAction,
+ deletePostAction,
+ getPostEditHistoryAction,
+ getPostInfoAction,
+ getPostThreadAction,
+ getPostAction,
+ getPostsByIdsAction,
+ listChannelPostsAction,
+ listFlaggedPostsAction,
+ listPostFilesAction,
+ listUnreadPostsAction,
+ markPostUnreadAction,
+ patchPostAction,
+ pinPostAction,
+ restorePostVersionAction,
+ searchPostsAction,
+ sendEphemeralPostAction,
+ setPostReminderAction,
+ unpinPostAction,
+ deletePreferencesAction,
+ getPreferenceAction,
+ listPreferencesByCategoryAction,
+ listPreferencesAction,
+ savePreferencesAction,
+ addReactionAction,
+ listReactionsAction,
+ removeReactionAction,
+ countUserReportsAction,
+ listUserReportsAction,
+ getRoleByNameAction,
+ getRoleAction,
+ getRolesByNamesAction,
+ listRolesAction,
+ patchRoleAction,
+ clearCustomStatusAction,
+ getUserStatusAction,
+ getUserStatusesAction,
+ removeRecentCustomStatusAction,
+ setCustomStatusAction,
+ updateUserStatusAction,
+ addTeamMemberAction,
+ addTeamMembersAction,
+ archiveTeamAction,
+ checkTeamExistsAction,
+ createTeamAction,
+ getTeamByNameAction,
+ getTeamIconAction,
+ getTeamInviteInfoAction,
+ getTeamMemberAction,
+ getTeamMembersByIdsAction,
+ getTeamStatsAction,
+ getTeamUnreadAction,
+ getTeamAction,
+ invalidateEmailInvitesAction,
+ inviteUsersByEmailAction,
+ joinTeamByInviteAction,
+ listTeamMembersAction,
+ listTeamUnreadsAction,
+ listTeamsAction,
+ listUserTeamMembershipsAction,
+ listUserTeamsAction,
+ patchTeamAction,
+ regenerateTeamInviteIdAction,
+ removeTeamIconAction,
+ removeTeamMemberAction,
+ restoreTeamAction,
+ searchTeamsAction,
+ setTeamIconAction,
+ updateTeamMemberRolesAction,
+ updateTeamPrivacyAction,
+ followThreadAction,
+ getThreadAction,
+ listThreadsAction,
+ markAllThreadsReadAction,
+ markThreadReadAction,
+ markThreadUnreadAction,
+ unfollowThreadAction,
+ createUserAction,
+ deleteDraftAction,
+ deleteThreadDraftAction,
+ getFilteredUserStatsAction,
+ getServerLimitsAction,
+ getUserByEmailAction,
+ getUserByUsernameAction,
+ getUserDefaultImageAction,
+ getUserImageAction,
+ getUserStatsAction,
+ getUserAction,
+ getUsersByIdsAction,
+ getUsersByUsernamesAction,
+ listDraftsAction,
+ listGroupChannelUsersAction,
+ listKnownUsersAction,
+ listUserChannelMembershipsAction,
+ listUsersAction,
+ patchUserAction,
+ resetUserImageAction,
+ searchUsersAction,
+ setUserActiveAction,
+ setUserImageAction,
+ updateUserRolesAction,
+ upsertDraftAction,
+];
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/create-post.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/create-post.ts
new file mode 100644
index 00000000000..4de26f97f82
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/create-post.ts
@@ -0,0 +1,53 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreatePostOutputSchema } from '../../../output-schemas';
+
+export const createPostAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_create_post',
+ outputSchema: mattermostCreatePostOutputSchema,
+ displayName: 'Create Post',
+ description: 'Posts a message to a channel or replies in a thread.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Posts a message to a channel, or replies in a thread when Root ID is set. Attach files by passing File IDs from Upload File. Not idempotent: each call creates a separate post.',
+ idempotent: false,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ message: Property.LongText({
+ displayName: 'Message',
+ description: 'Message text; Markdown is supported.',
+ required: true,
+ }),
+ rootId: Property.ShortText({
+ displayName: 'Root ID',
+ description: 'ID of the thread root post to reply to. Leave empty to start a new post.',
+ required: false,
+ }),
+ fileIds: Property.Array({
+ displayName: 'File IDs',
+ description: 'Up to 10 file IDs from Upload File, uploaded to the same channel.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { channelId, message, rootId, fileIds } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/posts',
+ body: {
+ channel_id: channelId,
+ message,
+ root_id: rootId,
+ file_ids: fileIds && fileIds.length > 0 ? fileIds : undefined,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/delete-post.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/delete-post.ts
new file mode 100644
index 00000000000..3209626c6be
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/delete-post.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const deletePostAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_delete_post',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Delete Post',
+ description: 'Deletes a post.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Deletes a post; deleting a thread root also deletes its replies. Users can no longer see or restore it. Only the author or a user with permission to delete others\' posts can do this.',
+ idempotent: false,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/posts/${encodeURIComponent(context.propsValue.postId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post-edit-history.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post-edit-history.ts
new file mode 100644
index 00000000000..114a229d8a9
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post-edit-history.ts
@@ -0,0 +1,32 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetPostEditHistoryOutputSchema } from '../../../output-schemas';
+
+export const getPostEditHistoryAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_post_edit_history',
+ outputSchema: mattermostGetPostEditHistoryOutputSchema,
+ displayName: 'Get Post Edit History',
+ description: 'Lists the previous versions of an edited post.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the past versions of a post the connected user wrote, each with its own ID to pass to Restore Post Version. Only the author can read it.',
+ idempotent: true,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ },
+ async run(context) {
+ const versions = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/posts/${encodeURIComponent(context.propsValue.postId)}/edit_history`,
+ });
+ return { versions, count: versions.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post-info.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post-info.ts
new file mode 100644
index 00000000000..c7cc7247583
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post-info.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetPostInfoOutputSchema } from '../../../output-schemas';
+
+export const getPostInfoAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_post_info',
+ outputSchema: mattermostGetPostInfoOutputSchema,
+ displayName: 'Get Post Info',
+ description: 'Gets the channel and team a post belongs to.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the channel and team a post belongs to (IDs, types, display names) and whether the connected user has joined them, without returning the post itself. Use Get Post for the message.',
+ idempotent: true,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/posts/${encodeURIComponent(context.propsValue.postId)}/info`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post-thread.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post-thread.ts
new file mode 100644
index 00000000000..01159ec4dfb
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post-thread.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetPostThreadOutputSchema } from '../../../output-schemas';
+
+export const getPostThreadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_post_thread',
+ outputSchema: mattermostGetPostThreadOutputSchema,
+ displayName: 'Get Post Thread',
+ description: 'Gets a post together with every post in its thread.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the root post and all replies of the thread that contains the given post (root or any reply). Use Get Post for a single post.',
+ idempotent: true,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/posts/${encodeURIComponent(context.propsValue.postId)}/thread`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post.ts
new file mode 100644
index 00000000000..1075f922c01
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-post.ts
@@ -0,0 +1,40 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostCreatePostOutputSchema } from '../../../output-schemas';
+
+export const getPostAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_post',
+ outputSchema: mattermostCreatePostOutputSchema,
+ displayName: 'Get Post',
+ description: 'Gets a single post by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one post with its message, author, channel, thread root and metadata. Use Get Post Thread for the whole conversation around it.',
+ idempotent: true,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ includeDeleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Deleted',
+ description: '"true" to return the post even if it was deleted; needs system admin permission. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { postId, includeDeleted } = context.propsValue;
+ const deleted = mattermostUtils.parseBoolean({ value: includeDeleted });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/posts/${encodeURIComponent(postId)}`,
+ query: deleted !== undefined ? { include_deleted: String(deleted) } : undefined,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-posts-by-ids.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-posts-by-ids.ts
new file mode 100644
index 00000000000..fb734e5b6c4
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/get-posts-by-ids.ts
@@ -0,0 +1,36 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetPostsByIdsOutputSchema } from '../../../output-schemas';
+
+export const getPostsByIdsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_posts_by_ids',
+ outputSchema: mattermostGetPostsByIdsOutputSchema,
+ displayName: 'Get Posts By IDs',
+ description: 'Gets several posts at once by their IDs.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the posts with the given IDs in one call; IDs the connected user cannot read are left out. Use Get Post for a single post.',
+ idempotent: true,
+ },
+ props: {
+ postIds: Property.Array({
+ displayName: 'Post IDs',
+ description: 'Post IDs (26 characters each). Use List Channel Posts or Search Posts to find them.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const posts = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/posts/ids',
+ body: context.propsValue.postIds,
+ });
+ return { posts, count: posts.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-channel-posts.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-channel-posts.ts
new file mode 100644
index 00000000000..3635f3d761a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-channel-posts.ts
@@ -0,0 +1,61 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListChannelPostsOutputSchema } from '../../../output-schemas';
+
+export const listChannelPostsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_channel_posts',
+ outputSchema: mattermostListChannelPostsOutputSchema,
+ displayName: 'List Channel Posts',
+ description: 'Lists the posts in a channel, newest first.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a page of posts in a channel, newest first, or with Since every post changed after that time (up to 1000). Since cannot be combined with Before, After, Page or Per Page. Use Search Posts to find posts by text.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ since: Property.Number({
+ displayName: 'Since',
+ description: 'Only posts created or changed after this time, in milliseconds since epoch.',
+ required: false,
+ }),
+ before: Property.ShortText({
+ displayName: 'Before Post ID',
+ description: 'Only posts that came before this post ID.',
+ required: false,
+ }),
+ after: Property.ShortText({
+ displayName: 'After Post ID',
+ description: 'Only posts that came after this post ID.',
+ required: false,
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { channelId, since, before, after, page, perPage } = context.propsValue;
+ if (since !== undefined && (before || after || page !== undefined || perPage !== undefined)) {
+ throw new Error('Since cannot be combined with Before Post ID, After Post ID, Page or Per Page.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/channels/${encodeURIComponent(channelId)}/posts`,
+ query:
+ since !== undefined
+ ? { since: String(since) }
+ : {
+ ...mattermostUtils.paging({ page, perPage }),
+ ...(before ? { before } : {}),
+ ...(after ? { after } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-flagged-posts.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-flagged-posts.ts
new file mode 100644
index 00000000000..076b8d9f64f
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-flagged-posts.ts
@@ -0,0 +1,49 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListFlaggedPostsOutputSchema } from '../../../output-schemas';
+
+export const listFlaggedPostsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_flagged_posts',
+ outputSchema: mattermostListFlaggedPostsOutputSchema,
+ displayName: 'List Saved Posts',
+ description: 'Lists the posts a user has saved (flagged).',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the posts a user has saved (flagged), optionally limited to one team or channel; pass "me" for the connected account. Only posts in channels the user belongs to are returned.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({
+ required: false,
+ description: 'Only saved posts in this team (26 characters). Use List Teams or Get Team By Name to find it.',
+ }),
+ channelId: mattermostAiProps.channelId({
+ required: false,
+ description:
+ 'Only saved posts in this channel (26 characters). Use Get Channel By Name, Search Channels or List User Channels to find it.',
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { userId, teamId, channelId, page, perPage } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/posts/flagged`,
+ query: {
+ ...mattermostUtils.paging({ page, perPage }),
+ ...(teamId ? { team_id: teamId } : {}),
+ ...(channelId ? { channel_id: channelId } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-post-files.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-post-files.ts
new file mode 100644
index 00000000000..1a7db015e1a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-post-files.ts
@@ -0,0 +1,41 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListPostFilesOutputSchema } from '../../../output-schemas';
+
+export const listPostFilesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_post_files',
+ outputSchema: mattermostListPostFilesOutputSchema,
+ displayName: 'List Post Files',
+ description: 'Lists the files attached to a post.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the info (ID, name, extension, size, MIME type) of every file attached to a post. Pass a file ID to the file actions to download or link it.',
+ idempotent: true,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ includeDeleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Deleted',
+ description: '"true" to include files of a deleted post; needs system admin permission. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { postId, includeDeleted } = context.propsValue;
+ const deleted = mattermostUtils.parseBoolean({ value: includeDeleted });
+ const files = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/posts/${encodeURIComponent(postId)}/files/info`,
+ query: deleted !== undefined ? { include_deleted: String(deleted) } : undefined,
+ });
+ return { files, count: files.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-unread-posts.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-unread-posts.ts
new file mode 100644
index 00000000000..85b297a186a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/list-unread-posts.ts
@@ -0,0 +1,47 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListChannelPostsOutputSchema } from '../../../output-schemas';
+
+export const listUnreadPostsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_unread_posts',
+ outputSchema: mattermostListChannelPostsOutputSchema,
+ displayName: 'List Unread Posts',
+ description: 'Lists the posts around the oldest unread post in a channel.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the oldest unread post of a user in a channel plus the posts around it, newest first; pass "me" for the connected account. Use List Channel Posts for the latest posts regardless of read state.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ channelId: mattermostAiProps.channelId({ required: true }),
+ limitBefore: Property.Number({
+ displayName: 'Limit Before',
+ description: 'Number of read posts before the oldest unread post, up to 200. Defaults to 60.',
+ required: false,
+ }),
+ limitAfter: Property.Number({
+ displayName: 'Limit After',
+ description: 'Number of posts from the oldest unread post onward, up to 200. Defaults to 60.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { userId, channelId, limitBefore, limitAfter } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/channels/${encodeURIComponent(channelId)}/posts/unread`,
+ query: {
+ ...(limitBefore !== undefined ? { limit_before: String(limitBefore) } : {}),
+ ...(limitAfter !== undefined ? { limit_after: String(limitAfter) } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/mark-post-unread.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/mark-post-unread.ts
new file mode 100644
index 00000000000..9627bb6f3c4
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/mark-post-unread.ts
@@ -0,0 +1,33 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostMarkPostUnreadOutputSchema } from '../../../output-schemas';
+
+export const markPostUnreadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_mark_post_unread',
+ outputSchema: mattermostMarkPostUnreadOutputSchema,
+ displayName: 'Mark Post Unread',
+ description: 'Marks a channel as unread from a given post onward.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Marks the post\'s channel as unread for a user starting at that post; pass "me" for the connected account. To mark a reply unread in a followed thread use Mark Thread Unread.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ postId: mattermostAiProps.postId({ required: true }),
+ },
+ async run(context) {
+ const { userId, postId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/users/${encodeURIComponent(userId)}/posts/${encodeURIComponent(postId)}/set_unread`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/patch-post.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/patch-post.ts
new file mode 100644
index 00000000000..9ddf32d9d1a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/patch-post.ts
@@ -0,0 +1,58 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostPatchPostOutputSchema } from '../../../output-schemas';
+
+export const patchPostAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_patch_post',
+ outputSchema: mattermostPatchPostOutputSchema,
+ displayName: 'Update Post',
+ description: 'Edits a post, changing only the fields you set.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Edits a post\'s message, pinned state or attached files; fields left empty stay as they are. File IDs replace the attachment list. Set at least one field.',
+ idempotent: true,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ message: Property.LongText({
+ displayName: 'Message',
+ description: 'New message text; Markdown is supported.',
+ required: false,
+ }),
+ isPinned: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Is Pinned',
+ description: '"true" to pin the post to its channel, "false" to unpin it.',
+ }),
+ fileIds: Property.Array({
+ displayName: 'File IDs',
+ description: 'Replaces the attached files with these file IDs from Upload File.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { postId, message, isPinned, fileIds } = context.propsValue;
+ const pinned = mattermostUtils.parseBoolean({ value: isPinned });
+ const body = {
+ ...(message !== undefined ? { message } : {}),
+ ...(pinned !== undefined ? { is_pinned: pinned } : {}),
+ ...(fileIds && fileIds.length > 0 ? { file_ids: fileIds } : {}),
+ };
+ if (Object.keys(body).length === 0) {
+ throw new Error('Set at least one of Message, Is Pinned or File IDs.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/posts/${encodeURIComponent(postId)}/patch`,
+ body,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/pin-post.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/pin-post.ts
new file mode 100644
index 00000000000..460ff341211
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/pin-post.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const pinPostAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_pin_post',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Pin Post',
+ description: 'Pins a post to its channel.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ "Pins a post to its channel so it shows in the channel's pinned list. Pinning an already pinned post keeps it pinned. Undo with Unpin Post.",
+ idempotent: true,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/posts/${encodeURIComponent(context.propsValue.postId)}/pin`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/restore-post-version.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/restore-post-version.ts
new file mode 100644
index 00000000000..292e2670d5e
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/restore-post-version.ts
@@ -0,0 +1,37 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostPatchPostOutputSchema } from '../../../output-schemas';
+
+export const restorePostVersionAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_restore_post_version',
+ outputSchema: mattermostPatchPostOutputSchema,
+ displayName: 'Restore Post Version',
+ description: 'Restores an edited post to one of its earlier versions.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Restores a post the connected user wrote to an earlier version from Get Post Edit History; the current text becomes a new history entry. Only the author can do this.',
+ idempotent: false,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ versionId: Property.ShortText({
+ displayName: 'Version ID',
+ description: 'ID (26 characters) of the past version to restore. Use Get Post Edit History to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { postId, versionId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/posts/${encodeURIComponent(postId)}/restore/${encodeURIComponent(versionId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/search-posts.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/search-posts.ts
new file mode 100644
index 00000000000..f8b95617886
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/search-posts.ts
@@ -0,0 +1,71 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostSearchPostsOutputSchema } from '../../../output-schemas';
+
+export const searchPostsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_search_posts',
+ outputSchema: mattermostSearchPostsOutputSchema,
+ displayName: 'Search Posts',
+ description: 'Searches posts by text in one team or across all teams.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Searches the posts the connected user can see, in one team when Team ID is set, otherwise across all teams. Terms support Mattermost search modifiers such as from:username, in:channel-name, before:/after:/on: YYYY-MM-DD and "exact phrase".',
+ idempotent: true,
+ },
+ props: {
+ terms: Property.ShortText({
+ displayName: 'Terms',
+ description:
+ 'Search text. Add from:username for a user\'s posts or in:channel-name (the channel name, not its display name) for one channel.',
+ required: true,
+ }),
+ teamId: mattermostAiProps.teamId({
+ required: false,
+ description:
+ 'Team ID (26 characters) to search in. Leave empty to search all teams. Use List Teams or Get Team By Name to find it.',
+ }),
+ isOrSearch: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Match Any Term',
+ description: '"true" to match posts with any of the terms instead of all of them. Defaults to "false".',
+ }),
+ includeDeletedChannels: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Archived Channels',
+ description: '"true" to also search archived channels. Defaults to "false".',
+ }),
+ timeZoneOffset: Property.Number({
+ displayName: 'Time Zone Offset',
+ description: 'Offset from UTC in seconds, used for date modifiers such as on:. Defaults to 0.',
+ required: false,
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { terms, teamId, isOrSearch, includeDeletedChannels, timeZoneOffset, page, perPage } =
+ context.propsValue;
+ const archived = mattermostUtils.parseBoolean({ value: includeDeletedChannels });
+ const paging = mattermostUtils.paging({ page, perPage });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: teamId ? `/teams/${encodeURIComponent(teamId)}/posts/search` : '/posts/search',
+ body: {
+ terms,
+ is_or_search: mattermostUtils.parseBoolean({ value: isOrSearch }) ?? false,
+ page: Number(paging.page),
+ per_page: Number(paging.per_page),
+ ...(archived !== undefined ? { include_deleted_channels: archived } : {}),
+ ...(timeZoneOffset !== undefined ? { time_zone_offset: timeZoneOffset } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/send-ephemeral-post.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/send-ephemeral-post.ts
new file mode 100644
index 00000000000..eb797045d5c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/send-ephemeral-post.ts
@@ -0,0 +1,44 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostPatchPostOutputSchema } from '../../../output-schemas';
+
+export const sendEphemeralPostAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_send_ephemeral_post',
+ outputSchema: mattermostPatchPostOutputSchema,
+ displayName: 'Send Ephemeral Post',
+ description: 'Shows a temporary message in a channel to one user only.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Shows a temporary message in a channel that only the target user sees; it is not stored and disappears on reload. Use Create Post for a normal message. Needs system admin permission. Not idempotent: each call shows another message.',
+ idempotent: false,
+ },
+ props: {
+ userId: Property.ShortText({
+ displayName: 'Target User ID',
+ description:
+ 'ID (26 characters) of the user who will see the message. Use Get User By Username or Search Users to find it.',
+ required: true,
+ }),
+ channelId: mattermostAiProps.channelId({ required: true }),
+ message: Property.LongText({
+ displayName: 'Message',
+ description: 'Message text; Markdown is supported.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, channelId, message } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/posts/ephemeral',
+ body: { user_id: userId, post: { channel_id: channelId, message } },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/set-post-reminder.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/set-post-reminder.ts
new file mode 100644
index 00000000000..cf51bdb70e7
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/set-post-reminder.ts
@@ -0,0 +1,39 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const setPostReminderAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_set_post_reminder',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Set Post Reminder',
+ description: 'Sets a reminder about a post for a user.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Schedules a reminder about a post; at Target Time the system bot messages the user about it. Pass "me" for the connected account. Setting it again for the same post replaces the earlier time.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ postId: mattermostAiProps.postId({ required: true }),
+ targetTime: Property.Number({
+ displayName: 'Target Time',
+ description: 'When to send the reminder, in seconds since epoch (not milliseconds).',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, postId, targetTime } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/users/${encodeURIComponent(userId)}/posts/${encodeURIComponent(postId)}/reminder`,
+ body: { target_time: targetTime },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/posts/unpin-post.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/unpin-post.ts
new file mode 100644
index 00000000000..cadb0a2da18
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/posts/unpin-post.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const unpinPostAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_unpin_post',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Unpin Post',
+ description: 'Unpins a post from its channel.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ "Removes a post from its channel's pinned list; the post itself stays. Unpinning a post that is not pinned changes nothing. Undo with Pin Post.",
+ idempotent: true,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/posts/${encodeURIComponent(context.propsValue.postId)}/unpin`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/delete-preferences.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/delete-preferences.ts
new file mode 100644
index 00000000000..2f8276adfb6
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/delete-preferences.ts
@@ -0,0 +1,42 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const deletePreferencesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_delete_preferences',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Delete Preferences',
+ description: 'Deletes preferences of a user.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Deletes the listed preferences (matched by user_id, category and name) of a user, so they fall back to their defaults. Another user needs permission to edit other users. The entries to delete come from List Preferences.',
+ idempotent: false,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ preferences: Property.Json({
+ displayName: 'Preferences',
+ description:
+ 'JSON array of up to 100 preferences to delete, each {"user_id", "category", "name", "value"} as returned by List Preferences. user_id is the 26-character ID of the same user (not "me").',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, preferences } = context.propsValue;
+ if (!Array.isArray(preferences)) {
+ throw new Error('Preferences must be a JSON array of {user_id, category, name, value} objects.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/users/${encodeURIComponent(userId)}/preferences/delete`,
+ body: preferences,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/get-preference.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/get-preference.ts
new file mode 100644
index 00000000000..d1211b4bc43
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/get-preference.ts
@@ -0,0 +1,42 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetPreferenceOutputSchema } from '../../../output-schemas';
+
+export const getPreferenceAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_preference',
+ outputSchema: mattermostGetPreferenceOutputSchema,
+ displayName: 'Get Preference',
+ description: 'Gets one preference of a user.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one saved preference of a user by category and name; pass "me" for the connected account. Fails when it was never set. Categories and names come from List Preferences.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ category: Property.ShortText({
+ displayName: 'Category',
+ description: 'Preference category, e.g. "display_settings".',
+ required: true,
+ }),
+ name: Property.ShortText({
+ displayName: 'Name',
+ description: 'Preference name within the category, e.g. "use_military_time".',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, category, name } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/preferences/${encodeURIComponent(category)}/name/${encodeURIComponent(name)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/list-preferences-by-category.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/list-preferences-by-category.ts
new file mode 100644
index 00000000000..179b898c67f
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/list-preferences-by-category.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListPreferencesOutputSchema } from '../../../output-schemas';
+
+export const listPreferencesByCategoryAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_preferences_by_category',
+ outputSchema: mattermostListPreferencesOutputSchema,
+ displayName: 'List Preferences By Category',
+ description: 'Lists a user\'s preferences in one category.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a user\'s saved preferences in one category, e.g. "display_settings"; pass "me" for the connected account. Category names come from List Preferences; for one preference use Get Preference.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ category: Property.ShortText({
+ displayName: 'Category',
+ description: 'Preference category, e.g. "display_settings", "notifications" or "favorite_channel".',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, category } = context.propsValue;
+ const preferences = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/preferences/${encodeURIComponent(category)}`,
+ });
+ return { preferences, count: preferences.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/list-preferences.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/list-preferences.ts
new file mode 100644
index 00000000000..8daae9e1718
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/list-preferences.ts
@@ -0,0 +1,32 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListPreferencesOutputSchema } from '../../../output-schemas';
+
+export const listPreferencesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_preferences',
+ outputSchema: mattermostListPreferencesOutputSchema,
+ displayName: 'List Preferences',
+ description: 'Lists all preferences of a user.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns every saved preference (category, name, value) of a user; pass "me" for the connected account. To read one category use List Preferences By Category.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ const preferences = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(context.propsValue.userId)}/preferences`,
+ });
+ return { preferences, count: preferences.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/save-preferences.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/save-preferences.ts
new file mode 100644
index 00000000000..272b7d4812a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/preferences/save-preferences.ts
@@ -0,0 +1,42 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const savePreferencesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_save_preferences',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Save Preferences',
+ description: 'Creates or updates preferences of a user.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates or overwrites up to 100 preferences (user_id, category, name, value) of a user; preferences not listed are left alone. Another user needs permission to edit other users. Existing categories and names come from List Preferences.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ preferences: Property.Json({
+ displayName: 'Preferences',
+ description:
+ 'JSON array of 1 to 100 preferences, each {"user_id", "category", "name", "value"}. user_id is the 26-character ID of the same user (not "me"), e.g. [{"user_id": "...", "category": "display_settings", "name": "use_military_time", "value": "true"}].',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, preferences } = context.propsValue;
+ if (!Array.isArray(preferences)) {
+ throw new Error('Preferences must be a JSON array of {user_id, category, name, value} objects.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/users/${encodeURIComponent(userId)}/preferences`,
+ body: preferences,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/reactions/add-reaction.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/reactions/add-reaction.ts
new file mode 100644
index 00000000000..2fcf8ca1b57
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/reactions/add-reaction.ts
@@ -0,0 +1,40 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostApi } from '../../../common/api';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAddReactionOutputSchema } from '../../../output-schemas';
+
+export const addReactionAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_add_reaction',
+ outputSchema: mattermostAddReactionOutputSchema,
+ displayName: 'Add Reaction',
+ description: 'Adds an emoji reaction to a post as the connected user.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds an emoji reaction to a post as the connected user. Repeating the same emoji on the same post keeps a single reaction.',
+ idempotent: true,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ emojiName: Property.ShortText({
+ displayName: 'Emoji Name',
+ description: 'Emoji name without colons, e.g. "thumbsup" or a custom emoji name.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { postId, emojiName } = context.propsValue;
+ const me = await mattermostApi.getMe({ auth: context.auth });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/reactions',
+ body: { user_id: me.id, post_id: postId, emoji_name: emojiName },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/reactions/list-reactions.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/reactions/list-reactions.ts
new file mode 100644
index 00000000000..92b20ba9ac9
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/reactions/list-reactions.ts
@@ -0,0 +1,32 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListReactionsOutputSchema } from '../../../output-schemas';
+
+export const listReactionsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_reactions',
+ outputSchema: mattermostListReactionsOutputSchema,
+ displayName: 'List Reactions',
+ description: 'Lists the emoji reactions on a post.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns every emoji reaction on a post, one entry per user and emoji, with who reacted and when.',
+ idempotent: true,
+ },
+ props: {
+ postId: mattermostAiProps.postId({ required: true }),
+ },
+ async run(context) {
+ const reactions = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/posts/${encodeURIComponent(context.propsValue.postId)}/reactions`,
+ });
+ return { reactions, count: reactions.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/reactions/remove-reaction.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/reactions/remove-reaction.ts
new file mode 100644
index 00000000000..80d83437019
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/reactions/remove-reaction.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const removeReactionAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_remove_reaction',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Remove Reaction',
+ description: 'Removes a user\'s emoji reaction from a post.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Removes one emoji reaction a user left on a post; pass "me" for the connected account. Removing someone else\'s reaction needs admin permission. Undo with Add Reaction.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ postId: mattermostAiProps.postId({ required: true }),
+ emojiName: Property.ShortText({
+ displayName: 'Emoji Name',
+ description: 'Emoji name without colons, e.g. "thumbsup". Use List Reactions to see the reactions on a post.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, postId, emojiName } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/users/${encodeURIComponent(userId)}/posts/${encodeURIComponent(postId)}/reactions/${encodeURIComponent(emojiName)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/reports/count-user-reports.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/reports/count-user-reports.ts
new file mode 100644
index 00000000000..1b460377aa0
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/reports/count-user-reports.ts
@@ -0,0 +1,45 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCountUserReportsOutputSchema } from '../../../output-schemas';
+
+export const countUserReportsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_count_user_reports',
+ outputSchema: mattermostCountUserReportsOutputSchema,
+ displayName: 'Count User Reports',
+ description: 'Counts the users an admin user report would list.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns how many users match the same filters as List User Reports, for sizing a report before paging through it. Needs permission to read users in the System Console.',
+ idempotent: true,
+ },
+ props: {
+ searchTerm: Property.ShortText({
+ displayName: 'Search Term',
+ description: 'Filters users by username, name or email.',
+ required: false,
+ }),
+ teamFilter: Property.ShortText({
+ displayName: 'Team ID',
+ description: 'Only users in this team.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { searchTerm, teamFilter } = context.propsValue;
+ const count = await mattermostClient.request<number>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/reports/users/count',
+ query: {
+ ...(searchTerm ? { search_term: searchTerm } : {}),
+ ...(teamFilter ? { team_filter: teamFilter } : {}),
+ },
+ });
+ return { count };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/reports/list-user-reports.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/reports/list-user-reports.ts
new file mode 100644
index 00000000000..6bcae5781b7
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/reports/list-user-reports.ts
@@ -0,0 +1,96 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListUserReportsOutputSchema } from '../../../output-schemas';
+
+export const listUserReportsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_user_reports',
+ outputSchema: mattermostListUserReportsOutputSchema,
+ displayName: 'List User Reports',
+ description: 'Lists users with activity stats for admin reporting.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns a sorted page of users with their activity stats (last login, last post, post counts) for admin reporting. Needs permission to read users in the System Console. To page, pass the last row\'s sort-column value and ID as From Column Value and From ID.',
+ idempotent: true,
+ },
+ props: {
+ sortColumn: Property.StaticDropdown({
+ displayName: 'Sort Column',
+ description: 'Column to sort by. Defaults to "Username".',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Username', value: 'Username' },
+ { label: 'Email', value: 'Email' },
+ { label: 'Create At', value: 'CreateAt' },
+ { label: 'Display Name', value: 'DisplayName' },
+ { label: 'Last Login At', value: 'LastLoginAt' },
+ { label: 'Last Status At', value: 'LastStatusAt' },
+ { label: 'Last Post Date', value: 'LastPostDate' },
+ { label: 'Days Active', value: 'DaysActive' },
+ { label: 'Total Posts', value: 'TotalPosts' },
+ ],
+ },
+ }),
+ sortDirection: Property.StaticDropdown({
+ displayName: 'Sort Direction',
+ description: '"asc" or "desc". Defaults to "asc".',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Ascending', value: 'asc' },
+ { label: 'Descending', value: 'desc' },
+ ],
+ },
+ }),
+ pageSize: Property.Number({
+ displayName: 'Page Size',
+ description: 'Users per page, 1 to 100. Defaults to 50.',
+ required: false,
+ }),
+ fromColumnValue: Property.ShortText({
+ displayName: 'From Column Value',
+ description: 'Sort-column value of the last user on the previous page, to get the next page.',
+ required: false,
+ }),
+ fromId: Property.ShortText({
+ displayName: 'From ID',
+ description: 'ID of the last user on the previous page, to get the next page.',
+ required: false,
+ }),
+ searchTerm: Property.ShortText({
+ displayName: 'Search Term',
+ description: 'Filters users by username, name or email.',
+ required: false,
+ }),
+ teamFilter: Property.ShortText({
+ displayName: 'Team ID',
+ description: 'Only users in this team.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const users = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/reports/users',
+ query: {
+ sort_column: p.sortColumn ?? 'Username',
+ sort_direction: p.sortDirection ?? 'asc',
+ page_size: String(Math.min(Math.max(p.pageSize ?? 50, 1), 100)),
+ ...(p.fromColumnValue ? { from_column_value: p.fromColumnValue } : {}),
+ ...(p.fromId ? { from_id: p.fromId } : {}),
+ ...(p.searchTerm ? { search_term: p.searchTerm } : {}),
+ ...(p.teamFilter ? { team_filter: p.teamFilter } : {}),
+ },
+ });
+ return { users, count: users.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/roles/get-role-by-name.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/roles/get-role-by-name.ts
new file mode 100644
index 00000000000..fc91243f56e
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/roles/get-role-by-name.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetRoleOutputSchema } from '../../../output-schemas';
+
+export const getRoleByNameAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_role_by_name',
+ outputSchema: mattermostGetRoleOutputSchema,
+ displayName: 'Get Role By Name',
+ description: 'Gets a role and its permissions by name.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one role with its permissions by its name, e.g. "system_user", "team_admin" or "channel_user". Use Get Roles By Names for several at once.',
+ idempotent: true,
+ },
+ props: {
+ roleName: Property.ShortText({
+ displayName: 'Role Name',
+ description: 'Role name, e.g. "system_user", "team_admin" or "channel_user".',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/roles/name/${encodeURIComponent(context.propsValue.roleName)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/roles/get-role.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/roles/get-role.ts
new file mode 100644
index 00000000000..b88bc1f2508
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/roles/get-role.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetRoleOutputSchema } from '../../../output-schemas';
+
+export const getRoleAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_role',
+ outputSchema: mattermostGetRoleOutputSchema,
+ displayName: 'Get Role',
+ description: 'Gets a role and its permissions by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one role with its permissions by role ID. Use Get Role By Name when only the name (e.g. "system_user") is known.',
+ idempotent: true,
+ },
+ props: {
+ roleId: Property.ShortText({
+ displayName: 'Role ID',
+ description: 'Role ID (26 characters). Use List Roles or Get Role By Name to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/roles/${encodeURIComponent(context.propsValue.roleId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/roles/get-roles-by-names.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/roles/get-roles-by-names.ts
new file mode 100644
index 00000000000..545e556198c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/roles/get-roles-by-names.ts
@@ -0,0 +1,36 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetRolesByNamesOutputSchema } from '../../../output-schemas';
+
+export const getRolesByNamesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_roles_by_names',
+ outputSchema: mattermostGetRolesByNamesOutputSchema,
+ displayName: 'Get Roles By Names',
+ description: 'Gets several roles and their permissions by name.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the roles matching the given names with their permissions; names that match no role are left out. Use List Roles to see every role.',
+ idempotent: true,
+ },
+ props: {
+ roleNames: Property.Array({
+ displayName: 'Role Names',
+ description: 'Role names, e.g. ["system_user", "team_admin"].',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const roles = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/roles/names',
+ body: context.propsValue.roleNames,
+ });
+ return { roles, count: roles.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/roles/list-roles.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/roles/list-roles.ts
new file mode 100644
index 00000000000..0368610dc7c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/roles/list-roles.ts
@@ -0,0 +1,29 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetRolesByNamesOutputSchema } from '../../../output-schemas';
+
+export const listRolesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_roles',
+ outputSchema: mattermostGetRolesByNamesOutputSchema,
+ displayName: 'List Roles',
+ description: 'Lists every role and its permissions.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns every role on the server (system, team and channel roles) with its permissions. Needs a system admin connection.',
+ idempotent: true,
+ },
+ props: {},
+ async run(context) {
+ const roles = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/roles',
+ });
+ return { roles, count: roles.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/roles/patch-role.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/roles/patch-role.ts
new file mode 100644
index 00000000000..3bd5638dfef
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/roles/patch-role.ts
@@ -0,0 +1,44 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetRoleOutputSchema } from '../../../output-schemas';
+
+export const patchRoleAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_patch_role',
+ outputSchema: mattermostGetRoleOutputSchema,
+ displayName: 'Update Role Permissions',
+ description: 'Replaces the permissions a role grants.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Replaces a role\'s whole permission list with the one given, so read it first with Get Role or Get Role By Name and send the full list. Without an Enterprise license the server only lets a few permissions be added or removed (such as bot, slash command, webhook and channel mention permissions) and rejects the rest. Needs a system admin connection.',
+ idempotent: true,
+ },
+ props: {
+ roleId: Property.ShortText({
+ displayName: 'Role ID',
+ description: 'Role ID (26 characters). Use List Roles or Get Role By Name to find it.',
+ required: true,
+ }),
+ permissions: Property.Array({
+ displayName: 'Permissions',
+ description: 'Full list of permission names the role should grant, e.g. ["create_post", "manage_slash_commands"]. Permissions left out are removed.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { roleId, permissions } = context.propsValue;
+ if (permissions.length === 0) {
+ throw new Error('Permissions must list at least one permission; an empty list would remove every permission from the role.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/roles/${encodeURIComponent(roleId)}/patch`,
+ body: { permissions },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/status/clear-custom-status.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/status/clear-custom-status.ts
new file mode 100644
index 00000000000..fd3dd541fdf
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/status/clear-custom-status.ts
@@ -0,0 +1,28 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const clearCustomStatusAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_clear_custom_status',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Clear Custom Status',
+ description: 'Removes the connected user\'s custom status message.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Removes the connected user\'s current custom status; it stays in their recent custom statuses. Only works for the connected account. To set one use Set Custom Status.',
+ idempotent: true,
+ },
+ props: {},
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: '/users/me/status/custom',
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/status/get-user-status.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/status/get-user-status.ts
new file mode 100644
index 00000000000..b8facb335fc
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/status/get-user-status.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetUserStatusOutputSchema } from '../../../output-schemas';
+
+export const getUserStatusAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_user_status',
+ outputSchema: mattermostGetUserStatusOutputSchema,
+ displayName: 'Get User Status',
+ description: 'Gets a user\'s presence status.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns a user\'s presence (online, away, dnd or offline) and when it last changed; pass "me" for the connected account. For several users at once use Get User Statuses.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(context.propsValue.userId)}/status`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/status/get-user-statuses.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/status/get-user-statuses.ts
new file mode 100644
index 00000000000..8f03d843f4a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/status/get-user-statuses.ts
@@ -0,0 +1,36 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetUserStatusesOutputSchema } from '../../../output-schemas';
+
+export const getUserStatusesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_user_statuses',
+ outputSchema: mattermostGetUserStatusesOutputSchema,
+ displayName: 'Get User Statuses',
+ description: 'Gets the presence status of several users.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the presence (online, away, dnd or offline) of several users in one call. For one user use Get User Status. User IDs come from List Users, Search Users or Get User By Username.',
+ idempotent: true,
+ },
+ props: {
+ userIds: Property.Array({
+ displayName: 'User IDs',
+ description: 'User IDs (26 characters each).',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const statuses = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/users/status/ids',
+ body: context.propsValue.userIds,
+ });
+ return { statuses, count: statuses.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/status/remove-recent-custom-status.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/status/remove-recent-custom-status.ts
new file mode 100644
index 00000000000..323abc9a364
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/status/remove-recent-custom-status.ts
@@ -0,0 +1,51 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const removeRecentCustomStatusAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_remove_recent_custom_status',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Remove Recent Custom Status',
+ description: 'Removes an entry from the connected user\'s recent custom statuses.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Removes one entry from the connected user\'s recent custom statuses list. All four fields must match the entry exactly; the list is the "recentCustomStatuses" JSON in props from Get User with "me". Only works for the connected account.',
+ idempotent: false,
+ },
+ props: {
+ emoji: Property.ShortText({
+ displayName: 'Emoji',
+ description: 'The entry\'s emoji, e.g. "calendar".',
+ required: true,
+ }),
+ text: Property.ShortText({
+ displayName: 'Text',
+ description: 'The entry\'s text.',
+ required: true,
+ }),
+ duration: Property.ShortText({
+ displayName: 'Duration',
+ description: 'The entry\'s duration, e.g. "one_hour" or "date_and_time".',
+ required: true,
+ }),
+ expiresAt: Property.ShortText({
+ displayName: 'Expires At',
+ description: 'The entry\'s expires_at, exactly as stored (ISO 8601).',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { emoji, text, duration, expiresAt } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/users/me/status/custom/recent/delete',
+ body: { emoji, text, duration, expires_at: expiresAt },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/status/set-custom-status.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/status/set-custom-status.ts
new file mode 100644
index 00000000000..b6a242c2073
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/status/set-custom-status.ts
@@ -0,0 +1,76 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const setCustomStatusAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_set_custom_status',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Set Custom Status',
+ description: 'Sets the connected user\'s custom status message.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Sets the connected user\'s custom status (emoji and text, e.g. "In a meeting") and how long it lasts; it also joins their recent custom statuses. Only works for the connected account. Duration "date_and_time" needs Expires At. To remove it use Clear Custom Status.',
+ idempotent: true,
+ },
+ props: {
+ emoji: Property.ShortText({
+ displayName: 'Emoji',
+ description: 'Emoji name without colons, e.g. "calendar".',
+ required: true,
+ }),
+ text: Property.ShortText({
+ displayName: 'Text',
+ description: 'Status text, up to 100 characters.',
+ required: true,
+ }),
+ duration: Property.StaticDropdown({
+ displayName: 'Duration',
+ description:
+ 'How long it lasts: "thirty_minutes", "one_hour", "four_hours", "today", "this_week" or "date_and_time". Leave empty to keep it until cleared.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: '30 Minutes', value: 'thirty_minutes' },
+ { label: '1 Hour', value: 'one_hour' },
+ { label: '4 Hours', value: 'four_hours' },
+ { label: 'Today', value: 'today' },
+ { label: 'This Week', value: 'this_week' },
+ { label: 'Until Expires At', value: 'date_and_time' },
+ ],
+ },
+ }),
+ expiresAt: Property.ShortText({
+ displayName: 'Expires At',
+ description: 'ISO 8601 date-time when the status ends, e.g. "2026-11-03T17:00:00Z". Needed for duration "date_and_time".',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { emoji, text, duration, expiresAt } = context.propsValue;
+ if (duration && !DURATIONS.includes(duration)) {
+ throw new Error(`Duration must be one of ${DURATIONS.join(', ')}, got "${duration}".`);
+ }
+ if (duration === 'date_and_time' && !expiresAt) {
+ throw new Error('Duration "date_and_time" needs Expires At.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: '/users/me/status/custom',
+ body: {
+ emoji,
+ text,
+ ...(duration ? { duration } : {}),
+ ...(expiresAt ? { expires_at: expiresAt } : {}),
+ },
+ });
+ },
+});
+
+const DURATIONS = ['thirty_minutes', 'one_hour', 'four_hours', 'today', 'this_week', 'date_and_time'];
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/status/update-user-status.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/status/update-user-status.ts
new file mode 100644
index 00000000000..11d2e265eca
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/status/update-user-status.ts
@@ -0,0 +1,67 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostApi } from '../../../common/api';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetUserStatusOutputSchema } from '../../../output-schemas';
+
+export const updateUserStatusAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_user_status',
+ outputSchema: mattermostGetUserStatusOutputSchema,
+ displayName: 'Update User Status',
+ description: 'Sets a user\'s presence status.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Manually sets a user\'s presence to online, away, offline or dnd (do not disturb); it stays until set to online again, which returns it to automatic. DND End Time only goes with dnd. Another user needs permission to edit other users. For a custom status message use Set Custom Status.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ status: Property.StaticDropdown({
+ displayName: 'Status',
+ description: '"online", "away", "offline" or "dnd" (do not disturb).',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Online', value: 'online' },
+ { label: 'Away', value: 'away' },
+ { label: 'Offline', value: 'offline' },
+ { label: 'Do Not Disturb', value: 'dnd' },
+ ],
+ },
+ }),
+ dndEndTime: Property.Number({
+ displayName: 'DND End Time',
+ description: 'Unix time in seconds when do not disturb ends. Only with status "dnd"; leave empty for no end.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { userId, status, dndEndTime } = context.propsValue;
+ if (!STATUSES.includes(status)) {
+ throw new Error(`Status must be one of ${STATUSES.join(', ')}, got "${status}".`);
+ }
+ const hasDndEndTime = dndEndTime !== undefined && dndEndTime !== null;
+ if (hasDndEndTime && status !== 'dnd') {
+ throw new Error('DND End Time can only be set with status "dnd".');
+ }
+ const resolvedUserId = userId === 'me' ? (await mattermostApi.getMe({ auth: context.auth })).id : userId;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/users/${encodeURIComponent(resolvedUserId)}/status`,
+ body: {
+ user_id: resolvedUserId,
+ status,
+ ...(hasDndEndTime ? { dnd_end_time: dndEndTime } : {}),
+ },
+ });
+ },
+});
+
+const STATUSES = ['online', 'away', 'offline', 'dnd'];
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/add-team-member.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/add-team-member.ts
new file mode 100644
index 00000000000..c93af37bc75
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/add-team-member.ts
@@ -0,0 +1,37 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAddTeamMemberOutputSchema } from '../../../output-schemas';
+
+export const addTeamMemberAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_add_team_member',
+ outputSchema: mattermostAddTeamMemberOutputSchema,
+ displayName: 'Add Team Member',
+ description: 'Adds a user to a team.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds one user to a team, or joins an open team as the connected user. Adding someone who is already a member keeps the existing membership. For several users at once use Add Team Members.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ userId: mattermostAiProps.userId({
+ required: true,
+ description: 'User ID (26 characters); "me" is not accepted here. Use Get User By Username or Search Users to find it.',
+ }),
+ },
+ async run(context) {
+ const { teamId, userId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/teams/${encodeURIComponent(teamId)}/members`,
+ body: { team_id: teamId, user_id: userId },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/add-team-members.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/add-team-members.ts
new file mode 100644
index 00000000000..6974e77731d
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/add-team-members.ts
@@ -0,0 +1,39 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAddTeamMembersOutputSchema } from '../../../output-schemas';
+
+export const addTeamMembersAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_add_team_members',
+ outputSchema: mattermostAddTeamMembersOutputSchema,
+ displayName: 'Add Team Members',
+ description: 'Adds several users to a team at once.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds a list of users to a team in one call and stops at the first user that cannot be added. Needs the add_user_to_team permission. For one user use Add Team Member.',
+ idempotent: false,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ userIds: Property.Array({
+ displayName: 'User IDs',
+ description: 'User IDs (26 characters each) to add. Use Get User By Username or Search Users to find them.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { teamId, userIds } = context.propsValue;
+ const members = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/teams/${encodeURIComponent(teamId)}/members/batch`,
+ body: userIds.map((userId) => ({ team_id: teamId, user_id: userId })),
+ });
+ return { members, count: members.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/archive-team.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/archive-team.ts
new file mode 100644
index 00000000000..ace7653ed5e
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/archive-team.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const archiveTeamAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_archive_team',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Archive Team',
+ description: 'Archives a team (soft delete); it can be restored later.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Archives a team: it is soft deleted and hidden from users, but its data is kept and Restore Team brings it back. Never deletes permanently. Needs the manage_team permission.',
+ idempotent: false,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/teams/${encodeURIComponent(context.propsValue.teamId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/check-team-exists.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/check-team-exists.ts
new file mode 100644
index 00000000000..b2eb4360e80
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/check-team-exists.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCheckTeamExistsOutputSchema } from '../../../output-schemas';
+
+export const checkTeamExistsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_check_team_exists',
+ outputSchema: mattermostCheckTeamExistsOutputSchema,
+ displayName: 'Check Team Exists',
+ description: 'Checks whether a team handle is already taken.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Tells whether a team with this handle exists, e.g. before Create Team. Use Get Team By Name to read the team itself.',
+ idempotent: true,
+ },
+ props: {
+ teamName: Property.ShortText({
+ displayName: 'Team Name',
+ description: 'Team handle from the team URL, e.g. "engineering". Not the display name.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/name/${encodeURIComponent(context.propsValue.teamName)}/exists`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/create-team.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/create-team.ts
new file mode 100644
index 00000000000..b6d8e5d12c6
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/create-team.ts
@@ -0,0 +1,61 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateTeamOutputSchema } from '../../../output-schemas';
+
+export const createTeamAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_create_team',
+ outputSchema: mattermostCreateTeamOutputSchema,
+ displayName: 'Create Team',
+ description: 'Creates a team.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a team; the connected user becomes its admin. Type "O" lets anyone on the server join, "I" is invite-only. Not idempotent: a taken name fails.',
+ idempotent: false,
+ },
+ props: {
+ name: Property.ShortText({
+ displayName: 'Name',
+ description: 'Unique handle used in the team URL: lowercase letters, numbers and "-", e.g. "engineering".',
+ required: true,
+ }),
+ displayName: Property.ShortText({
+ displayName: 'Display Name',
+ description: 'Team name shown to users.',
+ required: true,
+ }),
+ type: Property.StaticDropdown({
+ displayName: 'Type',
+ description: '"O" for open, "I" for invite only.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Open', value: 'O' },
+ { label: 'Invite only', value: 'I' },
+ ],
+ },
+ }),
+ description: Property.ShortText({
+ displayName: 'Description',
+ description: 'What the team is for.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { name, displayName, type, description } = context.propsValue;
+ if (type !== 'O' && type !== 'I') {
+ throw new Error(`Type must be "O" or "I", got "${type}".`);
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/teams',
+ body: { name, display_name: displayName, type, description },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-by-name.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-by-name.ts
new file mode 100644
index 00000000000..7b43f369d53
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-by-name.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateTeamOutputSchema } from '../../../output-schemas';
+
+export const getTeamByNameAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_team_by_name',
+ outputSchema: mattermostCreateTeamOutputSchema,
+ displayName: 'Get Team By Name',
+ description: 'Gets a team by its handle (the name in the team URL).',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the team whose handle (the name in its URL, e.g. "engineering") matches exactly; use it to turn a handle into a team ID. For partial matches use Search Teams.',
+ idempotent: true,
+ },
+ props: {
+ teamName: Property.ShortText({
+ displayName: 'Team Name',
+ description: 'Team handle from the team URL, e.g. "engineering". Not the display name.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/name/${encodeURIComponent(context.propsValue.teamName)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-icon.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-icon.ts
new file mode 100644
index 00000000000..048c3f24ccf
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-icon.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostDownloadFileOutputSchema } from '../../../output-schemas';
+
+export const getTeamIconAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_team_icon',
+ outputSchema: mattermostDownloadFileOutputSchema,
+ displayName: 'Get Team Icon',
+ description: 'Downloads a team\'s icon image.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Downloads the team\'s icon and returns it as a file. Fails if the team has no custom icon; set one with Set Team Icon.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ const download = await mattermostClient.download({
+ auth: context.auth,
+ path: `/teams/${encodeURIComponent(context.propsValue.teamId)}/image`,
+ });
+ const fileName = download.fileName ?? 'team-icon.png';
+ const file = await context.files.write({ fileName, data: download.data });
+ return { file, fileName, contentType: download.contentType, size: download.data.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-invite-info.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-invite-info.ts
new file mode 100644
index 00000000000..54800249de8
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-invite-info.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetTeamInviteInfoOutputSchema } from '../../../output-schemas';
+
+export const getTeamInviteInfoAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_team_invite_info',
+ outputSchema: mattermostGetTeamInviteInfoOutputSchema,
+ displayName: 'Get Team Invite Info',
+ description: 'Looks up which team an invite ID belongs to.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the ID, handle, display name and description of the team an invite ID belongs to, e.g. before Join Team By Invite.',
+ idempotent: true,
+ },
+ props: {
+ inviteId: Property.ShortText({
+ displayName: 'Invite ID',
+ description: 'Team invite ID, from an invite link or the "invite_id" field of Get Team.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/invite/${encodeURIComponent(context.propsValue.inviteId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-member.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-member.ts
new file mode 100644
index 00000000000..34a1e1acc48
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-member.ts
@@ -0,0 +1,33 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAddTeamMemberOutputSchema } from '../../../output-schemas';
+
+export const getTeamMemberAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_team_member',
+ outputSchema: mattermostAddTeamMemberOutputSchema,
+ displayName: 'Get Team Member',
+ description: 'Gets one user\'s membership in a team.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns a user\'s membership in a team (roles, admin flag); pass "me" for the connected account. Fails if the user was never a member; a removed member is still returned, with delete_at set to the removal time.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ const { teamId, userId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/${encodeURIComponent(teamId)}/members/${encodeURIComponent(userId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-members-by-ids.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-members-by-ids.ts
new file mode 100644
index 00000000000..20f3850ab7c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-members-by-ids.ts
@@ -0,0 +1,39 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAddTeamMembersOutputSchema } from '../../../output-schemas';
+
+export const getTeamMembersByIdsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_team_members_by_ids',
+ outputSchema: mattermostAddTeamMembersOutputSchema,
+ displayName: 'Get Team Members By IDs',
+ description: 'Gets the team memberships of several users at once.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the memberships in one team for the given user IDs; users who are not members are left out. For a single user use Get Team Member.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ userIds: Property.Array({
+ displayName: 'User IDs',
+ description: 'User IDs (26 characters each). Use Get User By Username or Search Users to find them.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { teamId, userIds } = context.propsValue;
+ const members = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/teams/${encodeURIComponent(teamId)}/members/ids`,
+ body: userIds,
+ });
+ return { members, count: members.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-stats.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-stats.ts
new file mode 100644
index 00000000000..9cf7c456011
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-stats.ts
@@ -0,0 +1,30 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetTeamStatsOutputSchema } from '../../../output-schemas';
+
+export const getTeamStatsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_team_stats',
+ outputSchema: mattermostGetTeamStatsOutputSchema,
+ displayName: 'Get Team Stats',
+ description: 'Gets the member counts of a team.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description: 'Returns how many members a team has. To list them use List Team Members.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/${encodeURIComponent(context.propsValue.teamId)}/stats`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-unread.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-unread.ts
new file mode 100644
index 00000000000..6a85b2be1fc
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team-unread.ts
@@ -0,0 +1,33 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetTeamUnreadOutputSchema } from '../../../output-schemas';
+
+export const getTeamUnreadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_team_unread',
+ outputSchema: mattermostGetTeamUnreadOutputSchema,
+ displayName: 'Get Team Unread',
+ description: 'Gets a user\'s unread message and mention counts in one team.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the unread message and mention counts of a user in one team; pass "me" for the connected account. For all teams at once use List Team Unreads.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ const { userId, teamId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/unread`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team.ts
new file mode 100644
index 00000000000..0e4ef7a0bb8
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/get-team.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetTeamOutputSchema } from '../../../output-schemas';
+
+export const getTeamAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_team',
+ outputSchema: mattermostGetTeamOutputSchema,
+ displayName: 'Get Team',
+ description: 'Gets a team by its ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one team by ID, including its type and invite ID. If you only have the team handle, use Get Team By Name.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/${encodeURIComponent(context.propsValue.teamId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/invalidate-email-invites.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/invalidate-email-invites.ts
new file mode 100644
index 00000000000..fa3eb163845
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/invalidate-email-invites.ts
@@ -0,0 +1,28 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const invalidateEmailInvitesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_invalidate_email_invites',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Invalidate Email Invites',
+ description: 'Cancels every pending email invitation on the server.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Invalidates every email invitation not yet accepted, across all teams on the server; the links in those emails stop working and cannot be revived. Needs a system admin connection.',
+ idempotent: false,
+ },
+ props: {},
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: '/teams/invites/email',
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/invite-users-by-email.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/invite-users-by-email.ts
new file mode 100644
index 00000000000..229dd23fd8b
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/invite-users-by-email.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const inviteUsersByEmailAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_invite_users_by_email',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Invite Users By Email',
+ description: 'Emails team invitations to a list of addresses.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Sends a team invitation email to each address. Only works when the server has email invitations enabled and SMTP configured; the server allows about 20 invitation emails per hour. Needs the invite_user and add_user_to_team permissions. Not idempotent: each call sends new emails.',
+ idempotent: false,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ emails: Property.Array({
+ displayName: 'Emails',
+ description: 'Email addresses to invite.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { teamId, emails } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/teams/${encodeURIComponent(teamId)}/invite/email`,
+ body: emails,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/join-team-by-invite.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/join-team-by-invite.ts
new file mode 100644
index 00000000000..8aad6148d56
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/join-team-by-invite.ts
@@ -0,0 +1,44 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostAddTeamMemberOutputSchema } from '../../../output-schemas';
+
+export const joinTeamByInviteAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_join_team_by_invite',
+ outputSchema: mattermostAddTeamMemberOutputSchema,
+ displayName: 'Join Team By Invite',
+ description: 'Joins a team as the connected user with an invite ID or email invite token.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds the connected user to a team using exactly one of: a team invite ID (from Get Team or Regenerate Team Invite ID) or the token from an email invitation link.',
+ idempotent: false,
+ },
+ props: {
+ inviteId: Property.ShortText({
+ displayName: 'Invite ID',
+ description: 'Team invite ID, the "invite_id" field of Get Team. Set this or Token, not both.',
+ required: false,
+ }),
+ token: Property.ShortText({
+ displayName: 'Token',
+ description: 'Token from an email invitation link. Set this or Invite ID, not both.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { inviteId, token } = context.propsValue;
+ if ((inviteId === undefined) === (token === undefined)) {
+ throw new Error('Set exactly one of Invite ID or Token.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/teams/members/invite',
+ query: inviteId !== undefined ? { invite_id: inviteId } : { token: token ?? '' },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-team-members.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-team-members.ts
new file mode 100644
index 00000000000..100ed2c9dc8
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-team-members.ts
@@ -0,0 +1,59 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostAddTeamMembersOutputSchema } from '../../../output-schemas';
+
+export const listTeamMembersAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_team_members',
+ outputSchema: mattermostAddTeamMembersOutputSchema,
+ displayName: 'List Team Members',
+ description: 'Lists the members of a team, one page at a time.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns one page of team memberships (user ID, roles, admin flag). For specific users use Get Team Member or Get Team Members By IDs; for the member count use Get Team Stats.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ sort: Property.StaticDropdown({
+ displayName: 'Sort',
+ description: '"Username" to sort by username. Leave empty to sort by user ID.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [{ label: 'Username', value: 'Username' }],
+ },
+ }),
+ excludeDeletedUsers: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Exclude Deleted Users',
+ description: '"true" to leave out deactivated users. Defaults to "false".',
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { teamId, sort, excludeDeletedUsers, page, perPage } = context.propsValue;
+ if (sort !== undefined && sort !== 'Username') {
+ throw new Error(`Sort must be "Username" or empty, got "${sort}".`);
+ }
+ const excludeDeleted = mattermostUtils.parseBoolean({ value: excludeDeletedUsers });
+ const members = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/teams/${encodeURIComponent(teamId)}/members`,
+ query: {
+ ...mattermostUtils.paging({ page, perPage }),
+ ...(sort !== undefined ? { sort } : {}),
+ ...(excludeDeleted !== undefined ? { exclude_deleted_users: String(excludeDeleted) } : {}),
+ },
+ });
+ return { members, count: members.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-team-unreads.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-team-unreads.ts
new file mode 100644
index 00000000000..4b349005370
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-team-unreads.ts
@@ -0,0 +1,49 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListTeamUnreadsOutputSchema } from '../../../output-schemas';
+
+export const listTeamUnreadsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_team_unreads',
+ outputSchema: mattermostListTeamUnreadsOutputSchema,
+ displayName: 'List Team Unreads',
+ description: 'Lists unread message and mention counts for each of a user\'s teams.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns unread message and mention counts per team for every team the user is on; pass "me" for the connected account. For one team use Get Team Unread.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ excludeTeamId: mattermostAiProps.teamId({
+ required: false,
+ displayName: 'Exclude Team ID',
+ description: 'Team ID (26 characters) to leave out of the results. Use List User Teams to find it.',
+ }),
+ includeCollapsedThreads: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Collapsed Threads',
+ description: '"true" to count unread replies in collapsed threads too. Defaults to "false".',
+ }),
+ },
+ async run(context) {
+ const { userId, excludeTeamId, includeCollapsedThreads } = context.propsValue;
+ const collapsedThreads = mattermostUtils.parseBoolean({ value: includeCollapsedThreads });
+ const unreads = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/teams/unread`,
+ query: {
+ exclude_team: excludeTeamId ?? '',
+ ...(collapsedThreads !== undefined ? { include_collapsed_threads: String(collapsedThreads) } : {}),
+ },
+ });
+ return { unreads, count: unreads.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-teams.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-teams.ts
new file mode 100644
index 00000000000..a2d90625135
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-teams.ts
@@ -0,0 +1,36 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListGroupChannelCommonTeamsOutputSchema } from '../../../output-schemas';
+
+export const listTeamsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_teams',
+ outputSchema: mattermostListGroupChannelCommonTeamsOutputSchema,
+ displayName: 'List Teams',
+ description: 'Lists teams on the server, one page at a time.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns one page of teams. Regular users only see open teams; a system admin connection sees all of them. To find teams by name use Search Teams, for the teams a user belongs to use List User Teams.',
+ idempotent: true,
+ },
+ props: {
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { page, perPage } = context.propsValue;
+ const teams = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/teams',
+ query: mattermostUtils.paging({ page, perPage }),
+ });
+ return { teams, count: teams.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-user-team-memberships.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-user-team-memberships.ts
new file mode 100644
index 00000000000..2d683dc0e93
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-user-team-memberships.ts
@@ -0,0 +1,32 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListUserTeamMembershipsOutputSchema } from '../../../output-schemas';
+
+export const listUserTeamMembershipsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_user_team_memberships',
+ outputSchema: mattermostListUserTeamMembershipsOutputSchema,
+ displayName: 'List User Team Memberships',
+ description: 'Lists a user\'s membership and roles in each of their teams.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the user\'s team memberships (team ID, roles, admin flag) across all their teams; pass "me" for the connected account. For the teams themselves use List User Teams.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ const memberships = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(context.propsValue.userId)}/teams/members`,
+ });
+ return { memberships, count: memberships.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-user-teams.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-user-teams.ts
new file mode 100644
index 00000000000..ec18ddcd33b
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/list-user-teams.ts
@@ -0,0 +1,32 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListGroupChannelCommonTeamsOutputSchema } from '../../../output-schemas';
+
+export const listUserTeamsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_user_teams',
+ outputSchema: mattermostListGroupChannelCommonTeamsOutputSchema,
+ displayName: 'List User Teams',
+ description: 'Lists the teams a user belongs to.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns every team the user is a member of; pass "me" for the connected account. Another user\'s teams need a system admin connection. For the user\'s roles in each team use List User Team Memberships.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ const teams = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(context.propsValue.userId)}/teams`,
+ });
+ return { teams, count: teams.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/patch-team.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/patch-team.ts
new file mode 100644
index 00000000000..14928ee9a8c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/patch-team.ts
@@ -0,0 +1,64 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostCreateTeamOutputSchema } from '../../../output-schemas';
+
+export const patchTeamAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_patch_team',
+ outputSchema: mattermostCreateTeamOutputSchema,
+ displayName: 'Update Team',
+ description: 'Updates a team\'s display name, description, company name or open invite setting.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Changes only the team fields you set and leaves the rest as they are. To switch between open and invite-only use Update Team Privacy; to rotate the invite link use Regenerate Team Invite ID. Needs the manage_team permission.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ displayName: Property.ShortText({
+ displayName: 'Display Name',
+ description: 'New team name shown to users.',
+ required: false,
+ }),
+ description: Property.ShortText({
+ displayName: 'Description',
+ description: 'New team description.',
+ required: false,
+ }),
+ companyName: Property.ShortText({
+ displayName: 'Company Name',
+ description: 'New company name.',
+ required: false,
+ }),
+ allowOpenInvite: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Allow Open Invite',
+ description: '"true" lets any user on the server join the team without an invite.',
+ }),
+ },
+ async run(context) {
+ const { teamId, displayName, description, companyName, allowOpenInvite } = context.propsValue;
+ const openInvite = mattermostUtils.parseBoolean({ value: allowOpenInvite });
+ const body = {
+ ...(displayName !== undefined ? { display_name: displayName } : {}),
+ ...(description !== undefined ? { description } : {}),
+ ...(companyName !== undefined ? { company_name: companyName } : {}),
+ ...(openInvite !== undefined ? { allow_open_invite: openInvite } : {}),
+ };
+ if (Object.keys(body).length === 0) {
+ throw new Error('Set at least one of Display Name, Description, Company Name or Allow Open Invite.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/teams/${encodeURIComponent(teamId)}/patch`,
+ body,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/regenerate-team-invite-id.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/regenerate-team-invite-id.ts
new file mode 100644
index 00000000000..30ab7f50e36
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/regenerate-team-invite-id.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateTeamOutputSchema } from '../../../output-schemas';
+
+export const regenerateTeamInviteIdAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_regenerate_team_invite_id',
+ outputSchema: mattermostCreateTeamOutputSchema,
+ displayName: 'Regenerate Team Invite ID',
+ description: 'Replaces a team\'s invite ID, so old invite links stop working.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Issues a new invite ID for the team and returns the team with it; every earlier invite link stops working. Needs the manage_team permission. Not idempotent: each call issues a different ID.',
+ idempotent: false,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/teams/${encodeURIComponent(context.propsValue.teamId)}/regenerate_invite_id`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/remove-team-icon.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/remove-team-icon.ts
new file mode 100644
index 00000000000..b5e0c6f800c
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/remove-team-icon.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const removeTeamIconAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_remove_team_icon',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Remove Team Icon',
+ description: 'Removes a team\'s custom icon.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Deletes the team\'s custom icon so the default initials show again; the image is not kept. Needs the manage_team permission.',
+ idempotent: false,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/teams/${encodeURIComponent(context.propsValue.teamId)}/image`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/remove-team-member.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/remove-team-member.ts
new file mode 100644
index 00000000000..9087c7de290
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/remove-team-member.ts
@@ -0,0 +1,33 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const removeTeamMemberAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_remove_team_member',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Remove Team Member',
+ description: 'Removes a user from a team.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Removes a user from a team and its channels; pass "me" to leave the team as the connected user. Add Team Member adds them back. Removing someone else needs the remove_user_from_team permission.',
+ idempotent: false,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ const { teamId, userId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/teams/${encodeURIComponent(teamId)}/members/${encodeURIComponent(userId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/restore-team.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/restore-team.ts
new file mode 100644
index 00000000000..cdfb77d6765
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/restore-team.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateTeamOutputSchema } from '../../../output-schemas';
+
+export const restoreTeamAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_restore_team',
+ outputSchema: mattermostCreateTeamOutputSchema,
+ displayName: 'Restore Team',
+ description: 'Restores a team that was archived.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Brings back a team archived with Archive Team, with its channels and members. Needs the manage_team permission.',
+ idempotent: false,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/teams/${encodeURIComponent(context.propsValue.teamId)}/restore`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/search-teams.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/search-teams.ts
new file mode 100644
index 00000000000..36500bf45d0
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/search-teams.ts
@@ -0,0 +1,52 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostSearchTeamsOutputSchema } from '../../../output-schemas';
+
+export const searchTeamsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_search_teams',
+ outputSchema: mattermostSearchTeamsOutputSchema,
+ displayName: 'Search Teams',
+ description: 'Searches teams by name or display name.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Finds teams whose handle or display name matches the term, one page at a time, with the total match count. Regular users only find open teams; a system admin connection finds all of them.',
+ idempotent: true,
+ },
+ props: {
+ term: Property.ShortText({
+ displayName: 'Term',
+ description: 'Text to match against team handles and display names.',
+ required: true,
+ }),
+ allowOpenInvite: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Allow Open Invite',
+ description: '"true" for only teams anyone can join, "false" for only teams that need an invite. Leave empty for both.',
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { term, allowOpenInvite, page, perPage } = context.propsValue;
+ const paging = mattermostUtils.paging({ page, perPage });
+ const openInvite = mattermostUtils.parseBoolean({ value: allowOpenInvite });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/teams/search',
+ body: {
+ term,
+ page: Number(paging.page),
+ per_page: Number(paging.per_page),
+ ...(openInvite !== undefined ? { allow_open_invite: openInvite } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/set-team-icon.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/set-team-icon.ts
new file mode 100644
index 00000000000..07bbd168da9
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/set-team-icon.ts
@@ -0,0 +1,40 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const setTeamIconAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_set_team_icon',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Set Team Icon',
+ description: 'Uploads an image as a team\'s icon.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Replaces the team\'s icon with the uploaded image. Needs the manage_team permission. Remove Team Icon restores the default.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ image: Property.File({
+ displayName: 'Image',
+ description: 'Image file for the icon.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { teamId, image } = context.propsValue;
+ const form = new FormData();
+ form.append('image', new Blob([new Uint8Array(image.data)]), image.filename);
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/teams/${encodeURIComponent(teamId)}/image`,
+ body: form,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/update-team-member-roles.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/update-team-member-roles.ts
new file mode 100644
index 00000000000..4a8826ee3e3
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/update-team-member-roles.ts
@@ -0,0 +1,48 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const updateTeamMemberRolesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_team_member_roles',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Update Team Member Roles',
+ description: 'Makes a team member a team admin or a regular member.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Sets whether a team member is a team admin and whether they are a regular team user; pass "me" for the connected account. Usually Team Admin "true" plus Team User "true" for an admin, Team Admin "false" plus Team User "true" for a regular member. Needs the manage_team_roles permission.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ userId: mattermostAiProps.userId({ required: true }),
+ schemeAdmin: mattermostAiProps.booleanFlag({
+ required: true,
+ displayName: 'Team Admin',
+ description: '"true" to make the member a team admin, "false" to remove admin rights.',
+ }),
+ schemeUser: mattermostAiProps.booleanFlag({
+ required: true,
+ displayName: 'Team User',
+ description: '"true" for a regular team member. Keep "true" unless the member is a guest.',
+ }),
+ },
+ async run(context) {
+ const { teamId, userId, schemeAdmin, schemeUser } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/teams/${encodeURIComponent(teamId)}/members/${encodeURIComponent(userId)}/schemeRoles`,
+ body: {
+ scheme_admin: mattermostUtils.parseBoolean({ value: schemeAdmin }),
+ scheme_user: mattermostUtils.parseBoolean({ value: schemeUser }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/teams/update-team-privacy.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/update-team-privacy.ts
new file mode 100644
index 00000000000..444317253bd
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/teams/update-team-privacy.ts
@@ -0,0 +1,48 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUpdateTeamPrivacyOutputSchema } from '../../../output-schemas';
+
+export const updateTeamPrivacyAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_team_privacy',
+ outputSchema: mattermostUpdateTeamPrivacyOutputSchema,
+ displayName: 'Update Team Privacy',
+ description: 'Switches a team between open and invite only.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Sets a team to "O" (open: anyone on the server can join) or "I" (invite only). Needs the manage_team permission.',
+ idempotent: true,
+ },
+ props: {
+ teamId: mattermostAiProps.teamId({ required: true }),
+ privacy: Property.StaticDropdown({
+ displayName: 'Privacy',
+ description: '"O" for open, "I" for invite only.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Open', value: 'O' },
+ { label: 'Invite only', value: 'I' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ const { teamId, privacy } = context.propsValue;
+ if (privacy !== 'O' && privacy !== 'I') {
+ throw new Error(`Privacy must be "O" or "I", got "${privacy}".`);
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/teams/${encodeURIComponent(teamId)}/privacy`,
+ body: { privacy },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/threads/follow-thread.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/follow-thread.ts
new file mode 100644
index 00000000000..b84b26ffafb
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/follow-thread.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const followThreadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_follow_thread',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Follow Thread',
+ description: 'Starts following a thread for a user.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Makes a user follow a thread so its replies show in their threads list and notify them; pass "me" for the connected account. Following an already followed thread changes nothing. Undo with Unfollow Thread.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ threadId: Property.ShortText({
+ displayName: 'Thread ID',
+ description: 'ID (26 characters) of the thread\'s root post. Use List Followed Threads or Get Post Thread to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, threadId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/threads/${encodeURIComponent(threadId)}/following`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/threads/get-thread.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/get-thread.ts
new file mode 100644
index 00000000000..ae2e3093f6f
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/get-thread.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetThreadOutputSchema } from '../../../output-schemas';
+
+export const getThreadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_thread',
+ outputSchema: mattermostGetThreadOutputSchema,
+ displayName: 'Get Followed Thread',
+ description: 'Gets a thread a user follows, with its unread state.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one followed thread with its reply count, participants, last reply time and unread counts for the user; pass "me" for the connected account. Use Get Post Thread for the posts themselves.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ threadId: Property.ShortText({
+ displayName: 'Thread ID',
+ description: 'ID (26 characters) of the thread\'s root post. Use List Followed Threads or Get Post Thread to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, threadId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/threads/${encodeURIComponent(threadId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/threads/list-threads.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/list-threads.ts
new file mode 100644
index 00000000000..dd572cb561a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/list-threads.ts
@@ -0,0 +1,52 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListThreadsOutputSchema } from '../../../output-schemas';
+
+export const listThreadsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_threads',
+ outputSchema: mattermostListThreadsOutputSchema,
+ displayName: 'List Followed Threads',
+ description: 'Lists the threads a user follows in a team.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the threads a user follows in a team, newest activity first, with reply counts and unread state; pass "me" for the connected account. Needs collapsed reply threads enabled on the server.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ since: Property.Number({
+ displayName: 'Since',
+ description: 'Only threads with activity after this time, in milliseconds since epoch.',
+ required: false,
+ }),
+ includeDeleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Deleted',
+ description: '"true" to include threads whose root post was deleted. Defaults to "false".',
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { userId, teamId, since, includeDeleted, page, perPage } = context.propsValue;
+ const deleted = mattermostUtils.parseBoolean({ value: includeDeleted });
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/threads`,
+ query: {
+ ...mattermostUtils.paging({ page, perPage }),
+ ...(since !== undefined ? { since: String(since) } : {}),
+ ...(deleted !== undefined ? { deleted: String(deleted) } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/threads/mark-all-threads-read.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/mark-all-threads-read.ts
new file mode 100644
index 00000000000..5ac6bafb84a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/mark-all-threads-read.ts
@@ -0,0 +1,33 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const markAllThreadsReadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_mark_all_threads_read',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Mark All Threads Read',
+ description: 'Marks every thread a user follows in a team as read.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Marks every thread a user follows in a team as read; pass "me" for the connected account. Use Mark Thread Read for a single thread.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ const { userId, teamId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/threads/read`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/threads/mark-thread-read.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/mark-thread-read.ts
new file mode 100644
index 00000000000..05dc5e196c0
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/mark-thread-read.ts
@@ -0,0 +1,43 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostMarkThreadReadOutputSchema } from '../../../output-schemas';
+
+export const markThreadReadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_mark_thread_read',
+ outputSchema: mattermostMarkThreadReadOutputSchema,
+ displayName: 'Mark Thread Read',
+ description: 'Marks a followed thread as read up to a point in time.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Sets the last-read time of a thread a user follows, so replies after Timestamp count as unread; pass "me" for the connected account and the current time to mark it fully read. Use Mark Thread Unread to mark from a specific reply.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ threadId: Property.ShortText({
+ displayName: 'Thread ID',
+ description: 'ID (26 characters) of the thread\'s root post. Use List Followed Threads or Get Post Thread to find it.',
+ required: true,
+ }),
+ timestamp: Property.Number({
+ displayName: 'Timestamp',
+ description: 'Read up to this time, in milliseconds since epoch.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, threadId, timestamp } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/threads/${encodeURIComponent(threadId)}/read/${encodeURIComponent(String(timestamp))}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/threads/mark-thread-unread.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/mark-thread-unread.ts
new file mode 100644
index 00000000000..af676bf37e1
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/mark-thread-unread.ts
@@ -0,0 +1,42 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostMarkThreadReadOutputSchema } from '../../../output-schemas';
+
+export const markThreadUnreadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_mark_thread_unread',
+ outputSchema: mattermostMarkThreadReadOutputSchema,
+ displayName: 'Mark Thread Unread',
+ description: 'Marks a followed thread as unread from a given reply onward.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Marks a thread a user follows as unread starting at one of its posts; pass "me" for the connected account. Post ID must belong to the thread (Get Post Thread lists them).',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ threadId: Property.ShortText({
+ displayName: 'Thread ID',
+ description: 'ID (26 characters) of the thread\'s root post. Use List Followed Threads or Get Post Thread to find it.',
+ required: true,
+ }),
+ postId: mattermostAiProps.postId({
+ required: true,
+ description: 'ID (26 characters) of the post in the thread to mark unread from. Use Get Post Thread to find it.',
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, threadId, postId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/threads/${encodeURIComponent(threadId)}/set_unread/${encodeURIComponent(postId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/threads/unfollow-thread.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/unfollow-thread.ts
new file mode 100644
index 00000000000..f4efb44ddc6
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/threads/unfollow-thread.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const unfollowThreadAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_unfollow_thread',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Unfollow Thread',
+ description: 'Stops following a thread for a user.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Makes a user stop following a thread so its replies no longer notify them; pass "me" for the connected account. Unfollowing a thread that is not followed changes nothing. Undo with Follow Thread.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ threadId: Property.ShortText({
+ displayName: 'Thread ID',
+ description: 'ID (26 characters) of the thread\'s root post. Use List Followed Threads or Get Post Thread to find it.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, teamId, threadId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/threads/${encodeURIComponent(threadId)}/following`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/create-user.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/create-user.ts
new file mode 100644
index 00000000000..9699b486c26
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/create-user.ts
@@ -0,0 +1,69 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateUserOutputSchema } from '../../../output-schemas';
+
+export const createUserAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_create_user',
+ outputSchema: mattermostCreateUserOutputSchema,
+ displayName: 'Create User',
+ description: 'Creates a user account that signs in with email and password.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a real user account that signs in with email and password. Needs a connection allowed to create users (open sign-up or a system admin). Not idempotent: a taken email or username fails.',
+ idempotent: false,
+ },
+ props: {
+ email: Property.ShortText({
+ displayName: 'Email',
+ description: 'Email address of the new user; must not be in use.',
+ required: true,
+ }),
+ username: Property.ShortText({
+ displayName: 'Username',
+ description: 'Unique username: lowercase letters, numbers, ".", "-" and "_", starting with a letter.',
+ required: true,
+ }),
+ password: Property.ShortText({
+ displayName: 'Password',
+ description: 'Password for email sign-in; must meet the server\'s password rules.',
+ required: true,
+ }),
+ firstName: Property.ShortText({
+ displayName: 'First Name',
+ description: 'First name of the user.',
+ required: false,
+ }),
+ lastName: Property.ShortText({
+ displayName: 'Last Name',
+ description: 'Last name of the user.',
+ required: false,
+ }),
+ nickname: Property.ShortText({
+ displayName: 'Nickname',
+ description: 'Nickname shown next to the username.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { email, username, password, firstName, lastName, nickname } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/users',
+ redactBodyInErrors: true,
+ body: {
+ email,
+ username,
+ password,
+ first_name: firstName,
+ last_name: lastName,
+ nickname,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/delete-draft.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/delete-draft.ts
new file mode 100644
index 00000000000..a001e76fd36
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/delete-draft.ts
@@ -0,0 +1,33 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const deleteDraftAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_delete_draft',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Delete Draft',
+ description: 'Deletes a user\'s draft in a channel.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Deletes a user\'s unsent channel draft for good; pass "me" for the connected account. For a draft reply in a thread use Delete Thread Draft. Needs synced drafts enabled on the server.',
+ idempotent: false,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ channelId: mattermostAiProps.channelId({ required: true }),
+ },
+ async run(context) {
+ const { userId, channelId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/users/${encodeURIComponent(userId)}/channels/${encodeURIComponent(channelId)}/drafts`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/delete-thread-draft.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/delete-thread-draft.ts
new file mode 100644
index 00000000000..8943683e10a
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/delete-thread-draft.ts
@@ -0,0 +1,38 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const deleteThreadDraftAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_delete_thread_draft',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Delete Thread Draft',
+ description: 'Deletes a user\'s draft reply in a thread.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Deletes a user\'s unsent draft reply in one thread for good; pass "me" for the connected account. Thread ID is the root_id of the draft from List Drafts. For a channel draft use Delete Draft.',
+ idempotent: false,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ channelId: mattermostAiProps.channelId({ required: true }),
+ threadId: mattermostAiProps.postId({
+ required: true,
+ displayName: 'Thread ID',
+ description: 'ID of the thread root post (26 characters), the draft\'s root_id from List Drafts.',
+ }),
+ },
+ async run(context) {
+ const { userId, channelId, threadId } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/users/${encodeURIComponent(userId)}/channels/${encodeURIComponent(channelId)}/drafts/${encodeURIComponent(threadId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-filtered-user-stats.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-filtered-user-stats.ts
new file mode 100644
index 00000000000..ab124e1878f
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-filtered-user-stats.ts
@@ -0,0 +1,84 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostGetFilteredUserStatsOutputSchema } from '../../../output-schemas';
+
+export const getFilteredUserStatsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_filtered_user_stats',
+ outputSchema: mattermostGetFilteredUserStatsOutputSchema,
+ displayName: 'Get Filtered User Count',
+ description: 'Counts the users matching filters.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns how many users match the filters: in a team or channel, with given roles, optionally counting bots and deactivated users. Needs a system admin connection. Team Roles needs In Team; Channel Roles needs In Channel.',
+ idempotent: true,
+ },
+ props: {
+ inTeam: mattermostAiProps.teamId({
+ required: false,
+ displayName: 'In Team',
+ description: 'Only count users in this team (team ID from List Teams or Get Team By Name).',
+ }),
+ inChannel: mattermostAiProps.channelId({
+ required: false,
+ displayName: 'In Channel',
+ description: 'Only count users in this channel (channel ID from Get Channel By Name or Search Channels).',
+ }),
+ includeDeleted: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Deactivated',
+ description: 'True to also count deactivated users.',
+ }),
+ includeBots: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Bots',
+ description: 'True to also count bot accounts.',
+ }),
+ roles: Property.ShortText({
+ displayName: 'System Roles',
+ description: 'Comma-separated system roles; counts users with any of them, e.g. "system_admin,system_user".',
+ required: false,
+ }),
+ teamRoles: Property.ShortText({
+ displayName: 'Team Roles',
+ description: 'Comma-separated team roles, e.g. "team_admin". Needs In Team.',
+ required: false,
+ }),
+ channelRoles: Property.ShortText({
+ displayName: 'Channel Roles',
+ description: 'Comma-separated channel roles, e.g. "channel_admin". Needs In Channel.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const includeDeleted = mattermostUtils.parseBoolean({ value: p.includeDeleted });
+ const includeBots = mattermostUtils.parseBoolean({ value: p.includeBots });
+ if (p.teamRoles && !p.inTeam) {
+ throw new Error('Team Roles needs In Team.');
+ }
+ if (p.channelRoles && !p.inChannel) {
+ throw new Error('Channel Roles needs In Channel.');
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/users/stats/filtered',
+ query: {
+ ...(p.inTeam ? { in_team: p.inTeam } : {}),
+ ...(p.inChannel ? { in_channel: p.inChannel } : {}),
+ ...(includeDeleted !== undefined ? { include_deleted: String(includeDeleted) } : {}),
+ ...(includeBots !== undefined ? { include_bots: String(includeBots) } : {}),
+ ...(p.roles ? { roles: p.roles } : {}),
+ ...(p.teamRoles ? { team_roles: p.teamRoles } : {}),
+ ...(p.channelRoles ? { channel_roles: p.channelRoles } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-server-limits.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-server-limits.ts
new file mode 100644
index 00000000000..1a609157778
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-server-limits.ts
@@ -0,0 +1,28 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetServerLimitsOutputSchema } from '../../../output-schemas';
+
+export const getServerLimitsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_server_limits',
+ outputSchema: mattermostGetServerLimitsOutputSchema,
+ displayName: 'Get Server Limits',
+ description: 'Gets the server\'s user limits and active user count.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the server\'s registered and active user counts and the user limits that apply to it. Needs a system admin connection.',
+ idempotent: true,
+ },
+ props: {},
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/limits/server',
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-by-email.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-by-email.ts
new file mode 100644
index 00000000000..692b7723784
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-by-email.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetUserByEmailOutputSchema } from '../../../output-schemas';
+
+export const getUserByEmailAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_user_by_email',
+ outputSchema: mattermostGetUserByEmailOutputSchema,
+ displayName: 'Get User By Email',
+ description: 'Gets a user by email address.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one user\'s profile, including the user ID other actions take, from their exact email address. Fails when the server hides emails from the connected user; Search Users matches part of an email.',
+ idempotent: true,
+ },
+ props: {
+ email: Property.ShortText({
+ displayName: 'Email',
+ description: 'Exact email address of the user.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/email/${encodeURIComponent(context.propsValue.email)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-by-username.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-by-username.ts
new file mode 100644
index 00000000000..7a81d04a56b
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-by-username.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetUserByEmailOutputSchema } from '../../../output-schemas';
+
+export const getUserByUsernameAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_user_by_username',
+ outputSchema: mattermostGetUserByEmailOutputSchema,
+ displayName: 'Get User By Username',
+ description: 'Gets a user by username.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one user\'s profile, including the user ID other actions take, from their exact username (without "@"). To match part of a name use Search Users.',
+ idempotent: true,
+ },
+ props: {
+ username: Property.ShortText({
+ displayName: 'Username',
+ description: 'Exact username without "@", e.g. "john.smith".',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/username/${encodeURIComponent(context.propsValue.username)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-default-image.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-default-image.ts
new file mode 100644
index 00000000000..369b572c825
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-default-image.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostDownloadFileOutputSchema } from '../../../output-schemas';
+
+export const getUserDefaultImageAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_user_default_image',
+ outputSchema: mattermostDownloadFileOutputSchema,
+ displayName: 'Get User Default Image',
+ description: 'Downloads a user\'s generated default profile picture.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Downloads the generated default profile picture (initials) of a user and returns it as a file, even if they uploaded their own. For the current picture use Get User Image.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ const { userId } = context.propsValue;
+ const download = await mattermostClient.download({
+ auth: context.auth,
+ path: `/users/${encodeURIComponent(userId)}/image/default`,
+ });
+ const fileName = download.fileName ?? `default-profile-${userId}.png`;
+ const file = await context.files.write({ fileName, data: download.data });
+ return { file, fileName, contentType: download.contentType, size: download.data.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-image.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-image.ts
new file mode 100644
index 00000000000..41908da47d2
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-image.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostDownloadFileOutputSchema } from '../../../output-schemas';
+
+export const getUserImageAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_user_image',
+ outputSchema: mattermostDownloadFileOutputSchema,
+ displayName: 'Get User Image',
+ description: 'Downloads a user\'s profile picture.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Downloads a user\'s current profile picture (the generated default if none was uploaded) and returns it as a file. For the generated default only use Get User Default Image.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ const { userId } = context.propsValue;
+ const download = await mattermostClient.download({
+ auth: context.auth,
+ path: `/users/${encodeURIComponent(userId)}/image`,
+ });
+ const fileName = download.fileName ?? `profile-${userId}.png`;
+ const file = await context.files.write({ fileName, data: download.data });
+ return { file, fileName, contentType: download.contentType, size: download.data.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-stats.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-stats.ts
new file mode 100644
index 00000000000..2c84272590f
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user-stats.ts
@@ -0,0 +1,28 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetFilteredUserStatsOutputSchema } from '../../../output-schemas';
+
+export const getUserStatsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_user_stats',
+ outputSchema: mattermostGetFilteredUserStatsOutputSchema,
+ displayName: 'Get User Count',
+ description: 'Gets the total number of users on the server.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns the total number of users on the server. To count only users in a team or channel or with given roles, or to choose whether bots and deactivated users count, use Get Filtered User Count.',
+ idempotent: true,
+ },
+ props: {},
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/users/stats',
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user.ts
new file mode 100644
index 00000000000..d7ad67d9ea7
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-user.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetUserOutputSchema } from '../../../output-schemas';
+
+export const getUserAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_user',
+ outputSchema: mattermostGetUserOutputSchema,
+ displayName: 'Get User',
+ description: 'Gets a user by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one user\'s profile by ID; pass "me" for the connected account. To look up by username or email use Get User By Username or Get User By Email.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(context.propsValue.userId)}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-users-by-ids.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-users-by-ids.ts
new file mode 100644
index 00000000000..b31b84c11cd
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-users-by-ids.ts
@@ -0,0 +1,43 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetUsersByIdsOutputSchema } from '../../../output-schemas';
+
+export const getUsersByIdsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_users_by_ids',
+ outputSchema: mattermostGetUsersByIdsOutputSchema,
+ displayName: 'Get Users By IDs',
+ description: 'Gets several users by their IDs.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the profiles of several users in one call from their IDs; unknown IDs are left out. For one user use Get User, for usernames use Get Users By Usernames.',
+ idempotent: true,
+ },
+ props: {
+ userIds: Property.Array({
+ displayName: 'User IDs',
+ description: 'User IDs (26 characters each), e.g. from List Users, Search Users or List Known Users.',
+ required: true,
+ }),
+ since: Property.Number({
+ displayName: 'Modified Since',
+ description: 'Only return users changed after this Unix time in milliseconds.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { userIds, since } = context.propsValue;
+ const users = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/users/ids',
+ query: since !== undefined && since !== null ? { since: String(since) } : undefined,
+ body: userIds,
+ });
+ return { users, count: users.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-users-by-usernames.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-users-by-usernames.ts
new file mode 100644
index 00000000000..8dddbcdf8ee
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/get-users-by-usernames.ts
@@ -0,0 +1,36 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostGetUsersByIdsOutputSchema } from '../../../output-schemas';
+
+export const getUsersByUsernamesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_get_users_by_usernames',
+ outputSchema: mattermostGetUsersByIdsOutputSchema,
+ displayName: 'Get Users By Usernames',
+ description: 'Gets several users by their usernames.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the profiles of several users in one call from their usernames (without "@"); unknown usernames are left out. For one user use Get User By Username.',
+ idempotent: true,
+ },
+ props: {
+ usernames: Property.Array({
+ displayName: 'Usernames',
+ description: 'Usernames without "@", e.g. "john.smith".',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const users = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/users/usernames',
+ body: context.propsValue.usernames,
+ });
+ return { users, count: users.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-drafts.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-drafts.ts
new file mode 100644
index 00000000000..0862a29c82f
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-drafts.ts
@@ -0,0 +1,34 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListDraftsOutputSchema } from '../../../output-schemas';
+
+export const listDraftsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_drafts',
+ outputSchema: mattermostListDraftsOutputSchema,
+ displayName: 'List Drafts',
+ description: 'Lists a user\'s saved drafts in a team.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns every unsent message draft a user has saved in a team\'s channels and threads; pass "me" for the connected account. Needs synced drafts enabled on the server.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ teamId: mattermostAiProps.teamId({ required: true }),
+ },
+ async run(context) {
+ const { userId, teamId } = context.propsValue;
+ const drafts = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/teams/${encodeURIComponent(teamId)}/drafts`,
+ });
+ return { drafts, count: drafts.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-group-channel-users.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-group-channel-users.ts
new file mode 100644
index 00000000000..ebd73d48a92
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-group-channel-users.ts
@@ -0,0 +1,35 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListGroupChannelUsersOutputSchema } from '../../../output-schemas';
+
+export const listGroupChannelUsersAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_group_channel_users',
+ outputSchema: mattermostListGroupChannelUsersOutputSchema,
+ displayName: 'List Group Message Members',
+ description: 'Lists the members of group message channels.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the members of each given group message channel, keyed by channel ID. Channels the connected user is not a member of are left out. Group message channel IDs come from List User Channels.',
+ idempotent: true,
+ },
+ props: {
+ channelIds: Property.Array({
+ displayName: 'Group Channel IDs',
+ description: 'IDs (26 characters each) of group message channels (type "G").',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/users/group_channels',
+ body: context.propsValue.channelIds,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-known-users.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-known-users.ts
new file mode 100644
index 00000000000..c47fa5ce84b
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-known-users.ts
@@ -0,0 +1,29 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostClient } from '../../../common/client';
+import { mattermostListKnownUsersOutputSchema } from '../../../output-schemas';
+
+export const listKnownUsersAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_known_users',
+ outputSchema: mattermostListKnownUsersOutputSchema,
+ displayName: 'List Known Users',
+ description: 'Lists the IDs of users the connected user shares a channel with.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns the IDs of every user who shares any channel (including direct and group messages) with the connected account. Pass them to Get Users By IDs for profiles.',
+ idempotent: true,
+ },
+ props: {},
+ async run(context) {
+ const userIds = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/users/known',
+ });
+ return { userIds, count: userIds.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-user-channel-memberships.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-user-channel-memberships.ts
new file mode 100644
index 00000000000..b1b3c1f0e09
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-user-channel-memberships.ts
@@ -0,0 +1,37 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostListUserChannelMembershipsOutputSchema } from '../../../output-schemas';
+
+export const listUserChannelMembershipsAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_user_channel_memberships',
+ outputSchema: mattermostListUserChannelMembershipsOutputSchema,
+ displayName: 'List User Channel Memberships',
+ description: 'Lists a user\'s channel memberships across all teams.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns one page of a user\'s channel memberships across every team, with their channel roles, unread and mention counts and notification settings; pass "me" for the connected account. Another user needs permission to edit other users. For the channels themselves use List User Channels.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const { userId, page, perPage } = context.propsValue;
+ const channelMembers = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: `/users/${encodeURIComponent(userId)}/channel_members`,
+ query: mattermostUtils.paging({ page, perPage }),
+ });
+ return { channelMembers, count: channelMembers.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-users.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-users.ts
new file mode 100644
index 00000000000..631b427eeaf
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/list-users.ts
@@ -0,0 +1,141 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostGetUsersByIdsOutputSchema } from '../../../output-schemas';
+
+export const listUsersAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_list_users',
+ outputSchema: mattermostGetUsersByIdsOutputSchema,
+ displayName: 'List Users',
+ description: 'Lists users, optionally filtered by team, channel, role or state.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Returns one page of users, optionally only those in or not in a team or channel, without a team, active or deactivated, or with given roles. To match a name or email use Search Users. Not In Team cannot be combined with In Team; Channel Roles and sort "status" need In Channel; Team Roles and sorts "last_activity_at" / "create_at" need In Team.',
+ idempotent: true,
+ },
+ props: {
+ inTeam: mattermostAiProps.teamId({
+ required: false,
+ displayName: 'In Team',
+ description: 'Only users in this team (team ID from List Teams or Get Team By Name).',
+ }),
+ notInTeam: mattermostAiProps.teamId({
+ required: false,
+ displayName: 'Not In Team',
+ description: 'Only users not in this team (team ID). Cannot be used with In Team.',
+ }),
+ inChannel: mattermostAiProps.channelId({
+ required: false,
+ displayName: 'In Channel',
+ description: 'Only users in this channel (channel ID from Get Channel By Name or Search Channels).',
+ }),
+ notInChannel: mattermostAiProps.channelId({
+ required: false,
+ displayName: 'Not In Channel',
+ description: 'Only users not in this channel (channel ID). Pass the channel\'s team as In Team.',
+ }),
+ withoutTeam: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Without Team',
+ description: 'True for only users that are on no team; overrides the team and channel filters.',
+ }),
+ active: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Active Only',
+ description: 'True for only active users. Cannot be true together with Deactivated Only.',
+ }),
+ inactive: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Deactivated Only',
+ description: 'True for only deactivated users. Cannot be true together with Active Only.',
+ }),
+ roles: Property.ShortText({
+ displayName: 'System Roles',
+ description: 'Comma-separated system roles; matches users with any of them, e.g. "system_admin,system_user".',
+ required: false,
+ }),
+ teamRoles: Property.ShortText({
+ displayName: 'Team Roles',
+ description: 'Comma-separated team roles, e.g. "team_admin" or "team_user". Needs In Team.',
+ required: false,
+ }),
+ channelRoles: Property.ShortText({
+ displayName: 'Channel Roles',
+ description: 'Comma-separated channel roles, e.g. "channel_admin" or "channel_user". Needs In Channel.',
+ required: false,
+ }),
+ sort: Property.StaticDropdown({
+ displayName: 'Sort',
+ description:
+ 'Defaults to username. "last_activity_at" or "create_at" need In Team; "status" needs In Channel.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Last Activity', value: 'last_activity_at' },
+ { label: 'Created', value: 'create_at' },
+ { label: 'Status', value: 'status' },
+ ],
+ },
+ }),
+ page: mattermostAiProps.page({ required: false }),
+ perPage: mattermostAiProps.perPage({ required: false }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const withoutTeam = mattermostUtils.parseBoolean({ value: p.withoutTeam });
+ const active = mattermostUtils.parseBoolean({ value: p.active });
+ const inactive = mattermostUtils.parseBoolean({ value: p.inactive });
+ if (p.inTeam && p.notInTeam) {
+ throw new Error('Not In Team cannot be used together with In Team.');
+ }
+ if (p.channelRoles && !p.inChannel) {
+ throw new Error('Channel Roles needs In Channel.');
+ }
+ if (p.teamRoles && !p.inTeam) {
+ throw new Error('Team Roles needs In Team.');
+ }
+ if (active === true && inactive === true) {
+ throw new Error('Active Only and Deactivated Only cannot both be true.');
+ }
+ if (p.sort !== undefined && p.sort !== null && p.sort !== '') {
+ if (!SORTS.includes(p.sort)) {
+ throw new Error(`Sort must be one of ${SORTS.join(', ')}, got "${p.sort}".`);
+ }
+ if (p.sort === 'status' && !p.inChannel) {
+ throw new Error('Sort "status" needs In Channel.');
+ }
+ if (p.sort !== 'status' && !p.inTeam) {
+ throw new Error(`Sort "${p.sort}" needs In Team.`);
+ }
+ }
+ const users = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.GET,
+ path: '/users',
+ query: {
+ ...mattermostUtils.paging({ page: p.page, perPage: p.perPage }),
+ ...(p.inTeam ? { in_team: p.inTeam } : {}),
+ ...(p.notInTeam ? { not_in_team: p.notInTeam } : {}),
+ ...(p.inChannel ? { in_channel: p.inChannel } : {}),
+ ...(p.notInChannel ? { not_in_channel: p.notInChannel } : {}),
+ ...(withoutTeam !== undefined ? { without_team: String(withoutTeam) } : {}),
+ ...(active !== undefined ? { active: String(active) } : {}),
+ ...(inactive !== undefined ? { inactive: String(inactive) } : {}),
+ ...(p.roles ? { roles: p.roles } : {}),
+ ...(p.teamRoles ? { team_roles: p.teamRoles } : {}),
+ ...(p.channelRoles ? { channel_roles: p.channelRoles } : {}),
+ ...(p.sort ? { sort: p.sort } : {}),
+ },
+ });
+ return { users, count: users.length };
+ },
+});
+
+const SORTS = ['last_activity_at', 'create_at', 'status'];
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/patch-user.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/patch-user.ts
new file mode 100644
index 00000000000..f1e291d3593
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/patch-user.ts
@@ -0,0 +1,76 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostCreateUserOutputSchema } from '../../../output-schemas';
+
+export const patchUserAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_patch_user',
+ outputSchema: mattermostCreateUserOutputSchema,
+ displayName: 'Update User',
+ description: 'Updates fields of a user\'s profile.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Changes only the profile fields given (email, username, names, nickname, position, locale) and leaves the rest. Updating another user needs permission to edit other users. For roles use Update User Roles, for the picture Set User Image.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ email: Property.ShortText({
+ displayName: 'Email',
+ description: 'New email address.',
+ required: false,
+ }),
+ username: Property.ShortText({
+ displayName: 'Username',
+ description: 'New unique username: lowercase letters, numbers, ".", "-" and "_".',
+ required: false,
+ }),
+ firstName: Property.ShortText({
+ displayName: 'First Name',
+ description: 'New first name.',
+ required: false,
+ }),
+ lastName: Property.ShortText({
+ displayName: 'Last Name',
+ description: 'New last name.',
+ required: false,
+ }),
+ nickname: Property.ShortText({
+ displayName: 'Nickname',
+ description: 'New nickname.',
+ required: false,
+ }),
+ position: Property.ShortText({
+ displayName: 'Position',
+ description: 'New job title or position.',
+ required: false,
+ }),
+ locale: Property.ShortText({
+ displayName: 'Locale',
+ description: 'New interface language code, e.g. "en" or "de".',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { userId, email, username, firstName, lastName, nickname, position, locale } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/users/${encodeURIComponent(userId)}/patch`,
+ body: {
+ ...(email !== undefined ? { email } : {}),
+ ...(username !== undefined ? { username } : {}),
+ ...(firstName !== undefined ? { first_name: firstName } : {}),
+ ...(lastName !== undefined ? { last_name: lastName } : {}),
+ ...(nickname !== undefined ? { nickname } : {}),
+ ...(position !== undefined ? { position } : {}),
+ ...(locale !== undefined ? { locale } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/reset-user-image.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/reset-user-image.ts
new file mode 100644
index 00000000000..6201a85ca28
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/reset-user-image.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const resetUserImageAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_reset_user_image',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Reset User Image',
+ description: 'Deletes a user\'s uploaded profile picture.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Deletes a user\'s uploaded profile picture so the generated default shows again; the uploaded image cannot be recovered. Resetting another user needs permission to edit other users.',
+ idempotent: false,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ },
+ async run(context) {
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.DELETE,
+ path: `/users/${encodeURIComponent(context.propsValue.userId)}/image`,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/search-users.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/search-users.ts
new file mode 100644
index 00000000000..2681fcd063e
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/search-users.ts
@@ -0,0 +1,85 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostGetUsersByIdsOutputSchema } from '../../../output-schemas';
+
+export const searchUsersAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_search_users',
+ outputSchema: mattermostGetUsersByIdsOutputSchema,
+ displayName: 'Search Users',
+ description: 'Searches users by username, name, nickname or email.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Finds users whose username, full name, nickname or email match a term, optionally only in or not in a team or channel. Use it to find a user ID for other actions. Not In Channel needs Team ID.',
+ idempotent: true,
+ },
+ props: {
+ term: Property.ShortText({
+ displayName: 'Term',
+ description: 'Text to match against username, full name, nickname and email.',
+ required: true,
+ }),
+ teamId: mattermostAiProps.teamId({
+ required: false,
+ description: 'Only users on this team (team ID from List Teams or Get Team By Name).',
+ }),
+ notInTeamId: mattermostAiProps.teamId({
+ required: false,
+ displayName: 'Not In Team',
+ description: 'Only users not on this team (team ID).',
+ }),
+ inChannelId: mattermostAiProps.channelId({
+ required: false,
+ displayName: 'In Channel',
+ description: 'Only users in this channel (channel ID from Get Channel By Name or Search Channels).',
+ }),
+ notInChannelId: mattermostAiProps.channelId({
+ required: false,
+ displayName: 'Not In Channel',
+ description: 'Only users not in this channel (channel ID). Needs Team ID.',
+ }),
+ withoutTeam: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Without Team',
+ description: 'True for only users on no team; overrides the team and channel filters.',
+ }),
+ allowInactive: mattermostAiProps.booleanFlag({
+ required: false,
+ displayName: 'Include Deactivated',
+ description: 'True to also return deactivated users.',
+ }),
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'Maximum users to return, 1 to 1000. Defaults to 100.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ if (p.notInChannelId && !p.teamId) {
+ throw new Error('Not In Channel needs Team ID.');
+ }
+ const users = await mattermostClient.request<unknown[]>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/users/search',
+ body: {
+ term: p.term,
+ team_id: p.teamId,
+ not_in_team_id: p.notInTeamId,
+ in_channel_id: p.inChannelId,
+ not_in_channel_id: p.notInChannelId,
+ without_team: mattermostUtils.parseBoolean({ value: p.withoutTeam }),
+ allow_inactive: mattermostUtils.parseBoolean({ value: p.allowInactive }),
+ limit: Math.min(Math.max(p.limit ?? 100, 1), 1000),
+ },
+ });
+ return { users, count: users.length };
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/set-user-active.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/set-user-active.ts
new file mode 100644
index 00000000000..3728ae69c9d
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/set-user-active.ts
@@ -0,0 +1,39 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUtils } from '../../../common/utils';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const setUserActiveAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_set_user_active',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Activate or Deactivate User',
+ description: 'Deactivates or reactivates a user account.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Deactivates a user (Active false: they are signed out and cannot sign in) or reactivates them (Active true); the account and its content are kept. Users can deactivate themselves; anything else needs a system admin connection.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ active: mattermostAiProps.booleanFlag({
+ required: true,
+ displayName: 'Active',
+ description: 'True to reactivate the user, false to deactivate them.',
+ }),
+ },
+ async run(context) {
+ const { userId, active } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/users/${encodeURIComponent(userId)}/active`,
+ body: { active: mattermostUtils.parseBoolean({ value: active }) },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/set-user-image.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/set-user-image.ts
new file mode 100644
index 00000000000..9fa39893d8f
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/set-user-image.ts
@@ -0,0 +1,40 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const setUserImageAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_set_user_image',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Set User Image',
+ description: 'Uploads a new profile picture for a user.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Replaces a user\'s profile picture with the given image (PNG, JPEG, GIF or BMP). Setting another user\'s picture needs permission to edit other users. To go back to the generated default use Reset User Image.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ image: Property.File({
+ displayName: 'Image',
+ description: 'Image file (PNG, JPEG, GIF or BMP) to use as the profile picture.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const { userId, image } = context.propsValue;
+ const form = new FormData();
+ form.append('image', new Blob([new Uint8Array(image.data)]), image.filename);
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: `/users/${encodeURIComponent(userId)}/image`,
+ body: form,
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/update-user-roles.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/update-user-roles.ts
new file mode 100644
index 00000000000..369344832cf
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/update-user-roles.ts
@@ -0,0 +1,50 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostArchiveChannelOutputSchema } from '../../../output-schemas';
+
+export const updateUserRolesAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_update_user_roles',
+ outputSchema: mattermostArchiveChannelOutputSchema,
+ displayName: 'Update User Roles',
+ description: 'Sets a user\'s system roles.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Replaces a user\'s system roles: "system_user" for a regular member or "system_user system_admin" to make them a system admin. Needs a connection allowed to manage roles. Team and channel roles are not changed.',
+ idempotent: true,
+ },
+ props: {
+ userId: mattermostAiProps.userId({ required: true }),
+ roles: Property.StaticDropdown({
+ displayName: 'Roles',
+ description: '"system_user" for a regular member, "system_user system_admin" for a system admin.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Member', value: 'system_user' },
+ { label: 'System Admin', value: 'system_user system_admin' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ const { userId, roles } = context.propsValue;
+ if (!ROLES.includes(roles)) {
+ throw new Error(`Roles must be one of ${ROLES.map((role) => `"${role}"`).join(', ')}, got "${roles}".`);
+ }
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.PUT,
+ path: `/users/${encodeURIComponent(userId)}/roles`,
+ body: { roles },
+ });
+ },
+});
+
+const ROLES = ['system_user', 'system_user system_admin'];
diff --git a/packages/pieces/community/mattermost/src/lib/actions/ai/users/upsert-draft.ts b/packages/pieces/community/mattermost/src/lib/actions/ai/users/upsert-draft.ts
new file mode 100644
index 00000000000..40c37fd93c3
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/actions/ai/users/upsert-draft.ts
@@ -0,0 +1,53 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { mattermostAuth } from '../../../auth';
+import { mattermostAiProps } from '../../../common/ai-props';
+import { mattermostClient } from '../../../common/client';
+import { mattermostUpsertDraftOutputSchema } from '../../../output-schemas';
+
+export const upsertDraftAction = createAction({
+ auth: mattermostAuth,
+ name: 'mattermost_upsert_draft',
+ outputSchema: mattermostUpsertDraftOutputSchema,
+ displayName: 'Save Draft',
+ description: 'Creates or replaces the connected user\'s draft in a channel or thread.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Saves an unsent message draft for the connected user in a channel, or in a thread when Root ID is set, replacing the draft already there. Needs synced drafts enabled on the server. To post the message use Create Post.',
+ idempotent: true,
+ },
+ props: {
+ channelId: mattermostAiProps.channelId({ required: true }),
+ message: Property.LongText({
+ displayName: 'Message',
+ description: 'Draft text, in Markdown.',
+ required: true,
+ }),
+ rootId: mattermostAiProps.postId({
+ required: false,
+ displayName: 'Root ID',
+ description: 'ID of the thread root post, for a draft reply. Leave empty for a channel draft.',
+ }),
+ fileIds: Property.Array({
+ displayName: 'File IDs',
+ description: 'Up to 10 file IDs from Upload File, uploaded to the same channel.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const { channelId, message, rootId, fileIds } = context.propsValue;
+ return await mattermostClient.request<unknown>({
+ auth: context.auth,
+ method: HttpMethod.POST,
+ path: '/drafts',
+ body: {
+ channel_id: channelId,
+ message,
+ root_id: rootId,
+ file_ids: fileIds && fileIds.length > 0 ? fileIds : undefined,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/actions/send-message.ts b/packages/pieces/community/mattermost/src/lib/actions/send-message.ts
index 5ac9a636bb7..c86e6d7ca1c 100644
--- a/packages/pieces/community/mattermost/src/lib/actions/send-message.ts
+++ b/packages/pieces/community/mattermost/src/lib/actions/send-message.ts
@@ -1,20 +1,17 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import {
- AuthenticationType,
- httpClient,
- HttpError,
- HttpMethod,
-} from '@activepieces/pieces-common';
-import { mattermostAuth } from '../..';
+import { HttpError, HttpMethod } from '@activepieces/pieces-common';
+import { mattermostAuth } from '../auth';
+import { mattermostClient } from '../common/client';
+import { mattermostSendMessageOutputSchema } from '../output-schemas';
-export const sendMessage = createAction({
+export const sendMessageAction = createAction({
auth: mattermostAuth,
name: 'send_message',
+ outputSchema: mattermostSendMessageOutputSchema,
classification: 'WRITE',
displayName: 'Send Message',
description: 'Send a message to a Mattermost channel',
- audience: 'both',
- aiMetadata: { description: 'Post a new text message to a Mattermost channel, identified by its channel ID (not name). Use when an agent needs to notify or post into a specific channel. Not idempotent: each call creates a separate post, so repeating it sends duplicate messages.', idempotent: false },
+ audience: 'human',
props: {
channel_id: Property.ShortText({
displayName: 'Channel ID',
@@ -29,30 +26,21 @@ export const sendMessage = createAction({
}),
},
async run(context) {
- // Remove trailing slash from workspace URL
- const baseUrl = context.auth.props.workspace_url.replace(/\/$/, '');
try {
- return await httpClient.sendRequest({
- url: `${baseUrl}/api/v4/posts`,
+ return await mattermostClient.send<unknown>({
+ auth: context.auth,
method: HttpMethod.POST,
- authentication: {
- type: AuthenticationType.BEARER_TOKEN,
- token: context.auth.props.token,
- },
+ path: '/posts',
body: {
channel_id: context.propsValue.channel_id,
message: context.propsValue.text,
},
});
- } catch (e: HttpError | unknown) {
- if (e instanceof HttpError) {
- const httpError = e as HttpError;
- console.log(httpError);
- if (httpError?.response.status === 403) {
- throw new Error(
- 'Please make sure you have the correct bot token and channel ID.'
- );
- }
+ } catch (e) {
+ if (e instanceof HttpError && e.response.status === 403) {
+ throw new Error(
+ 'Please make sure you have the correct bot token and channel ID.'
+ );
}
throw e;
}
diff --git a/packages/pieces/community/mattermost/src/lib/auth.ts b/packages/pieces/community/mattermost/src/lib/auth.ts
new file mode 100644
index 00000000000..54538ab9ffa
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/auth.ts
@@ -0,0 +1,23 @@
+import { PieceAuth, Property } from '@activepieces/pieces-framework';
+
+export const mattermostAuth = PieceAuth.CustomAuth({
+ description: `
+**Workspace URL**: The url of mattermost instance (e.g \`https://activepieces.mattermost.com\`)
+
+**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account
+`,
+ required: true,
+ props: {
+ workspace_url: Property.ShortText({
+ displayName: 'Workspace URL',
+ description:
+ 'The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)',
+ required: true,
+ }),
+ token: Property.ShortText({
+ displayName: 'Bot Token',
+ description: 'The bot token to use to authenticate',
+ required: true,
+ }),
+ },
+});
diff --git a/packages/pieces/community/mattermost/src/lib/common/ai-props.ts b/packages/pieces/community/mattermost/src/lib/common/ai-props.ts
new file mode 100644
index 00000000000..be81a1bc1f6
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/common/ai-props.ts
@@ -0,0 +1,84 @@
+import { Property } from '@activepieces/pieces-framework';
+
+function userId<R extends boolean>({
+ required,
+ displayName = 'User ID',
+ description = 'User ID (26 characters), or "me" for the connected account. Use Get User By Username or Search Users to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function teamId<R extends boolean>({
+ required,
+ displayName = 'Team ID',
+ description = 'Team ID (26 characters). Use List Teams or Get Team By Name to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function channelId<R extends boolean>({
+ required,
+ displayName = 'Channel ID',
+ description = 'Channel ID (26 characters). Use Get Channel By Name, Search Channels or List User Channels to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function postId<R extends boolean>({
+ required,
+ displayName = 'Post ID',
+ description = 'Post ID (26 characters). Use List Channel Posts, Search Posts or Create Post to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function page<R extends boolean>({
+ required,
+ displayName = 'Page',
+ description = 'Zero-based page number. Defaults to 0.',
+}: PropParams<R>) {
+ return Property.Number({ displayName, description, required });
+}
+
+function perPage<R extends boolean>({
+ required,
+ displayName = 'Per Page',
+ description = 'Items per page, 1 to 200. Defaults to 60.',
+}: PropParams<R>) {
+ return Property.Number({ displayName, description, required });
+}
+
+function booleanFlag<R extends boolean>({
+ required,
+ displayName,
+ description,
+}: PropParams<R> & { displayName: string }) {
+ return Property.StaticDropdown({
+ displayName,
+ description,
+ required,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'True', value: 'true' },
+ { label: 'False', value: 'false' },
+ ],
+ },
+ });
+}
+
+export const mattermostAiProps = {
+ userId,
+ teamId,
+ channelId,
+ postId,
+ page,
+ perPage,
+ booleanFlag,
+};
+
+export type PropParams<R extends boolean> = {
+ required: R;
+ displayName?: string;
+ description?: string;
+};
diff --git a/packages/pieces/community/mattermost/src/lib/common/api.ts b/packages/pieces/community/mattermost/src/lib/common/api.ts
new file mode 100644
index 00000000000..d2af60913c2
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/common/api.ts
@@ -0,0 +1,13 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { mattermostClient } from './client';
+import type { MattermostAuthValue, MattermostUser } from './types';
+
+async function getMe({ auth }: { auth: MattermostAuthValue }): Promise<MattermostUser> {
+ return await mattermostClient.request<MattermostUser>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/users/me',
+ });
+}
+
+export const mattermostApi = { getMe };
diff --git a/packages/pieces/community/mattermost/src/lib/common/client.ts b/packages/pieces/community/mattermost/src/lib/common/client.ts
new file mode 100644
index 00000000000..56e131587c0
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/common/client.ts
@@ -0,0 +1,105 @@
+import {
+ AuthenticationType,
+ HttpHeaders,
+ HttpMethod,
+ HttpResponse,
+ httpClient,
+ QueryParams,
+} from '@activepieces/pieces-common';
+import type { MattermostAuthValue } from './types';
+
+function baseUrl({ auth }: { auth: MattermostAuthValue }): string {
+ return `${auth.props.workspace_url.replace(/\/$/, '')}/api/v4`;
+}
+
+async function send<T>({
+ auth,
+ method,
+ path,
+ query,
+ body,
+ headers,
+ redactBodyInErrors,
+}: RequestParams & { auth: MattermostAuthValue }): Promise<HttpResponse<T>> {
+ return await httpClient.sendRequest<T>({
+ method,
+ url: `${baseUrl({ auth })}${path}`,
+ authentication: {
+ type: AuthenticationType.BEARER_TOKEN,
+ token: auth.props.token,
+ },
+ headers,
+ queryParams: query,
+ body,
+ redactBodyInErrors,
+ });
+}
+
+async function request<T>(params: RequestParams & { auth: MattermostAuthValue }): Promise<T> {
+ const response = await send<T>(params);
+ return response.body;
+}
+
+async function download({
+ auth,
+ path,
+ query,
+}: DownloadParams & { auth: MattermostAuthValue }): Promise<MattermostDownload> {
+ const response = await httpClient.sendRequest<ArrayBuffer>({
+ method: HttpMethod.GET,
+ url: `${baseUrl({ auth })}${path}`,
+ authentication: {
+ type: AuthenticationType.BEARER_TOKEN,
+ token: auth.props.token,
+ },
+ queryParams: query,
+ responseType: 'arraybuffer',
+ });
+ const contentType = response.headers?.['content-type'];
+ const disposition = response.headers?.['content-disposition'];
+ return {
+ data: Buffer.from(response.body),
+ contentType: typeof contentType === 'string' ? contentType : undefined,
+ fileName: fileNameFromDisposition({
+ disposition: typeof disposition === 'string' ? disposition : undefined,
+ }),
+ };
+}
+
+function fileNameFromDisposition({
+ disposition,
+}: {
+ disposition: string | undefined;
+}): string | undefined {
+ if (!disposition) {
+ return undefined;
+ }
+ const encoded = /filename\*=UTF-8''([^;]+)/i.exec(disposition);
+ if (encoded) {
+ return decodeURIComponent(encoded[1]);
+ }
+ const plain = /filename="?([^";]+)"?/i.exec(disposition);
+ return plain ? plain[1] : undefined;
+}
+
+export const mattermostClient = { baseUrl, send, request, download };
+
+type RequestParams = {
+ method: HttpMethod;
+ path: string;
+ query?: QueryParams;
+ body?: unknown;
+ headers?: HttpHeaders;
+ redactBodyInErrors?: boolean;
+};
+
+type DownloadParams = {
+ path: string;
+ query?: QueryParams;
+};
+
+type MattermostDownload = {
+ data: Buffer;
+ contentType: string | undefined;
+ fileName: string | undefined;
+};
diff --git a/packages/pieces/community/mattermost/src/lib/common/types.ts b/packages/pieces/community/mattermost/src/lib/common/types.ts
new file mode 100644
index 00000000000..4c961dce0b7
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/common/types.ts
@@ -0,0 +1,8 @@
+import type { AppConnectionType } from '@activepieces/pieces-framework';
+
+export type MattermostAuthValue = {
+ type: AppConnectionType.CUSTOM_AUTH;
+ props: { workspace_url: string; token: string };
+};
+
+export type MattermostUser = { id: string; username: string };
diff --git a/packages/pieces/community/mattermost/src/lib/common/utils.ts b/packages/pieces/community/mattermost/src/lib/common/utils.ts
new file mode 100644
index 00000000000..185b2a1e321
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/common/utils.ts
@@ -0,0 +1,27 @@
+function parseBoolean({ value }: { value: string | undefined }): boolean | undefined {
+ if (value === undefined || value === '') {
+ return undefined;
+ }
+ if (value !== 'true' && value !== 'false') {
+ throw new Error(`Expected "true" or "false", got "${value}".`);
+ }
+ return value === 'true';
+}
+
+function paging({
+ page,
+ perPage,
+}: {
+ page: number | undefined;
+ perPage: number | undefined;
+}): Record<string, string> {
+ return {
+ page: String(page ?? 0),
+ per_page: String(Math.min(Math.max(perPage ?? DEFAULT_PER_PAGE, 1), MAX_PER_PAGE)),
+ };
+}
+
+export const mattermostUtils = { parseBoolean, paging };
+
+const DEFAULT_PER_PAGE = 60;
+const MAX_PER_PAGE = 200;
diff --git a/packages/pieces/community/mattermost/src/lib/output-schemas.ts b/packages/pieces/community/mattermost/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..cf802540ac5
--- /dev/null
+++ b/packages/pieces/community/mattermost/src/lib/output-schemas.ts
@@ -0,0 +1,957 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+const countField: OutputSchema['fields'][number] = { key: 'count', label: 'Count', format: 'number' };
+
+const userNotifyPropsFields: OutputSchema['fields'] = [
+ { key: 'channel', label: 'Channel Mentions' },
+ { key: 'channel_mention_auto_follow_threads', label: 'Auto Follow Threads On Channel Mention' },
+ { key: 'comments', label: 'Comment Notifications' },
+ { key: 'desktop', label: 'Desktop Notifications' },
+ { key: 'desktop_sound', label: 'Desktop Sound' },
+ { key: 'desktop_threads', label: 'Desktop Thread Notifications' },
+ { key: 'email', label: 'Email Notifications' },
+ { key: 'email_threads', label: 'Email Thread Notifications' },
+ { key: 'first_name', label: 'Notify On First Name' },
+ { key: 'mention_keys', label: 'Mention Keys' },
+ { key: 'push', label: 'Push Notifications' },
+ { key: 'push_status', label: 'Push Status' },
+ { key: 'push_threads', label: 'Push Thread Notifications' },
+];
+
+const timezoneFields: OutputSchema['fields'] = [
+ { key: 'automaticTimezone', label: 'Automatic Timezone' },
+ { key: 'manualTimezone', label: 'Manual Timezone' },
+ { key: 'useAutomaticTimezone', label: 'Use Automatic Timezone' },
+];
+
+const userCoreFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'User ID' },
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'username', label: 'Username' },
+ { key: 'auth_service', label: 'Auth Service' },
+ { key: 'email', label: 'Email', format: 'email' },
+ { key: 'nickname', label: 'Nickname' },
+ { key: 'first_name', label: 'First Name' },
+ { key: 'last_name', label: 'Last Name' },
+ { key: 'position', label: 'Position' },
+ { key: 'roles', label: 'Roles' },
+ { key: 'notify_props', label: 'Notification Settings', children: userNotifyPropsFields },
+ { key: 'locale', label: 'Locale' },
+ { key: 'timezone', label: 'Timezone', children: timezoneFields },
+ { key: 'disable_welcome_email', label: 'Welcome Email Disabled', format: 'boolean' },
+];
+
+const passwordUpdatedField: OutputSchema['fields'][number] = {
+ key: 'last_password_update',
+ label: 'Password Last Updated',
+ format: 'datetime',
+};
+
+const pictureUpdatedField: OutputSchema['fields'][number] = {
+ key: 'last_picture_update',
+ label: 'Picture Last Updated',
+ format: 'datetime',
+};
+
+const userFields: OutputSchema['fields'] = [
+ ...userCoreFields,
+ { key: 'remote_id', label: 'Remote ID' },
+];
+
+const threadParticipantFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'User ID' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'username', label: 'Username' },
+ { key: 'auth_data', label: 'Auth Data' },
+ { key: 'auth_service', label: 'Auth Service' },
+ { key: 'email', label: 'Email', format: 'email' },
+ { key: 'nickname', label: 'Nickname' },
+ { key: 'first_name', label: 'First Name' },
+ { key: 'last_name', label: 'Last Name' },
+ { key: 'position', label: 'Position' },
+ { key: 'roles', label: 'Roles' },
+ { key: 'locale', label: 'Locale' },
+ { key: 'timezone', label: 'Timezone' },
+ { key: 'disable_welcome_email', label: 'Welcome Email Disabled', format: 'boolean' },
+];
+
+const channelFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Channel ID' },
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'team_id', label: 'Team ID' },
+ { key: 'type', label: 'Type' },
+ { key: 'display_name', label: 'Display Name' },
+ { key: 'name', label: 'Name' },
+ { key: 'header', label: 'Header' },
+ { key: 'purpose', label: 'Purpose' },
+ { key: 'last_post_at', label: 'Last Post At', format: 'datetime' },
+ { key: 'total_msg_count', label: 'Total Message Count', format: 'number' },
+ { key: 'extra_update_at', label: 'Extra Updated At', format: 'datetime' },
+ { key: 'creator_id', label: 'Creator ID' },
+ { key: 'scheme_id', label: 'Scheme ID' },
+ { key: 'props', label: 'Props' },
+ { key: 'group_constrained', label: 'Group Constrained', format: 'boolean' },
+ { key: 'autotranslation', label: 'Autotranslation', format: 'boolean' },
+ { key: 'shared', label: 'Shared', format: 'boolean' },
+ { key: 'total_msg_count_root', label: 'Total Root Message Count', format: 'number' },
+ { key: 'policy_id', label: 'Policy ID' },
+ { key: 'last_root_post_at', label: 'Last Root Post At', format: 'datetime' },
+ { key: 'banner_info', label: 'Banner Info' },
+ { key: 'policy_enforced', label: 'Policy Enforced', format: 'boolean' },
+ { key: 'policy_auto_add', label: 'Policy Auto Add', format: 'boolean' },
+ { key: 'policy_is_active', label: 'Policy Is Active', format: 'boolean' },
+ { key: 'default_category_name', label: 'Default Category Name' },
+ { key: 'managed_category_name', label: 'Managed Category Name' },
+ { key: 'discoverable', label: 'Discoverable', format: 'boolean' },
+ { key: 'disable_join_leave_messages', label: 'Join And Leave Messages Disabled', format: 'boolean' },
+];
+
+const channelWithTeamFields: OutputSchema['fields'] = [
+ ...channelFields,
+ { key: 'team_display_name', label: 'Team Display Name' },
+ { key: 'team_name', label: 'Team Name' },
+ { key: 'team_update_at', label: 'Team Updated At', format: 'datetime' },
+];
+
+const channelMemberNotifyPropsFields: OutputSchema['fields'] = [
+ { key: 'channel_auto_follow_threads', label: 'Auto Follow Threads' },
+ { key: 'desktop', label: 'Desktop Notifications' },
+ { key: 'email', label: 'Email Notifications' },
+ { key: 'ignore_channel_mentions', label: 'Ignore Channel Mentions' },
+ { key: 'mark_unread', label: 'Mark Unread' },
+ { key: 'push', label: 'Push Notifications' },
+];
+
+const channelMemberFields: OutputSchema['fields'] = [
+ { key: 'channel_id', label: 'Channel ID' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'roles', label: 'Roles' },
+ { key: 'msg_count', label: 'Message Count', format: 'number' },
+ { key: 'mention_count', label: 'Mention Count', format: 'number' },
+ { key: 'mention_count_root', label: 'Root Mention Count', format: 'number' },
+ { key: 'urgent_mention_count', label: 'Urgent Mention Count', format: 'number' },
+ { key: 'msg_count_root', label: 'Root Message Count', format: 'number' },
+ { key: 'notify_props', label: 'Notification Settings', children: channelMemberNotifyPropsFields },
+ { key: 'scheme_guest', label: 'Guest', format: 'boolean' },
+ { key: 'scheme_user', label: 'Regular User', format: 'boolean' },
+ { key: 'scheme_admin', label: 'Admin', format: 'boolean' },
+ { key: 'explicit_roles', label: 'Explicit Roles' },
+ { key: 'autotranslation_disabled', label: 'Autotranslation Disabled', format: 'boolean' },
+];
+
+const channelMemberActivityFields: OutputSchema['fields'] = [
+ ...channelMemberFields,
+ { key: 'last_viewed_at', label: 'Last Viewed At', format: 'datetime' },
+ { key: 'last_update_at', label: 'Last Updated At', format: 'datetime' },
+];
+
+const userChannelMembershipFields: OutputSchema['fields'] = [
+ ...channelMemberActivityFields,
+ { key: 'team_display_name', label: 'Team Display Name' },
+ { key: 'team_name', label: 'Team Name' },
+ { key: 'team_update_at', label: 'Team Updated At', format: 'datetime' },
+];
+
+const channelUnreadFields: OutputSchema['fields'] = [
+ { key: 'team_id', label: 'Team ID' },
+ { key: 'channel_id', label: 'Channel ID' },
+ { key: 'msg_count', label: 'Message Count', format: 'number' },
+ { key: 'mention_count', label: 'Mention Count', format: 'number' },
+ { key: 'mention_count_root', label: 'Root Mention Count', format: 'number' },
+ { key: 'urgent_mention_count', label: 'Urgent Mention Count', format: 'number' },
+ { key: 'msg_count_root', label: 'Root Message Count', format: 'number' },
+];
+
+const teamUnreadFields: OutputSchema['fields'] = [
+ { key: 'team_id', label: 'Team ID' },
+ { key: 'msg_count', label: 'Message Count', format: 'number' },
+ { key: 'mention_count', label: 'Mention Count', format: 'number' },
+ { key: 'mention_count_root', label: 'Root Mention Count', format: 'number' },
+ { key: 'msg_count_root', label: 'Root Message Count', format: 'number' },
+ { key: 'thread_count', label: 'Thread Count', format: 'number' },
+ { key: 'thread_mention_count', label: 'Thread Mention Count', format: 'number' },
+ { key: 'thread_urgent_mention_count', label: 'Thread Urgent Mention Count', format: 'number' },
+];
+
+const teamFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Team ID' },
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'display_name', label: 'Display Name' },
+ { key: 'name', label: 'Name' },
+ { key: 'description', label: 'Description' },
+ { key: 'email', label: 'Email', format: 'email' },
+ { key: 'type', label: 'Type' },
+ { key: 'company_name', label: 'Company Name' },
+ { key: 'allowed_domains', label: 'Allowed Domains' },
+ { key: 'invite_id', label: 'Invite ID' },
+ { key: 'allow_open_invite', label: 'Open Invite Allowed', format: 'boolean' },
+ { key: 'scheme_id', label: 'Scheme ID' },
+ { key: 'group_constrained', label: 'Group Constrained', format: 'boolean' },
+ { key: 'policy_id', label: 'Policy ID' },
+ { key: 'cloud_limits_archived', label: 'Archived By Cloud Limits', format: 'boolean' },
+ { key: 'policy_enforced', label: 'Policy Enforced', format: 'boolean' },
+ { key: 'policy_auto_add', label: 'Policy Auto Add', format: 'boolean' },
+ { key: 'policy_is_active', label: 'Policy Is Active', format: 'boolean' },
+];
+
+const teamIconUpdatedField: OutputSchema['fields'][number] = {
+ key: 'last_team_icon_update',
+ label: 'Icon Last Updated',
+ format: 'datetime',
+};
+
+const teamMemberFields: OutputSchema['fields'] = [
+ { key: 'team_id', label: 'Team ID' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'roles', label: 'Roles' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'scheme_guest', label: 'Guest', format: 'boolean' },
+ { key: 'scheme_user', label: 'Regular User', format: 'boolean' },
+ { key: 'scheme_admin', label: 'Admin', format: 'boolean' },
+ { key: 'explicit_roles', label: 'Explicit Roles' },
+];
+
+const fileInfoFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'File ID' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'channel_id', label: 'Channel ID' },
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'name', label: 'File Name' },
+ { key: 'extension', label: 'Extension' },
+ { key: 'size', label: 'Size', format: 'filesize' },
+ { key: 'mime_type', label: 'MIME Type' },
+ { key: 'width', label: 'Width', format: 'number' },
+ { key: 'height', label: 'Height', format: 'number' },
+ { key: 'has_preview_image', label: 'Has Preview Image', format: 'boolean' },
+ { key: 'mini_preview', label: 'Mini Preview' },
+ { key: 'remote_id', label: 'Remote ID' },
+ { key: 'archived', label: 'Archived', format: 'boolean' },
+];
+
+const postFileInfoFields: OutputSchema['fields'] = [
+ ...fileInfoFields,
+ { key: 'post_id', label: 'Post ID' },
+];
+
+const systemMessagePropsFields: OutputSchema['fields'] = [
+ { key: 'username', label: 'Username' },
+ { key: 'addedUserId', label: 'Added User ID' },
+ { key: 'addedUsername', label: 'Added Username' },
+ { key: 'userId', label: 'User ID' },
+ { key: 'new_purpose', label: 'New Purpose' },
+ { key: 'old_purpose', label: 'Old Purpose' },
+ { key: 'new_header', label: 'New Header' },
+ { key: 'old_header', label: 'Old Header' },
+];
+
+const postCoreFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Post ID' },
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'edit_at', label: 'Edited At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'is_pinned', label: 'Pinned', format: 'boolean' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'channel_id', label: 'Channel ID' },
+ { key: 'root_id', label: 'Root Post ID' },
+ { key: 'original_id', label: 'Original Post ID' },
+ { key: 'message', label: 'Message' },
+ { key: 'type', label: 'Type' },
+ { key: 'hashtags', label: 'Hashtags' },
+ { key: 'file_ids', label: 'File IDs' },
+ { key: 'pending_post_id', label: 'Pending Post ID' },
+ { key: 'reply_count', label: 'Reply Count', format: 'number' },
+ { key: 'last_reply_at', label: 'Last Reply At', format: 'datetime' },
+ { key: 'participants', label: 'Participants' },
+];
+
+const remoteIdField: OutputSchema['fields'][number] = { key: 'remote_id', label: 'Remote ID' };
+
+const hasReactionsField: OutputSchema['fields'][number] = {
+ key: 'has_reactions',
+ label: 'Has Reactions',
+ format: 'boolean',
+};
+
+const postFields: OutputSchema['fields'] = [
+ ...postCoreFields,
+ { key: 'props', label: 'Props' },
+ { key: 'metadata', label: 'Metadata' },
+];
+
+const postWithRemoteFields: OutputSchema['fields'] = [...postFields, remoteIdField];
+
+const channelPostFields: OutputSchema['fields'] = [
+ ...postCoreFields,
+ { key: 'props', label: 'Props', children: systemMessagePropsFields },
+ remoteIdField,
+ {
+ key: 'metadata',
+ label: 'Metadata',
+ children: [{ key: 'files', label: 'Files', labelKey: 'name', listItems: postFileInfoFields }],
+ },
+];
+
+const threadPostFields: OutputSchema['fields'] = [...postCoreFields, { key: 'props', label: 'Props' }];
+
+const postListFields: OutputSchema['fields'] = [
+ { key: 'order', label: 'Post Order' },
+ { key: 'next_post_id', label: 'Next Post ID' },
+ { key: 'prev_post_id', label: 'Previous Post ID' },
+ { key: 'first_inaccessible_post_time', label: 'First Inaccessible Post Time', format: 'datetime' },
+];
+
+const threadFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Thread ID' },
+ { key: 'reply_count', label: 'Reply Count', format: 'number' },
+ { key: 'last_reply_at', label: 'Last Reply At', format: 'datetime' },
+ { key: 'last_viewed_at', label: 'Last Viewed At', format: 'datetime' },
+ { key: 'participants', label: 'Participants', labelKey: 'username', listItems: threadParticipantFields },
+ { key: 'unread_replies', label: 'Unread Replies', format: 'number' },
+ { key: 'unread_mentions', label: 'Unread Mentions', format: 'number' },
+ { key: 'is_urgent', label: 'Urgent', format: 'boolean' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+];
+
+function postListWith({ postFieldList }: { postFieldList: OutputSchema['fields'] }): OutputSchema['fields'] {
+ return [
+ ...postListFields,
+ { key: 'posts', label: 'Posts', dynamicKey: true, labelKey: 'message', children: postFieldList },
+ ];
+}
+
+function threadWith({ postFieldList }: { postFieldList: OutputSchema['fields'] }): OutputSchema['fields'] {
+ return [...threadFields, { key: 'post', label: 'Root Post', children: postFieldList }];
+}
+
+const reactionFields: OutputSchema['fields'] = [
+ { key: 'user_id', label: 'User ID' },
+ { key: 'post_id', label: 'Post ID' },
+ { key: 'emoji_name', label: 'Emoji Name' },
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'remote_id', label: 'Remote ID' },
+ { key: 'channel_id', label: 'Channel ID' },
+];
+
+const botFields: OutputSchema['fields'] = [
+ { key: 'user_id', label: 'Bot User ID' },
+ { key: 'username', label: 'Username' },
+ { key: 'display_name', label: 'Display Name' },
+ { key: 'description', label: 'Description' },
+ { key: 'owner_id', label: 'Owner ID' },
+ { key: 'system_owned', label: 'System Owned', format: 'boolean' },
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+];
+
+const commandFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Command ID' },
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'creator_id', label: 'Creator ID' },
+ { key: 'team_id', label: 'Team ID' },
+ { key: 'trigger', label: 'Trigger Word' },
+ { key: 'method', label: 'HTTP Method' },
+ { key: 'username', label: 'Username' },
+ { key: 'icon_url', label: 'Icon URL', format: 'image' },
+ { key: 'auto_complete', label: 'Autocomplete', format: 'boolean' },
+ { key: 'auto_complete_desc', label: 'Autocomplete Description' },
+ { key: 'auto_complete_hint', label: 'Autocomplete Hint' },
+ { key: 'display_name', label: 'Display Name' },
+ { key: 'description', label: 'Description' },
+ { key: 'url', label: 'Request URL', format: 'url' },
+ { key: 'plugin_id', label: 'Plugin ID' },
+];
+
+const emojiFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Emoji ID' },
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'creator_id', label: 'Creator ID' },
+ { key: 'name', label: 'Name' },
+];
+
+const channelCategoryFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Category ID' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'team_id', label: 'Team ID' },
+ { key: 'sort_order', label: 'Sort Order', format: 'number' },
+ { key: 'sorting', label: 'Sorting' },
+ { key: 'type', label: 'Type' },
+ { key: 'display_name', label: 'Display Name' },
+ { key: 'muted', label: 'Muted', format: 'boolean' },
+ { key: 'collapsed', label: 'Collapsed', format: 'boolean' },
+ { key: 'channel_ids', label: 'Channel IDs' },
+];
+
+const userStatusFields: OutputSchema['fields'] = [
+ { key: 'user_id', label: 'User ID' },
+ { key: 'status', label: 'Status' },
+ { key: 'manual', label: 'Set Manually', format: 'boolean' },
+ { key: 'last_activity_at', label: 'Last Activity At', format: 'datetime' },
+ { key: 'dnd_end_time', label: 'Do Not Disturb Ends At', format: 'number' },
+];
+
+const preferenceFields: OutputSchema['fields'] = [
+ { key: 'user_id', label: 'User ID' },
+ { key: 'category', label: 'Category' },
+ { key: 'name', label: 'Name' },
+ { key: 'value', label: 'Value' },
+];
+
+const roleFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Role ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'display_name', label: 'Display Name' },
+ { key: 'description', label: 'Description' },
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'permissions', label: 'Permissions' },
+ { key: 'scheme_managed', label: 'Scheme Managed', format: 'boolean' },
+ { key: 'built_in', label: 'Built In', format: 'boolean' },
+ { key: 'scheme_id', label: 'Scheme ID' },
+];
+
+const draftFields: OutputSchema['fields'] = [
+ { key: 'create_at', label: 'Created At', format: 'datetime' },
+ { key: 'update_at', label: 'Updated At', format: 'datetime' },
+ { key: 'delete_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'channel_id', label: 'Channel ID' },
+ { key: 'root_id', label: 'Root Post ID' },
+ { key: 'message', label: 'Message' },
+ { key: 'type', label: 'Type' },
+ { key: 'props', label: 'Props' },
+ { key: 'metadata', label: 'Metadata' },
+];
+
+export const mattermostAddChannelMemberOutputSchema: OutputSchema = { fields: channelMemberFields };
+
+export const mattermostAddReactionOutputSchema: OutputSchema = { fields: reactionFields };
+
+export const mattermostAddTeamMemberOutputSchema: OutputSchema = { fields: teamMemberFields };
+
+export const mattermostAddTeamMembersOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'members', label: 'Members', labelKey: 'user_id', listItems: teamMemberFields },
+ countField,
+ ],
+};
+
+export const mattermostArchiveChannelOutputSchema: OutputSchema = {
+ fields: [{ key: 'status', label: 'Status' }],
+};
+
+export const mattermostAssignBotOutputSchema: OutputSchema = { fields: botFields };
+
+export const mattermostCheckTeamExistsOutputSchema: OutputSchema = {
+ fields: [{ key: 'exists', label: 'Exists', format: 'boolean' }],
+};
+
+export const mattermostConvertBotToUserOutputSchema: OutputSchema = {
+ fields: [
+ ...userCoreFields,
+ passwordUpdatedField,
+ { key: 'is_bot', label: 'Is Bot', format: 'boolean' },
+ { key: 'bot_description', label: 'Bot Description' },
+ ],
+};
+
+export const mattermostConvertGroupMessageToChannelOutputSchema: OutputSchema = {
+ fields: channelFields,
+};
+
+export const mattermostConvertUserToBotOutputSchema: OutputSchema = {
+ fields: botFields.filter((field) => field.key !== 'description'),
+};
+
+export const mattermostCountUserReportsOutputSchema: OutputSchema = { fields: [countField] };
+
+export const mattermostCreateChannelOutputSchema: OutputSchema = { fields: channelFields };
+
+export const mattermostCreateChannelCategoryOutputSchema: OutputSchema = {
+ fields: channelCategoryFields,
+};
+
+export const mattermostCreateCommandOutputSchema: OutputSchema = { fields: commandFields };
+
+export const mattermostCreateEmojiOutputSchema: OutputSchema = { fields: emojiFields };
+
+export const mattermostCreatePostOutputSchema: OutputSchema = { fields: postWithRemoteFields };
+
+export const mattermostCreateTeamOutputSchema: OutputSchema = { fields: teamFields };
+
+export const mattermostCreateUserOutputSchema: OutputSchema = {
+ fields: [...userFields, passwordUpdatedField],
+};
+
+export const mattermostDisableBotOutputSchema: OutputSchema = { fields: botFields };
+
+export const mattermostDownloadFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'file', label: 'File', format: 'url' },
+ { key: 'fileName', label: 'File Name' },
+ { key: 'contentType', label: 'Content Type' },
+ { key: 'size', label: 'Size', format: 'filesize' },
+ ],
+};
+
+export const mattermostExecuteCommandOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'response_type', label: 'Response Type' },
+ { key: 'text', label: 'Text' },
+ { key: 'username', label: 'Username' },
+ { key: 'channel_id', label: 'Channel ID' },
+ { key: 'icon_url', label: 'Icon URL', format: 'image' },
+ { key: 'type', label: 'Type' },
+ { key: 'props', label: 'Props' },
+ { key: 'goto_location', label: 'Go To Location' },
+ { key: 'trigger_id', label: 'Trigger ID' },
+ { key: 'skip_slack_parsing', label: 'Skip Slack Parsing', format: 'boolean' },
+ { key: 'attachments', label: 'Attachments' },
+ { key: 'extra_responses', label: 'Extra Responses' },
+ ],
+};
+
+export const mattermostGetChannelCategoryOrderOutputSchema: OutputSchema = {
+ fields: [{ key: 'order', label: 'Category Order' }, countField],
+};
+
+export const mattermostGetChannelMemberCountsOutputSchema: OutputSchema = {
+ fields: [{ key: 'counts', label: 'Member Counts By Channel', value: '', dynamicKey: true }],
+};
+
+export const mattermostGetChannelMembersByIdsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'members', label: 'Members', labelKey: 'user_id', listItems: channelMemberFields },
+ countField,
+ ],
+};
+
+export const mattermostGetChannelStatsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'channel_id', label: 'Channel ID' },
+ { key: 'member_count', label: 'Member Count', format: 'number' },
+ { key: 'guest_count', label: 'Guest Count', format: 'number' },
+ { key: 'pinnedpost_count', label: 'Pinned Post Count', format: 'number' },
+ { key: 'files_count', label: 'File Count', format: 'number' },
+ ],
+};
+
+export const mattermostGetChannelUnreadOutputSchema: OutputSchema = { fields: channelUnreadFields };
+
+export const mattermostGetChannelsByIdsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'channels', label: 'Channels', labelKey: 'name', listItems: channelFields },
+ countField,
+ ],
+};
+
+export const mattermostGetEmojisByNamesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'emojis', label: 'Emojis', labelKey: 'name', listItems: emojiFields },
+ countField,
+ ],
+};
+
+export const mattermostGetFileInfoOutputSchema: OutputSchema = { fields: fileInfoFields };
+
+export const mattermostGetFilePublicLinkOutputSchema: OutputSchema = {
+ fields: [{ key: 'link', label: 'Public Link', format: 'url' }],
+};
+
+export const mattermostGetFilteredUserStatsOutputSchema: OutputSchema = {
+ fields: [{ key: 'total_users_count', label: 'Total Users', format: 'number' }],
+};
+
+export const mattermostGetPostEditHistoryOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'versions', label: 'Versions', labelKey: 'message', listItems: postWithRemoteFields },
+ countField,
+ ],
+};
+
+export const mattermostGetPostInfoOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'channel_id', label: 'Channel ID' },
+ { key: 'channel_type', label: 'Channel Type' },
+ { key: 'channel_display_name', label: 'Channel Display Name' },
+ { key: 'has_joined_channel', label: 'Has Joined Channel', format: 'boolean' },
+ { key: 'team_id', label: 'Team ID' },
+ { key: 'team_type', label: 'Team Type' },
+ { key: 'team_display_name', label: 'Team Display Name' },
+ { key: 'has_joined_team', label: 'Has Joined Team', format: 'boolean' },
+ ],
+};
+
+export const mattermostGetPostThreadOutputSchema: OutputSchema = {
+ fields: [
+ ...postListWith({ postFieldList: postFields }),
+ { key: 'has_next', label: 'Has Next', format: 'boolean' },
+ ],
+};
+
+export const mattermostGetPostsByIdsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'posts', label: 'Posts', labelKey: 'message', listItems: postFields },
+ countField,
+ ],
+};
+
+export const mattermostGetPreferenceOutputSchema: OutputSchema = { fields: preferenceFields };
+
+export const mattermostGetRoleOutputSchema: OutputSchema = { fields: roleFields };
+
+export const mattermostGetRolesByNamesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'roles', label: 'Roles', labelKey: 'name', listItems: roleFields },
+ countField,
+ ],
+};
+
+export const mattermostGetServerLimitsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'maxUsersLimit', label: 'Max Users Limit', format: 'number' },
+ { key: 'maxUsersHardLimit', label: 'Max Users Hard Limit', format: 'number' },
+ { key: 'activeUserCount', label: 'Active User Count', format: 'number' },
+ { key: 'singleChannelGuestCount', label: 'Single Channel Guest Count', format: 'number' },
+ { key: 'singleChannelGuestLimit', label: 'Single Channel Guest Limit', format: 'number' },
+ { key: 'postHistoryLimit', label: 'Post History Limit', format: 'number' },
+ { key: 'lastAccessiblePostTime', label: 'Last Accessible Post Time', format: 'datetime' },
+ ],
+};
+
+export const mattermostGetTeamOutputSchema: OutputSchema = {
+ fields: [...teamFields, teamIconUpdatedField],
+};
+
+export const mattermostGetTeamInviteInfoOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Team ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'display_name', label: 'Display Name' },
+ { key: 'description', label: 'Description' },
+ ],
+};
+
+export const mattermostGetTeamStatsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'team_id', label: 'Team ID' },
+ { key: 'total_member_count', label: 'Total Member Count', format: 'number' },
+ { key: 'active_member_count', label: 'Active Member Count', format: 'number' },
+ ],
+};
+
+export const mattermostGetTeamUnreadOutputSchema: OutputSchema = { fields: teamUnreadFields };
+
+export const mattermostGetThreadOutputSchema: OutputSchema = {
+ fields: threadWith({ postFieldList: [...threadPostFields, hasReactionsField] }),
+};
+
+export const mattermostGetUserOutputSchema: OutputSchema = {
+ fields: [...userFields, pictureUpdatedField],
+};
+
+export const mattermostGetUserByEmailOutputSchema: OutputSchema = { fields: userFields };
+
+export const mattermostGetUserStatusOutputSchema: OutputSchema = { fields: userStatusFields };
+
+export const mattermostGetUserStatusesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'statuses', label: 'Statuses', labelKey: 'status', listItems: userStatusFields },
+ countField,
+ ],
+};
+
+export const mattermostGetUsersByIdsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'users', label: 'Users', labelKey: 'username', listItems: userFields },
+ countField,
+ ],
+};
+
+export const mattermostListAllChannelsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'channels', label: 'Channels', labelKey: 'name', listItems: channelWithTeamFields },
+ countField,
+ ],
+};
+
+export const mattermostListArchivedChannelsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'channels', label: 'Channels', labelKey: 'name', listItems: channelFields },
+ countField,
+ ],
+};
+
+export const mattermostListBotsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'bots', label: 'Bots', labelKey: 'display_name', listItems: botFields },
+ countField,
+ ],
+};
+
+export const mattermostListChannelCategoriesOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'categories',
+ label: 'Categories',
+ labelKey: 'display_name',
+ listItems: channelCategoryFields,
+ },
+ { key: 'order', label: 'Category Order' },
+ ],
+};
+
+export const mattermostListChannelMembersOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'members', label: 'Members', labelKey: 'user_id', listItems: channelMemberActivityFields },
+ countField,
+ ],
+};
+
+export const mattermostListChannelPostsOutputSchema: OutputSchema = {
+ fields: postListWith({ postFieldList: channelPostFields }),
+};
+
+export const mattermostListChannelTimezonesOutputSchema: OutputSchema = {
+ fields: [{ key: 'timezones', label: 'Timezones' }, countField],
+};
+
+export const mattermostListCommandsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'commands', label: 'Commands', labelKey: 'display_name', listItems: commandFields },
+ countField,
+ ],
+};
+
+export const mattermostListDraftsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'drafts', label: 'Drafts', labelKey: 'message', listItems: draftFields },
+ countField,
+ ],
+};
+
+export const mattermostListFlaggedPostsOutputSchema: OutputSchema = {
+ fields: postListWith({ postFieldList: postFields }),
+};
+
+export const mattermostListGroupChannelCommonTeamsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'teams', label: 'Teams', labelKey: 'name', listItems: teamFields },
+ countField,
+ ],
+};
+
+export const mattermostListGroupChannelUsersOutputSchema: OutputSchema = {
+ fields: [{ key: 'users', label: 'Users By ID', value: '', dynamicKey: true }],
+};
+
+export const mattermostListKnownUsersOutputSchema: OutputSchema = {
+ fields: [{ key: 'userIds', label: 'User IDs' }, countField],
+};
+
+export const mattermostListPostFilesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'files', label: 'Files', labelKey: 'name', listItems: postFileInfoFields },
+ countField,
+ ],
+};
+
+export const mattermostListPreferencesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'preferences', label: 'Preferences', labelKey: 'name', listItems: preferenceFields },
+ countField,
+ ],
+};
+
+export const mattermostListReactionsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'reactions', label: 'Reactions', labelKey: 'emoji_name', listItems: reactionFields },
+ countField,
+ ],
+};
+
+export const mattermostListTeamUnreadsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'unreads', label: 'Unreads', labelKey: 'team_id', listItems: teamUnreadFields },
+ countField,
+ ],
+};
+
+export const mattermostListThreadsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'total', label: 'Total', format: 'number' },
+ { key: 'total_unread_threads', label: 'Total Unread Threads', format: 'number' },
+ { key: 'total_unread_mentions', label: 'Total Unread Mentions', format: 'number' },
+ { key: 'total_unread_urgent_mentions', label: 'Total Unread Urgent Mentions', format: 'number' },
+ {
+ key: 'threads',
+ label: 'Threads',
+ labelKey: 'id',
+ listItems: threadWith({ postFieldList: [...threadPostFields, hasReactionsField, remoteIdField] }),
+ },
+ ],
+};
+
+export const mattermostListUserChannelMembershipsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'channelMembers',
+ label: 'Channel Memberships',
+ labelKey: 'channel_id',
+ listItems: userChannelMembershipFields,
+ },
+ countField,
+ ],
+};
+
+export const mattermostListUserReportsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'users',
+ label: 'Users',
+ labelKey: 'username',
+ listItems: [
+ ...userFields,
+ pictureUpdatedField,
+ { key: 'last_login', label: 'Last Login', format: 'datetime' },
+ { key: 'last_status_at', label: 'Last Status At', format: 'datetime' },
+ { key: 'days_active', label: 'Days Active', format: 'number' },
+ { key: 'channel_count', label: 'Channel Count', format: 'number' },
+ { key: 'teams', label: 'Teams' },
+ ],
+ },
+ countField,
+ ],
+};
+
+export const mattermostListUserTeamMembershipsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'memberships', label: 'Team Memberships', labelKey: 'team_id', listItems: teamMemberFields },
+ countField,
+ ],
+};
+
+export const mattermostMarkChannelsReadOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'status', label: 'Status' },
+ {
+ key: 'last_viewed_at_times',
+ label: 'Last Viewed At By Channel',
+ dynamicKey: true,
+ format: 'datetime',
+ },
+ ],
+};
+
+export const mattermostMarkPostUnreadOutputSchema: OutputSchema = {
+ fields: [
+ ...channelUnreadFields,
+ { key: 'user_id', label: 'User ID' },
+ { key: 'last_viewed_at', label: 'Last Viewed At', format: 'datetime' },
+ ],
+};
+
+export const mattermostMarkThreadReadOutputSchema: OutputSchema = {
+ fields: threadWith({ postFieldList: threadPostFields }),
+};
+
+export const mattermostPatchPostOutputSchema: OutputSchema = { fields: postFields };
+
+export const mattermostSearchAllChannelsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'channels', label: 'Channels', labelKey: 'name', listItems: channelWithTeamFields },
+ { key: 'total_count', label: 'Total Count', format: 'number' },
+ ],
+};
+
+export const mattermostSearchFilesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'order', label: 'File Order' },
+ {
+ key: 'file_infos',
+ label: 'Files',
+ dynamicKey: true,
+ labelKey: 'name',
+ children: postFileInfoFields,
+ },
+ { key: 'next_file_info_id', label: 'Next File ID' },
+ { key: 'prev_file_info_id', label: 'Previous File ID' },
+ { key: 'first_inaccessible_file_time', label: 'First Inaccessible File Time', format: 'datetime' },
+ ],
+};
+
+export const mattermostSearchPostsOutputSchema: OutputSchema = {
+ fields: [
+ ...postListWith({ postFieldList: postWithRemoteFields }),
+ { key: 'matches', label: 'Matches' },
+ ],
+};
+
+export const mattermostSearchTeamsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'teams', label: 'Teams', labelKey: 'name', listItems: teamFields },
+ { key: 'total_count', label: 'Total Count', format: 'number' },
+ ],
+};
+
+export const mattermostSetChannelMembersOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'batches',
+ label: 'Batches',
+ listItems: [
+ { key: 'added', label: 'Added' },
+ { key: 'removed', label: 'Removed' },
+ ],
+ },
+ countField,
+ ],
+};
+
+export const mattermostUpdateChannelCategoriesOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'categories',
+ label: 'Categories',
+ labelKey: 'display_name',
+ listItems: channelCategoryFields,
+ },
+ countField,
+ ],
+};
+
+export const mattermostUpdateTeamPrivacyOutputSchema: OutputSchema = {
+ fields: [...teamFields, teamIconUpdatedField],
+};
+
+export const mattermostUploadFileOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'file_infos', label: 'Files', labelKey: 'name', listItems: fileInfoFields },
+ { key: 'client_ids', label: 'Client IDs' },
+ ],
+};
+
+export const mattermostUpsertDraftOutputSchema: OutputSchema = { fields: draftFields };
+
+export const mattermostSendMessageOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'status', label: 'HTTP Status', format: 'number' },
+ { key: 'body', label: 'Post', children: postWithRemoteFields },
+ ],
+};