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:
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"You can obtain API token from [Account Settings](https://app.youform.com/account).": "You can obtain API token from [Account Settings](https://app.youform.com/account).",
|
||||
"New Submission": "New Submission",
|
||||
"Triggers When a new submission is recieved.": "Triggers When a new submission is recieved.",
|
||||
"Form": "Form"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { createPiece } from '@activepieces/pieces-framework';
|
||||
import { youformAuth } from './lib/common/auth';
|
||||
import { PieceCategory } from '@activepieces/shared';
|
||||
import { newSubmissionTrigger } from './lib/triggers/new-form-submission';
|
||||
|
||||
export const youform = createPiece({
|
||||
displayName: 'Youform',
|
||||
auth: youformAuth,
|
||||
minimumSupportedRelease: '0.36.1',
|
||||
logoUrl: 'https://cdn.activepieces.com/pieces/youform.png',
|
||||
authors: ['kishanprmr'],
|
||||
categories: [PieceCategory.FORMS_AND_SURVEYS],
|
||||
actions: [],
|
||||
triggers: [newSubmissionTrigger],
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { PieceAuth } from '@activepieces/pieces-framework';
|
||||
import {
|
||||
AuthenticationType,
|
||||
httpClient,
|
||||
HttpMethod,
|
||||
} from '@activepieces/pieces-common';
|
||||
import { BASE_URL } from './constants';
|
||||
|
||||
export const youformAuth = PieceAuth.SecretText({
|
||||
displayName: 'API Token',
|
||||
description: `You can obtain API token from [Account Settings](https://app.youform.com/account).`,
|
||||
required: true,
|
||||
validate: async ({ auth }) => {
|
||||
try {
|
||||
await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url: BASE_URL + '/me',
|
||||
authentication: {
|
||||
type: AuthenticationType.BEARER_TOKEN,
|
||||
token: auth,
|
||||
},
|
||||
});
|
||||
return {
|
||||
valid: true,
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
valid: false,
|
||||
error: 'Invalid API Token',
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
export const BASE_URL = 'https://app.youform.com/api'
|
||||
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
AuthenticationType,
|
||||
httpClient,
|
||||
HttpMethod,
|
||||
} from '@activepieces/pieces-common';
|
||||
import { Property } from '@activepieces/pieces-framework';
|
||||
import { BASE_URL } from './constants';
|
||||
import { ListFormsResponse } from './types';
|
||||
import { youformAuth } from './auth';
|
||||
|
||||
export const formIdDropdown = Property.Dropdown({
|
||||
auth: youformAuth,
|
||||
displayName: 'Form',
|
||||
refreshers: [],
|
||||
required: true,
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
placeholder: 'Please connect your account first.',
|
||||
options: [],
|
||||
disabled: false,
|
||||
};
|
||||
}
|
||||
|
||||
const response = await httpClient.sendRequest<ListFormsResponse>({
|
||||
method: HttpMethod.GET,
|
||||
url: BASE_URL + '/forms',
|
||||
authentication: {
|
||||
type: AuthenticationType.BEARER_TOKEN,
|
||||
token: auth.secret_text,
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
options: response.body.data.data.map((form) => ({
|
||||
label: form.name,
|
||||
value: form.slug,
|
||||
})),
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
export type ListFormsResponse = {
|
||||
data:{
|
||||
data: {
|
||||
id: number;
|
||||
name: string;
|
||||
slug:string
|
||||
}[];}
|
||||
};
|
||||
|
||||
|
||||
export type CreateWebhookResponse = {
|
||||
data:{
|
||||
id:number
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
|
||||
import { youformAuth } from '../common/auth';
|
||||
import { formIdDropdown } from '../common/props';
|
||||
import {
|
||||
AuthenticationType,
|
||||
httpClient,
|
||||
HttpMethod,
|
||||
} from '@activepieces/pieces-common';
|
||||
import { BASE_URL } from '../common/constants';
|
||||
import { CreateWebhookResponse } from '../common/types';
|
||||
import { isNil } from '@activepieces/shared';
|
||||
|
||||
const TRIGGER_KEY = 'youform-new-submission-trigger';
|
||||
|
||||
export const newSubmissionTrigger = createTrigger({
|
||||
name: 'new-submission',
|
||||
auth: youformAuth,
|
||||
displayName: 'New Submission',
|
||||
description: 'Triggers When a new submission is recieved.',
|
||||
type: TriggerStrategy.WEBHOOK,
|
||||
props: {
|
||||
formId: formIdDropdown,
|
||||
},
|
||||
async onEnable(context) {
|
||||
const { formId } = context.propsValue;
|
||||
|
||||
const response = await httpClient.sendRequest<CreateWebhookResponse>({
|
||||
method: HttpMethod.POST,
|
||||
url: BASE_URL + '/webhooks',
|
||||
authentication: {
|
||||
type: AuthenticationType.BEARER_TOKEN,
|
||||
token: context.auth.secret_text,
|
||||
},
|
||||
body:{},
|
||||
queryParams: {
|
||||
form_id: formId.toString(),
|
||||
webhook_url: context.webhookUrl,
|
||||
},
|
||||
});
|
||||
|
||||
const webhookId = response.body.data.id;
|
||||
|
||||
await context.store.put<number>(TRIGGER_KEY, webhookId);
|
||||
},
|
||||
async onDisable(context) {
|
||||
const webhookId = await context.store.get<number>(TRIGGER_KEY);
|
||||
|
||||
if (!isNil(webhookId)) {
|
||||
await httpClient.sendRequest<CreateWebhookResponse>({
|
||||
method: HttpMethod.DELETE,
|
||||
url: BASE_URL + `/webhooks/${webhookId}`,
|
||||
authentication: {
|
||||
type: AuthenticationType.BEARER_TOKEN,
|
||||
token: context.auth.secret_text,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
async run(context) {
|
||||
return [context.payload.body];
|
||||
},
|
||||
async test(context) {
|
||||
return [context.payload.body];
|
||||
},
|
||||
sampleData: undefined,
|
||||
});
|
||||
Reference in New Issue
Block a user