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

1.7 KB
Raw Blame
import { microsoftTeamsAuth } from '../auth';
import { createAction, Property } from '@activepieces/pieces-framework';
import { microsoftTeamsProps } from '../common/props';
import { microsoftTeamsClient } from '../common/client';
import { microsoftTeamsCreatePrivateChannelOutputSchema } from '../output-schemas';

export const createPrivateChannelAction = createAction({
	auth: microsoftTeamsAuth,
	name: 'microsoft_teams_create_private_channel',
	outputSchema: microsoftTeamsCreatePrivateChannelOutputSchema,
	classification: 'WRITE',
	displayName: 'Create Private Channel',
	description: 'Create a new private channel in a team.',
	audience: 'human',
	aiMetadata: {
		description: 'Creates a new private (membership-restricted) channel inside a Microsoft Teams team, identified by team ID, with a display name and optional description. Use when access should be limited to specific members; for a standard open channel use Create Channel instead. Not idempotent — each call adds another channel.',
		idempotent: false,
	},
	props: {
		teamId: microsoftTeamsProps.teamId({ required: true }),
		channelDisplayName: Property.ShortText({
			displayName: 'Channel Name',
			required: true,
		}),
		channelDescription: Property.LongText({
			displayName: 'Channel Description',
			required: false,
		}),
	},
	async run(context) {
		const { teamId, channelDescription, channelDisplayName } = context.propsValue;

		const client = microsoftTeamsClient.create({ auth: context.auth });

		const channel = {
			displayName: channelDisplayName,
			description: channelDescription,
			membershipType: 'private',
		};

		return await microsoftTeamsClient.withRetry(() => client.api(`/teams/${teamId}/channels`).post(channel));
	},
});