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, Property, TriggerStrategy } from '@activepieces/pieces-framework';
import { makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
import { isNil } from '@activepieces/pieces-framework';
import { copyAiAuth } from '../auth';
export const workflowRunCompletedTrigger = createTrigger({
auth:copyAiAuth,
name: 'workflow_run_completed',
displayName: 'Workflow Run Completed',
description: 'Triggered when a workflow run is completed.',
aiMetadata: {
description: 'Fires via webhook when an execution of the specified Copy.ai workflow finishes, delivering the completed run including its status, inputs, and generated outputs. Scoped to the single workflow ID configured on the trigger.',
},
props: {
workflowId: Property.ShortText({
displayName: 'Workflow ID',
required: true,
}),
},
type: TriggerStrategy.WEBHOOK,
sampleData: {
"status": "COMPLETE",
"input": {
"should_run": "Test"
},
"toolKey": null,
"metadata": {
"webapp": true
},
"error": null,
"createdAt": "2025-05-07T09:31:40.545Z",
"id": "WRUN-7515d814-3890-4ba0-ae32-fa6abcf76432",
"workflowRunId": "WRUN-7515d814-3890-4ba0-ae32-fa6abcf76432",
"workflowId": "WCFG-506c46fb-6459-4e23-979b-875444170626",
"credits": 1,
"output": {
"final_output": "",
"send_api_request": "{}",
},
"type": "workflowRun.completed"
},
async onEnable(context) {
const response = await makeRequest(
context.auth.secret_text,
HttpMethod.POST,
'/webhook',
{
"url": context.webhookUrl,
"eventType": "workflowRun.completed",
"workflowId": context.propsValue.workflowId
}
) as CreateWebhookResponse;
await context.store.put<{webhookId:string}>('workflow_run_completed',{webhookId:response.data.id})
},
async onDisable(context) {
const response = await context.store.get<{webhookId:string}>('workflow_run_completed');
if(!isNil(response) && !isNil(response.webhookId))
{
await makeRequest(
context.auth.secret_text,
HttpMethod.DELETE,
`/webhook/${response.webhookId}`,
{}
)
}
},
async run(context) {
return [context.payload.body];
},
});
type CreateWebhookResponse = {
status:string;
data:{
id:string
}
}