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,27 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { makeRequest } from '../common';
|
||||
import { cognitoFormsAuth } from '../../index';
|
||||
import { formFields, formIdDropdown } from '../common/props';
|
||||
|
||||
export const createEntryAction = createAction({
|
||||
auth: cognitoFormsAuth,
|
||||
name: 'create_entry',
|
||||
displayName: 'Create Entry',
|
||||
description: 'Creates a new entry.',
|
||||
props: {
|
||||
formId: formIdDropdown,
|
||||
entryData: formFields,
|
||||
},
|
||||
async run(context) {
|
||||
const apiKey = context.auth;
|
||||
const { formId, entryData } = context.propsValue;
|
||||
|
||||
return await makeRequest(
|
||||
apiKey,
|
||||
HttpMethod.POST,
|
||||
`/forms/${formId}/entries`,
|
||||
entryData
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { makeRequest } from '../common';
|
||||
import { cognitoFormsAuth } from '../../index';
|
||||
import { formIdDropdown } from '../common/props';
|
||||
|
||||
export const deleteEntryAction = createAction({
|
||||
auth: cognitoFormsAuth,
|
||||
name: 'delete_entry',
|
||||
displayName: 'Delete Entry',
|
||||
description: 'Deletes a specified entry.',
|
||||
props: {
|
||||
formId: formIdDropdown,
|
||||
entryId: Property.ShortText({
|
||||
displayName: 'Entry ID',
|
||||
required: true,
|
||||
description: 'Enter the ID of the entry to delete.',
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const apiKey = context.auth;
|
||||
const { formId, entryId } = context.propsValue;
|
||||
|
||||
return await makeRequest(
|
||||
apiKey,
|
||||
HttpMethod.DELETE,
|
||||
`/forms/${formId}/entries/${entryId}`
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { makeRequest } from '../common';
|
||||
import { cognitoFormsAuth } from '../../index';
|
||||
import { formIdDropdown } from '../common/props';
|
||||
|
||||
export const getEntryAction = createAction({
|
||||
auth: cognitoFormsAuth,
|
||||
name: 'get_entry',
|
||||
displayName: 'Get Entry',
|
||||
description: 'Gets a specified entry.',
|
||||
props: {
|
||||
formId: formIdDropdown,
|
||||
entryId: Property.ShortText({
|
||||
displayName: 'Entry ID',
|
||||
required: true,
|
||||
description: 'Enter the ID of the entry to retrieve.',
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const apiKey = context.auth;
|
||||
const { formId, entryId } = context.propsValue;
|
||||
|
||||
return await makeRequest(
|
||||
apiKey,
|
||||
HttpMethod.GET,
|
||||
`/forms/${formId}/entries/${entryId}`
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { makeRequest } from '../common';
|
||||
import { cognitoFormsAuth } from '../../index';
|
||||
import { formFields, formIdDropdown } from '../common/props';
|
||||
|
||||
export const updateEntryAction = createAction({
|
||||
auth: cognitoFormsAuth,
|
||||
name: 'update_entry',
|
||||
displayName: 'Update Entry',
|
||||
description: 'Update an existing entry.',
|
||||
props: {
|
||||
formId: formIdDropdown,
|
||||
entryId: Property.ShortText({
|
||||
displayName: 'Entry ID',
|
||||
required: true,
|
||||
description: 'Enter the ID of the entry you want to update.',
|
||||
}),
|
||||
entryData: formFields,
|
||||
},
|
||||
async run(context) {
|
||||
const apiKey = context.auth;
|
||||
const { formId, entryId, entryData } = context.propsValue;
|
||||
|
||||
return await makeRequest(
|
||||
apiKey,
|
||||
HttpMethod.PATCH,
|
||||
`/forms/${formId}/entries/${entryId}`,
|
||||
entryData
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
import { HttpMethod, httpClient } from '@activepieces/pieces-common';
|
||||
import { AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
|
||||
import { cognitoFormsAuth } from '../..';
|
||||
|
||||
export const BASE_URL = 'https://www.cognitoforms.com/api';
|
||||
|
||||
export async function makeRequest(
|
||||
{secret_text}: AppConnectionValueForAuthProperty<typeof cognitoFormsAuth>,
|
||||
method: HttpMethod,
|
||||
path: string,
|
||||
body?: unknown
|
||||
) {
|
||||
const response = await httpClient.sendRequest({
|
||||
method,
|
||||
url: `${BASE_URL}${path}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${secret_text}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body,
|
||||
});
|
||||
|
||||
return response.body;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
import {
|
||||
Property,
|
||||
DropdownOption,
|
||||
DynamicPropsValue,
|
||||
} from '@activepieces/pieces-framework';
|
||||
import { makeRequest } from './index';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { cognitoFormsAuth } from '../..';
|
||||
|
||||
export const formIdDropdown = Property.Dropdown({
|
||||
auth: cognitoFormsAuth,
|
||||
displayName: 'Form',
|
||||
required: true,
|
||||
refreshers: [],
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'Please connect your Cognito Forms account',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
const apiKey = auth;
|
||||
const forms = await makeRequest(apiKey, HttpMethod.GET, '/forms');
|
||||
|
||||
const options: DropdownOption<string>[] = forms.map((form: any) => ({
|
||||
label: form.Name,
|
||||
value: form.Id,
|
||||
}));
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
options,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export const formFields = Property.DynamicProperties({
|
||||
displayName: 'Fields',
|
||||
auth: cognitoFormsAuth,
|
||||
refreshers: ['formId'],
|
||||
required: true,
|
||||
props: async ({ auth, formId }) => {
|
||||
if (!auth || !formId) return {};
|
||||
|
||||
const apiKey = auth;
|
||||
const response = await makeRequest(
|
||||
apiKey,
|
||||
HttpMethod.GET,
|
||||
`/forms/${formId}/schema`
|
||||
);
|
||||
|
||||
const fields = response as FormSchemaResponse;
|
||||
|
||||
const props: DynamicPropsValue = {};
|
||||
|
||||
for (const [key, value] of Object.entries(fields.properties)) {
|
||||
const fieldType = value.type;
|
||||
const fieldName = key;
|
||||
const fieldDes = value.description;
|
||||
const isReadOnly = value.readOnly;
|
||||
|
||||
if (isReadOnly) continue;
|
||||
|
||||
switch (fieldType) {
|
||||
case 'string':
|
||||
props[fieldName] = Property.ShortText({
|
||||
displayName: fieldName,
|
||||
description: fieldDes ?? '',
|
||||
required: false,
|
||||
});
|
||||
break;
|
||||
case 'boolean':
|
||||
props[fieldName] = Property.Checkbox({
|
||||
displayName: fieldName,
|
||||
description: fieldDes ?? '',
|
||||
|
||||
required: false,
|
||||
});
|
||||
break;
|
||||
case 'number':
|
||||
props[fieldName] = Property.Number({
|
||||
displayName: fieldName,
|
||||
description: fieldDes ?? '',
|
||||
|
||||
required: false,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return props;
|
||||
},
|
||||
});
|
||||
|
||||
type FormSchemaResponse = {
|
||||
type: string;
|
||||
properties: {
|
||||
[x: string]: {
|
||||
type: string;
|
||||
readOnly: boolean;
|
||||
description: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
import {
|
||||
createTrigger,
|
||||
Property,
|
||||
TriggerStrategy,
|
||||
} from '@activepieces/pieces-framework';
|
||||
import { cognitoFormsAuth } from '../../index';
|
||||
|
||||
export const entryUpdatedTrigger = createTrigger({
|
||||
name: 'entry_updated',
|
||||
displayName: 'Entry Updated',
|
||||
description: 'Triggers when an existing form entry is updated.',
|
||||
auth: cognitoFormsAuth,
|
||||
props: {
|
||||
webhookInstructions: Property.MarkDown({
|
||||
value: `
|
||||
To use this trigger, you need to manually set up a webhook in your Cognito Forms account:
|
||||
|
||||
1. Login to your Cognito Forms account.
|
||||
2. Select desired form and go to Form Settings.
|
||||
3. Enable **Post JSON Data to Website** and add following URL in **Update Entry Endpoint** field:
|
||||
\`\`\`text
|
||||
{{webhookUrl}}
|
||||
\`\`\`
|
||||
4. Click Save to save the form changes.
|
||||
`,
|
||||
}),
|
||||
},
|
||||
type: TriggerStrategy.WEBHOOK,
|
||||
sampleData: undefined,
|
||||
async onEnable(context) {
|
||||
// No need to register webhooks programmatically as user will do it manually
|
||||
},
|
||||
async onDisable(context) {
|
||||
// No need to unregister webhooks as user will do it manually
|
||||
},
|
||||
|
||||
async run(context) {
|
||||
return [context.payload.body];
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import {
|
||||
createTrigger,
|
||||
Property,
|
||||
TriggerStrategy,
|
||||
} from '@activepieces/pieces-framework';
|
||||
import { cognitoFormsAuth } from '../../index';
|
||||
|
||||
export const newEntryTrigger = createTrigger({
|
||||
name: 'new_entry',
|
||||
displayName: 'New Entry',
|
||||
description: 'Triggers when a new form entry is submitted.',
|
||||
auth: cognitoFormsAuth,
|
||||
props: {
|
||||
webhookInstructions: Property.MarkDown({
|
||||
value: `
|
||||
To use this trigger, you need to manually set up a webhook in your Cognito Forms account:
|
||||
|
||||
1. Login to your Cognito Forms account.
|
||||
2. Select desired form and go to Form Settings.
|
||||
3. Enable **Post JSON Data to Website** and add following URL in **Submit Entry Endpoint** field:
|
||||
\`\`\`text
|
||||
{{webhookUrl}}
|
||||
\`\`\`
|
||||
4. Click Save to save the form changes.
|
||||
`,
|
||||
}),
|
||||
},
|
||||
type: TriggerStrategy.WEBHOOK,
|
||||
sampleData: undefined,
|
||||
async onEnable(context) {
|
||||
// No need to register webhooks programmatically as user will do it manually
|
||||
},
|
||||
async onDisable(context) {
|
||||
// No need to unregister webhooks as user will do it manually
|
||||
},
|
||||
|
||||
async run(context) {
|
||||
return [context.payload.body];
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user