AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import {
createAction,
MarkdownVariant,
Property,
} from '@activepieces/pieces-framework';
import { youtubeAuth } from '../common/auth';
import { getChannelOutputSchema } from '../output-schemas';
export const youtubeGetChannelAction = createAction({
auth: youtubeAuth,
outputSchema: getChannelOutputSchema,
name: 'get_channel',
classification: 'READ',
displayName: 'Get Channel',
description: "Get a channel's details, including subscriber and view counts.",
audience: 'human',
aiMetadata: {
description:
'Fetches a YouTube channel using channels.list, by channel ID or by @handle, returning title, description, country, subscriber count, view count and video count. Use it to resolve a channel reference into its statistics or its uploads playlist ID. Read-only and idempotent.',
idempotent: true,
},
props: {
lookupInfo: Property.MarkDown({
value: 'Fill in Channel ID or Handle.',
variant: MarkdownVariant.INFO,
}),
channelId: Property.ShortText({
displayName: 'Channel ID',
description: 'Starts with UC. Leave empty to look the channel up by Handle.',
placeholder: 'UC_x5XG1OV2P6uZZ5FSM9Ttw',
required: false,
}),
handle: Property.ShortText({
displayName: 'Handle',
description: 'The @name on the channel page. Used only when Channel ID is empty.',
placeholder: '@GoogleDevelopers',
required: false,
}),
},
propertyGroups: [
{
key: 'channel',
display: 'section',
label: 'Channel',
icon: 'user',
props: ['lookupInfo', 'channelId', 'handle'],
},
],
async run(context) {
const accessToken = context.auth.access_token;
const { channelId, handle } = context.propsValue;
if (!channelId && !handle) {
throw new Error('Provide either a Channel ID or a Handle.');
}
const queryParams: Record<string, string> = {
part: 'snippet,contentDetails,statistics',
};
if (channelId) {
queryParams['id'] = channelId;
} else if (handle) {
queryParams['forHandle'] = handle.startsWith('@') ? handle : `@${handle}`;
}
const response = await httpClient.sendRequest({
method: HttpMethod.GET,
url: 'https://www.googleapis.com/youtube/v3/channels',
headers: { Authorization: `Bearer ${accessToken}` },
queryParams,
});
return response.body;
},
});