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 {
createTrigger,
TriggerStrategy,
PiecePropValueSchema,
AppConnectionValueForAuthProperty,
} from '@activepieces/pieces-framework';
import {
DedupeStrategy,
Polling,
pollingHelper,
HttpMethod,
} from '@activepieces/pieces-common';
import dayjs from 'dayjs';
import { meistertaskAuth } from '../auth';
import { makeRequest, meisterTaskCommon } from '../common/common';
const getToken = (auth: any): string => {
return typeof auth === 'string' ? auth : (auth as any).access_token;
};
const newCommentPolling: Polling<
AppConnectionValueForAuthProperty<typeof meistertaskAuth>,
{ task_id: unknown }
> = {
strategy: DedupeStrategy.TIMEBASED,
items: async ({ auth, propsValue }) => {
const token = getToken(auth);
const tasksResponse = await makeRequest(
HttpMethod.GET,
`/task/${propsValue.task_id}/comments`,
token
);
const taskComments = tasksResponse.body || [];
return taskComments.map((comment: any) => ({
epochMilliSeconds: dayjs(comment.created_at).valueOf(),
data: comment,
}));
},
};
export const newComment = createTrigger({
auth: meistertaskAuth,
name: 'new_comment',
classification: 'READ',
displayName: 'New Comment',
description: 'Triggers when a new comment is created on a task.',
aiMetadata: {
description: 'Fires when a new comment is posted on the selected MeisterTask task. Represents a discussion message added to that specific task.',
},
props: {
task_id: meisterTaskCommon.task_id,
},
sampleData: {
"id": 2,
"task_id": 123,
"text": "Looks awesome!",
"text_html": "<p>Looks awesome!</p>\n",
"person_id": 7,
"created_at": "2017-04-02T03:14:15.926535Z",
"updated_at": "2017-04-02T03:14:15.926535Z"
},
type: TriggerStrategy.POLLING,
async test(context) {
return await pollingHelper.test(newCommentPolling, context);
},
async onEnable(context) {
await pollingHelper.onEnable(newCommentPolling, context);
},
async onDisable(context) {
await pollingHelper.onDisable(newCommentPolling, context);
},
async run(context) {
return await pollingHelper.poll(newCommentPolling, context);
},
});