Add Activepieces integration for workflow automation

- Add Activepieces fork with SmoothSchedule custom piece
- Create integrations app with Activepieces service layer
- Add embed token endpoint for iframe integration
- Create Automations page with embedded workflow builder
- Add sidebar visibility fix for embed mode
- Add list inactive customers endpoint to Public API
- Include SmoothSchedule triggers: event created/updated/cancelled
- Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-18 22:59:37 -05:00
parent 9848268d34
commit 3aa7199503
16292 changed files with 1284892 additions and 4708 deletions

View File

@@ -0,0 +1,31 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { makeRequest } from '../common/client';
import { copyAiAuth } from '../../index';
export const getWorkflowRunOutputsAction = createAction({
auth:copyAiAuth,
name: 'get_workflow_run_outputs',
displayName: 'Get Workflow Run Outputs',
description: 'Retrieves the outputs of a completed workflow run.',
props: {
workflowId: Property.ShortText({
displayName: 'Workflow ID',
required: true,
}),
runId: Property.ShortText({
displayName: 'Run ID',
description: 'The ID of the workflow run to get outputs from.',
required: true,
}),
},
async run({ propsValue, auth }) {
const response = await makeRequest(
auth.secret_text,
HttpMethod.GET,
`/workflow/${propsValue.workflowId}/run/${propsValue.runId}`,
);
return response.data?.output || response;
},
});

View File

@@ -0,0 +1,40 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { makeRequest } from '../common/client';
import { copyAiAuth } from '../../index';
export const getWorkflowRunStatusAction = createAction({
auth:copyAiAuth,
name: 'get_workflow_run_status',
displayName: 'Get Workflow Run Status',
description: 'Retrieves the status of a workflow execution.',
props: {
workflowId: Property.ShortText({
displayName: 'Workflow ID',
required: true,
}),
runId: Property.ShortText({
displayName: 'Run ID',
description: 'The ID of the workflow run to check.',
required: true,
}),
},
async run({ propsValue, auth }) {
const response = (await makeRequest(
auth.secret_text,
HttpMethod.GET,
`/workflow/${propsValue.workflowId}/run/${propsValue.runId}`,
)) as GetRunResponse;
return {
status: response.data.status,
};
},
});
type GetRunResponse = {
status: string;
data: {
status: string;
};
};

View File

@@ -0,0 +1,44 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { makeRequest } from '../common/client';
import { copyAiAuth } from '../../index';
export const runWorkflowAction = createAction({
auth:copyAiAuth,
name: 'run_workflow',
displayName: 'Run Workflow',
description: 'Start a Copy.ai workflow execution.',
props: {
workflowId: Property.ShortText({
displayName: 'Workflow ID',
description: 'The ID of the workflow to run.',
required: true,
}),
inputs: Property.Object({
displayName: 'Workflow Inputs',
description: 'The input data for the workflow.',
required: true,
}),
},
async run({ propsValue, auth }) {
const response = (await makeRequest(
auth.secret_text,
HttpMethod.POST,
`/workflow/${propsValue.workflowId}/run`,
{
startVariables: propsValue.inputs,
},
)) as CreateRunResponse;
return {
runId: response.data.id,
};
},
});
type CreateRunResponse = {
success: string;
data: {
id: string;
};
};

View File

@@ -0,0 +1,16 @@
import { HttpMethod, httpClient } from '@activepieces/pieces-common';
export const BASE_URL = 'https://api.copy.ai/api';
export async function makeRequest(auth: string, method: HttpMethod, path: string, body?: unknown) {
const response = await httpClient.sendRequest({
method,
url: `${BASE_URL}${path}`,
headers: {
'x-copy-ai-api-key': `${auth}`,
'Content-Type': 'application/json',
},
body,
});
return response.body;
}

View File

@@ -0,0 +1,81 @@
import { createTrigger, Property, TriggerStrategy } from '@activepieces/pieces-framework';
import { makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
import { isNil } from '@activepieces/shared';
import { copyAiAuth } from '../../index';
export const workflowRunCompletedTrigger = createTrigger({
auth:copyAiAuth,
name: 'workflow_run_completed',
displayName: 'Workflow Run Completed',
description: 'Triggered when a workflow run is completed.',
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
}
}