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,37 @@
import { activeCampaignAuth } from '../../..';
import { Property, createAction } from '@activepieces/pieces-framework';
import { activecampaignCommon, makeClient } from '../../common';
import { CreateAccountRequest } from '../../common/types';
export const createAccountAction = createAction({
auth: activeCampaignAuth,
name: 'activecampaign_create_account',
displayName: 'Create Account',
description: 'Creates a new account.',
props: {
name: Property.ShortText({
displayName: 'Account Name',
required: true,
}),
accountUrl: Property.ShortText({
displayName: 'Account URL',
required: false,
}),
accountCustomFields: activecampaignCommon.accountCustomFields,
},
async run(context) {
const { name, accountUrl, accountCustomFields } = context.propsValue;
const createAccountParams: CreateAccountRequest = {
name,
accountUrl,
fields: [],
};
Object.entries(accountCustomFields).forEach(([key, value]) => {
createAccountParams.fields?.push({ customFieldId: Number(key), fieldValue: value });
});
const client = makeClient(context.auth.props);
return await client.createAccount(createAccountParams);
},
});

View File

@@ -0,0 +1,38 @@
import { activeCampaignAuth } from '../../..';
import { Property, createAction } from '@activepieces/pieces-framework';
import { activecampaignCommon, makeClient } from '../../common';
import { CreateAccountRequest } from '../../common/types';
export const updateAccountAction = createAction({
auth: activeCampaignAuth,
name: 'activecampaign_update_account',
displayName: 'Update Account',
description: 'Updates an account.',
props: {
accountId: activecampaignCommon.accountId,
name: Property.ShortText({
displayName: 'Account Name',
required: false,
}),
accountUrl: Property.ShortText({
displayName: 'Account URL',
required: false,
}),
accountCustomFields: activecampaignCommon.accountCustomFields,
},
async run(context) {
const { accountId, name, accountUrl, accountCustomFields } = context.propsValue;
const updateAccountParams: Partial<CreateAccountRequest> = {
name,
accountUrl,
fields: [],
};
Object.entries(accountCustomFields).forEach(([key, value]) => {
updateAccountParams.fields?.push({ customFieldId: Number(key), fieldValue: value });
});
const client = makeClient(context.auth.props);
return await client.updateAccount(Number(accountId), updateAccountParams);
},
});

View File

@@ -0,0 +1,29 @@
import { activeCampaignAuth } from '../../..';
import { Property, createAction } from '@activepieces/pieces-framework';
import { activecampaignCommon, makeClient } from '../../common';
export const addContactToAccountAction = createAction({
auth: activeCampaignAuth,
name: 'activecampaign_add_contact_to_account',
displayName: 'Add Contact to Account',
description: 'Adds a contact to an ActiveCampaign account.',
props: {
contactId: activecampaignCommon.contactId,
accountId: activecampaignCommon.accountId,
jobTitle: Property.ShortText({
displayName: 'Job Title',
required: false,
}),
},
async run(context) {
const { contactId, accountId, jobTitle } = context.propsValue;
const client = makeClient(context.auth.props);
return await client.createAccountContactAssociation(
Number(contactId),
Number(accountId),
jobTitle,
);
},
});

View File

@@ -0,0 +1,20 @@
import { activeCampaignAuth } from '../../..';
import { createAction } from '@activepieces/pieces-framework';
import { activecampaignCommon, makeClient } from '../../common';
export const addTagToContactAction = createAction({
auth: activeCampaignAuth,
name: 'activecampaign_add_tag_to_contact',
displayName: 'Add Tag to Contact',
description: 'Adds a tag to contact.',
props: {
contactId: activecampaignCommon.contactId,
tagId: activecampaignCommon.tagId,
},
async run(context) {
const { contactId, tagId } = context.propsValue;
const client = makeClient(context.auth.props);
return await client.addTagToContact(contactId, tagId);
},
});

View File

@@ -0,0 +1,48 @@
import { activeCampaignAuth } from '../../../';
import { Property, createAction } from '@activepieces/pieces-framework';
import { activecampaignCommon, makeClient } from '../../common';
import { CreateContactRequest } from '../../common/types';
export const createContactAction = createAction({
auth: activeCampaignAuth,
name: 'activecampaign_create_contact',
displayName: 'Create Contact',
description: 'Creates a new contact.',
props: {
email: Property.ShortText({
displayName: 'Email',
required: true,
}),
firstName: Property.ShortText({
displayName: 'First Name',
required: false,
}),
lastName: Property.ShortText({
displayName: 'Last Name',
required: false,
}),
phone: Property.ShortText({
displayName: 'Phone',
required: false,
}),
contactCustomFields: activecampaignCommon.contactCustomFields,
},
async run(context) {
const { email, firstName, lastName, phone, contactCustomFields } = context.propsValue;
const createContactParams: CreateContactRequest = {
email,
firstName,
lastName,
phone,
fieldValues: [],
};
Object.entries(contactCustomFields).forEach(([key, value]) => {
createContactParams.fieldValues.push({ field: key, value: value });
});
const client = makeClient(context.auth.props);
return await client.createContact(createContactParams);
},
});

View File

@@ -0,0 +1,41 @@
import { activeCampaignAuth } from '../../../';
import { Property, createAction } from '@activepieces/pieces-framework';
import { activecampaignCommon, makeClient } from '../../common';
export const subscribeOrUnsubscribeContactFromListAction = createAction({
auth: activeCampaignAuth,
name: 'activecampaign_subscribe_or_unsubscribe_contact_from_list',
displayName: 'Subscribe or Unsubscribe Contact From List',
description:
'Subscribes a Contact to a List it is not currently associated with, or Unsubscribes a Contact from a list is currently associated with.',
props: {
listId: activecampaignCommon.listId(true),
status: Property.StaticDropdown({
displayName: 'Action',
required: true,
options: {
disabled: false,
options: [
{
label: 'Subscribe',
value: '1',
},
{
label: 'Unsubscribe',
value: '2',
},
],
},
}),
contactId: Property.ShortText({
displayName: 'Contact ID',
required: true,
}),
},
async run(context) {
const { listId, status, contactId } = context.propsValue;
const client = makeClient(context.auth.props);
return await client.addContactToList(listId!, contactId, status);
},
});

View File

@@ -0,0 +1,50 @@
import { activeCampaignAuth } from '../../../';
import { Property, createAction } from '@activepieces/pieces-framework';
import { activecampaignCommon, makeClient } from '../../common';
import { CreateContactRequest } from '../../common/types';
export const updateContactAction = createAction({
auth: activeCampaignAuth,
name: 'activecampaign_update_contact',
displayName: 'Update Contact',
description: 'Updates an existing contact.',
props: {
contactId: activecampaignCommon.contactId,
email: Property.ShortText({
displayName: 'Email',
required: false,
}),
firstName: Property.ShortText({
displayName: 'First Name',
required: false,
}),
lastName: Property.ShortText({
displayName: 'Last Name',
required: false,
}),
phone: Property.ShortText({
displayName: 'Phone',
required: false,
}),
contactCustomFields: activecampaignCommon.contactCustomFields,
},
async run(context) {
const { email, contactId, firstName, lastName, phone, contactCustomFields } =
context.propsValue;
const updateContactParams: Partial<CreateContactRequest> = {
email,
firstName,
lastName,
phone,
fieldValues: [],
};
Object.entries(contactCustomFields).forEach(([key, value]) => {
updateContactParams.fieldValues?.push({ field: key, value: value });
});
const client = makeClient(context.auth.props);
return await client.updateContact(Number(contactId), updateContactParams);
},
});

View File

@@ -0,0 +1,148 @@
import {
HttpMessageBody,
HttpMethod,
QueryParams,
httpClient,
HttpRequest,
} from '@activepieces/pieces-common';
import {
AccountCustomFieldsResponse,
ContactCustomFieldsResponse,
ContactList,
CreateAccountRequest,
CreateContactRequest,
CreateWebhookRequest,
CreateWebhookResponse,
ListAccountsResponse,
ListContactsResponse,
ListTagsResponse,
} from './types';
function emptyValueFilter(accessor: (key: string) => any): (key: string) => boolean {
return (key: string) => {
const val = accessor(key);
return val !== null && val !== undefined && (typeof val != 'string' || val.length > 0);
};
}
export function prepareQuery(request?: Record<string, any>): QueryParams {
const params: QueryParams = {};
if (!request) return params;
Object.keys(request)
.filter(emptyValueFilter((k) => request[k]))
.forEach((k: string) => {
params[k] = (request as Record<string, any>)[k].toString();
});
return params;
}
export class ActiveCampaignClient {
constructor(private apiUrl: string, private apiKey: string) {}
async makeRequest<T extends HttpMessageBody>(
method: HttpMethod,
resourceUri: string,
query?: QueryParams,
body: any | undefined = undefined,
): Promise<T> {
const baseUrl = this.apiUrl.replace(/\/$/, '');
const request: HttpRequest = {
method: method,
url: baseUrl + '/api/3' + resourceUri,
headers: {
'Api-Token': this.apiKey,
},
queryParams: query,
body: body,
};
const res = await httpClient.sendRequest<T>(request);
return res.body;
}
async authenticate() {
return await this.makeRequest(HttpMethod.GET, '/users/me');
}
async subscribeWebhook(request: CreateWebhookRequest): Promise<CreateWebhookResponse> {
return await this.makeRequest<CreateWebhookResponse>(HttpMethod.POST, '/webhooks', undefined, {
webhook: request,
});
}
async unsubscribeWebhook(webhookId: string) {
return await this.makeRequest(HttpMethod.DELETE, `/webhooks/${webhookId}`);
}
async listContactLists() {
return await this.makeRequest<{ lists: ContactList[] }>(
HttpMethod.GET,
'/lists',
prepareQuery({ limit: 20 }),
);
}
async createAccount(request: CreateAccountRequest) {
return await this.makeRequest(HttpMethod.POST, '/accounts', undefined, { account: request });
}
async updateAccount(accountId: number, request: Partial<CreateAccountRequest>) {
return await this.makeRequest(HttpMethod.PUT, `/accounts/${accountId}`, undefined, {
account: request,
});
}
async listAccounts(search?: string): Promise<ListAccountsResponse> {
return await this.makeRequest<ListAccountsResponse>(
HttpMethod.GET,
'/accounts',
prepareQuery({ search: search }),
);
}
async listAccountCustomFields() {
return await this.makeRequest<{ accountCustomFieldMeta: AccountCustomFieldsResponse[] }>(
HttpMethod.GET,
'/accountCustomFieldMeta',
);
}
async createContact(request: CreateContactRequest) {
return await this.makeRequest(HttpMethod.POST, '/contacts', undefined, { contact: request });
}
async updateContact(contactId: number, request: Partial<CreateContactRequest>) {
return await this.makeRequest(HttpMethod.PUT, `/contacts/${contactId}`, undefined, {
contact: request,
});
}
async listContacts(): Promise<ListContactsResponse> {
return await this.makeRequest<ListContactsResponse>(HttpMethod.GET, '/contacts');
}
async listContactCustomFields(): Promise<ContactCustomFieldsResponse> {
return await this.makeRequest<ContactCustomFieldsResponse>(HttpMethod.GET, '/fields');
}
async addContactToList(listId: string, contactId: string, status: string) {
return await this.makeRequest(HttpMethod.POST, '/contactLists', undefined, {
contactList: { list: listId, contact: contactId, status: status },
});
}
async createAccountContactAssociation(contactId: number, accountId: number, jobTitle?: string) {
return await this.makeRequest(HttpMethod.POST, '/accountContacts', undefined, {
accountContact: { contact: contactId, account: accountId, jobTitle: jobTitle },
});
}
async addTagToContact(contactId: string, tagId: string) {
return await this.makeRequest(HttpMethod.POST, '/contactTags', undefined, {
contactTag: { contact: contactId, tag: tagId },
});
}
async listTags(): Promise<ListTagsResponse> {
return await this.makeRequest<ListTagsResponse>(HttpMethod.GET, '/tags');
}
}

View File

@@ -0,0 +1,16 @@
export const WEBHOOK_SOURCES = ['public', 'admin', 'api', 'system'];
export enum CUSTOM_FIELD_TYPE {
TEXT = 'text',
DROPDOWN = 'dropdown',
TEXTAREA = 'textarea',
NUMBER = 'number',
MONEY = 'currency',
DATE = 'date',
DATETIME = 'datetime',
LIST_BOX = 'listbox',
MULTISELECT = 'multiselect',
RADIO = 'radio',
CHECKBOX = 'checkbox',
HIDDEN = 'hidden',
}

View File

@@ -0,0 +1,299 @@
import { activeCampaignAuth } from '../../';
import { AppConnectionValueForAuthProperty, DynamicPropsValue, PiecePropValueSchema, Property } from '@activepieces/pieces-framework';
import { ActiveCampaignClient } from './client';
import { CUSTOM_FIELD_TYPE } from './constants';
export function makeClient(auth: PiecePropValueSchema<typeof activeCampaignAuth>) {
const client = new ActiveCampaignClient(auth.apiUrl, auth.apiKey);
return client;
}
export const activecampaignCommon = {
listId: (required = false) =>
Property.Dropdown({
auth: activeCampaignAuth,
displayName: 'List',
required,
refreshers: [],
options: async ({ auth }) => {
if (!auth) {
return {
disabled: true,
placeholder: 'Please connect your account first',
options: [],
};
}
const client = makeClient(auth.props);
const res = await client.listContactLists();
return {
disabled: false,
options: res.lists.map((list) => {
return {
label: list.name,
value: list.id,
};
}),
};
},
}),
accountId: Property.Dropdown({
auth: activeCampaignAuth,
displayName: 'Account ID',
required: true,
refreshers: [],
options: async ({ auth }) => {
if (!auth) {
return {
disabled: true,
placeholder: 'Please connect your account first',
options: [],
};
}
const client = makeClient(auth.props);
const res = await client.listAccounts();
return {
disabled: false,
options: res.accounts.map((account) => {
return {
label: account.name,
value: account.id,
};
}),
};
},
}),
contactId: Property.Dropdown({
auth: activeCampaignAuth,
displayName: 'Contact ID',
required: true,
refreshers: [],
options: async ({ auth }) => {
if (!auth) {
return {
disabled: true,
placeholder: 'Please connect your account first',
options: [],
};
}
const client = makeClient((auth as AppConnectionValueForAuthProperty<typeof activeCampaignAuth>).props);
const res = await client.listContacts();
return {
disabled: false,
options: res.contacts.map((contact) => {
return {
label: contact.firstName && contact.lastName ? `${contact.firstName} ${contact.lastName}` : contact.email,
value: contact.id,
};
}),
};
},
}),
tagId: Property.Dropdown({
auth: activeCampaignAuth,
displayName: 'Tag ID',
required: true,
refreshers: [],
options: async ({ auth }) => {
if (!auth) {
return {
disabled: true,
placeholder: 'Please connect your account first',
options: [],
};
}
const client = makeClient(auth.props);
const res = await client.listTags();
return {
disabled: false,
options: res.tags.map((tag) => {
return {
label: tag.tag,
value: tag.id,
};
}),
};
},
}),
accountCustomFields: Property.DynamicProperties({
auth: activeCampaignAuth,
displayName: 'Account Custom Fields',
refreshers: [],
required: true,
props: async ({ auth }) => {
if (!auth) return {};
const client = makeClient(auth.props);
const res = await client.listAccountCustomFields();
const fields: DynamicPropsValue = {};
for (const field of res.accountCustomFieldMeta) {
switch (field.fieldType) {
case CUSTOM_FIELD_TYPE.TEXT:
case CUSTOM_FIELD_TYPE.HIDDEN:
fields[field.id] = Property.ShortText({
displayName: field.fieldLabel,
required: false,
});
break;
case CUSTOM_FIELD_TYPE.TEXTAREA:
fields[field.id] = Property.LongText({
displayName: field.fieldLabel,
required: false,
});
break;
case CUSTOM_FIELD_TYPE.DATE:
fields[field.id] = Property.DateTime({
displayName: field.fieldLabel,
description: 'Please use YYYY-MM-DD format.',
required: false,
});
break;
case CUSTOM_FIELD_TYPE.DATETIME:
fields[field.id] = Property.DateTime({
displayName: field.fieldLabel,
required: false,
});
break;
case CUSTOM_FIELD_TYPE.MONEY:
case CUSTOM_FIELD_TYPE.NUMBER:
fields[field.id] = Property.Number({
displayName: field.fieldLabel,
required: false,
});
break;
case CUSTOM_FIELD_TYPE.DROPDOWN:
case CUSTOM_FIELD_TYPE.RADIO:
fields[field.id] = Property.StaticDropdown({
displayName: field.fieldLabel,
required: false,
options: {
disabled: false,
options: field.fieldOptions
? field.fieldOptions?.map((option) => {
return {
label: option,
value: option,
};
})
: [],
},
});
break;
case CUSTOM_FIELD_TYPE.CHECKBOX:
case CUSTOM_FIELD_TYPE.LIST_BOX:
case CUSTOM_FIELD_TYPE.MULTISELECT:
fields[field.id] = Property.StaticMultiSelectDropdown({
displayName: field.fieldLabel,
required: false,
options: {
disabled: false,
options: field.fieldOptions
? field.fieldOptions?.map((option) => {
return {
label: option,
value: option,
};
})
: [],
},
});
break;
}
}
return fields;
},
}),
contactCustomFields: Property.DynamicProperties({
auth: activeCampaignAuth,
displayName: 'Contact Custom Fields',
refreshers: [],
required: true,
props: async ({ auth }) => {
if (!auth) return {};
const client = makeClient(auth.props);
const res = await client.listContactCustomFields();
const fields: DynamicPropsValue = {};
for (const field of res.fields) {
switch (field.type) {
case CUSTOM_FIELD_TYPE.TEXT:
case CUSTOM_FIELD_TYPE.HIDDEN:
fields[field.id] = Property.ShortText({
displayName: field.title,
required: false,
});
break;
case CUSTOM_FIELD_TYPE.TEXTAREA:
fields[field.id] = Property.LongText({
displayName: field.title,
required: false,
});
break;
case CUSTOM_FIELD_TYPE.DATE:
fields[field.id] = Property.DateTime({
displayName: field.title,
description: 'Please use YYYY-MM-DD format.',
required: false,
});
break;
case CUSTOM_FIELD_TYPE.DATETIME:
fields[field.id] = Property.DateTime({
displayName: field.title,
required: false,
});
break;
case CUSTOM_FIELD_TYPE.MONEY:
case CUSTOM_FIELD_TYPE.NUMBER:
fields[field.id] = Property.Number({
displayName: field.title,
required: false,
});
break;
case CUSTOM_FIELD_TYPE.DROPDOWN:
case CUSTOM_FIELD_TYPE.RADIO:
fields[field.id] = Property.StaticDropdown({
displayName: field.title,
required: false,
options: {
disabled: false,
options: res.fieldOptions
.filter((option) => option.field === field.id)
.map((option) => {
return {
label: option.label,
value: option.value,
};
}),
},
});
break;
case CUSTOM_FIELD_TYPE.CHECKBOX:
case CUSTOM_FIELD_TYPE.LIST_BOX:
case CUSTOM_FIELD_TYPE.MULTISELECT:
fields[field.id] = Property.StaticMultiSelectDropdown({
displayName: field.title,
required: false,
options: {
disabled: false,
options: res.fieldOptions
.filter((option) => option.field === field.id)
.map((option) => {
return {
label: option.label,
value: option.value,
};
}),
},
});
break;
}
}
return fields;
},
}),
};

View File

@@ -0,0 +1,83 @@
import { CUSTOM_FIELD_TYPE } from './constants';
export type CreateWebhookRequest = {
name: string;
url: string;
events: string[];
sources: string[];
listid?: string;
};
export type CreateWebhookResponse = {
webhook: {
name: string;
url: string;
events: string[];
sources: string[];
listid: string;
cdate: string;
state: string;
id: string;
};
};
export type ContactList = {
id: string;
name: string;
};
export type CreateAccountRequest = {
name: string;
accountUrl?: string;
fields?: {
customFieldId: number;
fieldValue: any;
}[];
};
export type CreateContactRequest = {
email: string;
firstName?: string;
lastName?: string;
phone?: string;
fieldValues: {
field: string;
value: any;
}[];
};
export type ListAccountsResponse = {
accounts: {
name: string;
id: string;
}[];
};
export type ListContactsResponse = {
contacts: {
email: string;
firstName: string;
lastName: string;
id: string;
}[];
};
export type ListTagsResponse = {
tags: {
tagType: string;
tag: string;
id: string;
}[];
};
export type AccountCustomFieldsResponse = {
id: string;
fieldLabel: string;
fieldType: CUSTOM_FIELD_TYPE;
fieldOptions?: string[];
fieldDefaultCurrency?: string;
fieldDefault?: number | string | string[];
};
export type ContactCustomFieldsResponse = {
fieldOptions: { field: string; value: string; label: string; id: string }[];
fields: { id: string; title: string; type: CUSTOM_FIELD_TYPE; options: string[] }[];
};

View File

@@ -0,0 +1,84 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const campaignLinkClickedTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_campaign_link_clicked',
displayName: 'New Campaign Link Click',
description:
'Triggers when a contact clicks a link in a campaign message (will only run once for each unique link).',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces Deal Task Completed Hook`,
url: context.webhookUrl,
events: ['click'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>('activecampaign_campaign_link_clicked', res);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>(
'activecampaign_campaign_link_clicked',
);
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'deal_update',
date_time: '2024-02-28T04:45:41-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
contact: {
id: '3',
email: 'code.test@gmail.com',
first_name: 'John',
last_name: 'Wick',
phone: '',
ip: '0.0.0.0',
tags: '1233',
customer_acct_name: '',
orgname: '',
},
customer_acct_name: '',
customer_acct_id: '0',
orgname: '',
deal: {
id: '1',
title: 'Test Deal',
create_date: '2024-02-28 04:36:09',
create_date_iso: '2024-02-28T04:36:09-06:00',
orgid: '1',
orgname: 'John Wick',
stageid: '1',
stage_title: 'To Contact',
pipelineid: '1',
pipeline_title: 'Test Pipeline',
value: '1,044,055.00',
value_raw: '1044055',
currency: 'usd',
currency_symbol: '$',
owner: '1',
owner_firstname: 'John',
owner_lastname: 'Wick',
contactid: '3',
contact_email: 'code.test@gmail.com',
contact_firstname: 'John',
contact_lastname: 'Wick',
status: '0',
fields: [{ id: '1', key: 'Forecasted Close Date', value: '2024-02-08 00:00:00' }],
},
updated_fields: ['value'],
},
});

View File

@@ -0,0 +1,83 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const dealTaskCompletedTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_deal_task_completed',
displayName: 'Deal Task Completed',
description: 'Triggers when a deal task has been completed.',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces Deal Task Completed Hook`,
url: context.webhookUrl,
events: ['deal_task_complete'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>('activecampaign_deal_task_completed', res);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>(
'activecampaign_deal_task_completed',
);
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'deal_update',
date_time: '2024-02-28T04:45:41-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
contact: {
id: '3',
email: 'code.test@gmail.com',
first_name: 'John',
last_name: 'Wick',
phone: '',
ip: '0.0.0.0',
tags: '1233',
customer_acct_name: '',
orgname: '',
},
customer_acct_name: '',
customer_acct_id: '0',
orgname: '',
deal: {
id: '1',
title: 'Test Deal',
create_date: '2024-02-28 04:36:09',
create_date_iso: '2024-02-28T04:36:09-06:00',
orgid: '1',
orgname: 'John Wick',
stageid: '1',
stage_title: 'To Contact',
pipelineid: '1',
pipeline_title: 'Test Pipeline',
value: '1,044,055.00',
value_raw: '1044055',
currency: 'usd',
currency_symbol: '$',
owner: '1',
owner_firstname: 'John',
owner_lastname: 'Wick',
contactid: '3',
contact_email: 'code.test@gmail.com',
contact_firstname: 'John',
contact_lastname: 'Wick',
status: '0',
fields: [{ id: '1', key: 'Forecasted Close Date', value: '2024-02-08 00:00:00' }],
},
updated_fields: ['value'],
},
});

View File

@@ -0,0 +1,83 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const newCampaignBounceTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_new_campaign_bounce',
displayName: 'New Campaign Bounce',
description: 'Triggers when a contact email address bounces from a sent campaign.',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces Campaign Bounce Hook`,
url: context.webhookUrl,
events: ['bounce'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>('activecampaign_new_campaign_bounce', res);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>(
'activecampaign_new_campaign_bounce',
);
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'deal_update',
date_time: '2024-02-28T04:45:41-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
contact: {
id: '3',
email: 'code.test@gmail.com',
first_name: 'John',
last_name: 'Wick',
phone: '',
ip: '0.0.0.0',
tags: '1233',
customer_acct_name: '',
orgname: '',
},
customer_acct_name: '',
customer_acct_id: '0',
orgname: '',
deal: {
id: '1',
title: 'Test Deal',
create_date: '2024-02-28 04:36:09',
create_date_iso: '2024-02-28T04:36:09-06:00',
orgid: '1',
orgname: 'John Wick',
stageid: '1',
stage_title: 'To Contact',
pipelineid: '1',
pipeline_title: 'Test Pipeline',
value: '1,044,055.00',
value_raw: '1044055',
currency: 'usd',
currency_symbol: '$',
owner: '1',
owner_firstname: 'John',
owner_lastname: 'Wick',
contactid: '3',
contact_email: 'code.test@gmail.com',
contact_firstname: 'John',
contact_lastname: 'Wick',
status: '0',
fields: [{ id: '1', key: 'Forecasted Close Date', value: '2024-02-08 00:00:00' }],
},
updated_fields: ['value'],
},
});

View File

@@ -0,0 +1,58 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const newContactNoteTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_new_contact_note',
displayName: 'New Contact Note',
description: 'Triggers when a new contact note is added.',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces New Contact Note Hook`,
url: context.webhookUrl,
events: ['subscriber_note'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>('activecampaign_new_contact_note', res);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>(
'activecampaign_new_contact_note',
);
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'subscriber_note',
date_time: '2024-02-28T06:58:11-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
note: 'test note',
contact: {
id: '3',
email: 'code.test@gmail.com',
first_name: 'john',
last_name: 'wick',
phone: '',
ip: '0.0.0.0',
tags: '1233',
customer_acct_name: '',
orgname: '',
},
customer_acct_name: '',
customer_acct_id: '0',
orgname: '',
},
});

View File

@@ -0,0 +1,68 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const newContactTaskTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_new_contact_task',
displayName: 'New Contact Task',
description: 'Triggers when a new contact task is added.',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces New Contact Task Hook`,
url: context.webhookUrl,
events: ['contact_task_add'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>('activecampaign_new_contact_task', res);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>(
'activecampaign_new_contact_task',
);
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'contact_task_add',
date_time: '2024-02-28T07:00:57-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
contact: {
id: '3',
email: 'code.test@gmail.com',
first_name: 'John',
last_name: 'Wick',
phone: '',
ip: '0.0.0.0',
tags: '1233',
customer_acct_name: '',
orgname: '',
},
customer_acct_name: '',
customer_acct_id: '0',
orgname: '',
task: {
id: '7',
type_id: '1',
title: 'test task',
note: 'Desc',
duedate: '2024-02-28 07:00:48',
duedate_iso: '2024-02-28T07:00:48-06:00',
edate: '2024-02-28 07:15:48',
edate_iso: '2024-02-28T07:15:48-06:00',
type_title: 'Call',
},
},
});

View File

@@ -0,0 +1,83 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const newDealAddedOrUpdatedTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_new_deal_added_or_updated',
displayName: 'New Deal Added or Updated',
description: 'Triggers when a new deal is created or existing deal is updated.',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces New Deal Hook`,
url: context.webhookUrl,
events: ['deal_add', 'deal_update'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>('activecampaign_new_deal_added_or_updated', res);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>(
'activecampaign_new_deal_added_or_updated',
);
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'deal_update',
date_time: '2024-02-28T04:45:41-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
contact: {
id: '3',
email: 'code.test@gmail.com',
first_name: 'John',
last_name: 'Wick',
phone: '',
ip: '0.0.0.0',
tags: '1233',
customer_acct_name: '',
orgname: '',
},
customer_acct_name: '',
customer_acct_id: '0',
orgname: '',
deal: {
id: '1',
title: 'Test Deal',
create_date: '2024-02-28 04:36:09',
create_date_iso: '2024-02-28T04:36:09-06:00',
orgid: '1',
orgname: 'John Wick',
stageid: '1',
stage_title: 'To Contact',
pipelineid: '1',
pipeline_title: 'Test Pipeline',
value: '1,044,055.00',
value_raw: '1044055',
currency: 'usd',
currency_symbol: '$',
owner: '1',
owner_firstname: 'John',
owner_lastname: 'Wick',
contactid: '3',
contact_email: 'code.test@gmail.com',
contact_firstname: 'John',
contact_lastname: 'Wick',
status: '0',
fields: [{ id: '1', key: 'Forecasted Close Date', value: '2024-02-08 00:00:00' }],
},
updated_fields: ['value'],
},
});

View File

@@ -0,0 +1,67 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const newDealNoteTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_new_deal_note',
displayName: 'New Deal Note',
description: 'Triggers when a new deal note is created.',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces New Deal Note Hook`,
url: context.webhookUrl,
events: ['deal_note_add'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>('activecampaign_new_deal_note', res);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>('activecampaign_new_deal_note');
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'deal_note_add',
date_time: '2024-02-28T05:58:27-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
note: { id: '1', text: 'Tst node' },
deal: {
id: '1',
title: 'Test Deal updated',
create_date: '2024-02-28 04:36:09',
create_date_iso: '2024-02-28T04:36:09-06:00',
orgid: '1',
orgname: 'John wick',
stageid: '1',
stage_title: 'To Contact',
pipelineid: '1',
pipeline_title: 'Test Pipeline',
value: '14,055.00',
value_raw: '14055',
currency: 'usd',
currency_symbol: '$',
owner: '1',
owner_firstname: 'John',
owner_lastname: 'wick',
contactid: '3',
contact_email: 'code.test@gmail.com',
contact_firstname: 'John',
contact_lastname: 'wick',
status: '0',
fields: [{ id: '1', key: 'Forecasted Close Date', value: '2024-02-08 00:00:00' }],
},
},
});

View File

@@ -0,0 +1,91 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const newDealTaskTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_new_deal_task',
displayName: 'New Deal Task',
description: 'Triggers when a new deal task is created.',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces New Deal Task Hook`,
url: context.webhookUrl,
events: ['deal_task_add'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>('activecampaign_new_deal_task', res);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>('activecampaign_new_deal_task');
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'deal_task_add',
date_time: '2024-02-28T06:38:49-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
contact: {
id: '3',
email: 'code.test@gmail.com',
first_name: 'john',
last_name: 'wick',
phone: '',
ip: '0.0.0.0',
tags: '1233',
customer_acct_name: '',
orgname: '',
},
customer_acct_name: '',
customer_acct_id: '0',
orgname: '',
deal: {
id: '1',
title: 'Test Deal updated',
create_date: '2024-02-28 04:36:09',
create_date_iso: '2024-02-28T04:36:09-06:00',
orgid: '1',
orgname: 'john wick',
stageid: '1',
stage_title: 'To Contact',
pipelineid: '1',
pipeline_title: 'Test Pipeline',
value: '14,055.00',
value_raw: '14055',
currency: 'usd',
currency_symbol: '$',
owner: '1',
owner_firstname: 'john',
owner_lastname: 'wick',
contactid: '3',
contact_email: 'code.test@gmail.com',
contact_firstname: 'john',
contact_lastname: 'wick',
status: '0',
fields: [{ id: '1', key: 'Forecasted Close Date', value: '2024-02-08 00:00:00' }],
},
task: {
id: '6',
type_id: '1',
title: 'TEST TASK',
note: 'fsfssssf',
duedate: '2024-02-28 06:38:41',
duedate_iso: '2024-02-28T06:38:41-06:00',
edate: '2024-02-28 06:53:41',
edate_iso: '2024-02-28T06:53:41-06:00',
type_title: 'Call',
},
},
});

View File

@@ -0,0 +1,75 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const newOrUpdatedAccountTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_new_or_updated_account',
displayName: 'New or Updated Account',
description: 'Triggers when a new account is added or an existing accounts details are updated',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces New Account Hook`,
url: context.webhookUrl,
events: ['account_add', 'account_update'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>('activecampaign_new_or_updated_account', res);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>(
'activecampaign_new_or_updated_account',
);
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'account_update',
date_time: '2024-02-28T06:44:32-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
account: {
id: '1',
name: 'John Wick',
account_url: 'https://www.github.com',
created_timestamp: '2024-02-28 01:09:17',
updated_timestamp: '2024-02-28 06:44:32',
fields: {
'0': { id: '1', key: 'Description', value: 'Desc' },
'1': { id: '2', key: 'Address 1', value: 'Address 1' },
'2': { id: '3', key: 'Address 2', value: 'Address 2' },
'3': { id: '4', key: 'City', value: 'City' },
'4': { id: '5', key: 'State/Province', value: 'State' },
'5': { id: '6', key: 'Postal Code', value: '75156' },
'6': { id: '7', key: 'Country', value: 'India' },
'7': { id: '8', key: 'Number of Employees', value: '101 - 500' },
'8': { id: '9', key: 'Annual Revenue', value: 'Less than 100K' },
'9': { id: '10', key: 'Industry/Vertical', value: 'Accounting/Financial' },
'10': { key: 'Phone Number', value: '' },
'11': { id: '11', key: 'Text Input', value: 'Text Input' },
'12': { id: '12', key: 'Text Area', value: 'Text Area' },
'13': { id: '13', key: 'Number', value: '18.000' },
'14': { id: '14', key: 'money', value: '18' },
'15': { id: '15', key: 'Date', value: '2024-02-28 00:00:00' },
'16': { key: 'Date Time', value: '' },
'17': { id: '16', key: 'Drop Down', value: 'Option 3' },
'18': { id: '17', key: 'List box', value: ['Option 1', 'Option 2'] },
'19': { id: '18', key: 'Radio Buttons', value: 'Option 1' },
'20': { id: '19', key: 'Check Box', value: ['Option 1', 'Option 2'] },
'21': { id: '20', key: 'Hidden', value: 'Hidden' },
},
},
updated_fields: ['name'],
},
});

View File

@@ -0,0 +1,61 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const newtagAddedOrRemovedFromContactTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_new_tag_added_or_removed_from_contact',
displayName: 'Tag Added or Removed From Contact',
description: 'Triggers when a a Tag is added or removed from a Contact',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces Contact Tag Hook`,
url: context.webhookUrl,
events: ['contact_tag_added', 'contact_tag_removed'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>(
'activecampaign_new_tag_added_or_removed_from_contact',
res,
);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>(
'activecampaign_new_tag_added_or_removed_from_contact',
);
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'contact_tag_added',
date_time: '2024-02-28T07:04:13-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
contact: {
id: '3',
email: 'code.test@gmail.com',
first_name: 'John',
last_name: 'Wick',
phone: '',
ip: '0.0.0.0',
tags: 'tag1, tag2',
customer_acct_name: '',
orgname: '',
},
customer_acct_name: '',
customer_acct_id: '0',
orgname: '',
tag: 'tag2',
},
});

View File

@@ -0,0 +1,58 @@
import { activeCampaignAuth } from '../..';
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { makeClient } from '../common';
import { CreateWebhookResponse } from '../common/types';
import { WEBHOOK_SOURCES } from '../common/constants';
export const updatedContactTrigger = createTrigger({
auth: activeCampaignAuth,
name: 'activecampaign_updated_contact',
displayName: 'Updated Contact',
description: 'Triggers when an existing contact details are updated.',
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
const client = makeClient(context.auth.props);
const res = await client.subscribeWebhook({
name: `Activepieces Updated Contact Hook`,
url: context.webhookUrl,
events: ['update'],
sources: WEBHOOK_SOURCES,
});
await context.store.put<CreateWebhookResponse>('activecampaign_updated_contact', res);
},
async run(context) {
return [context.payload.body];
},
async onDisable(context) {
const webhook = await context.store.get<CreateWebhookResponse>(
'activecampaign_updated_contact',
);
if (webhook != null) {
const client = makeClient(context.auth.props);
await client.unsubscribeWebhook(webhook.webhook.id);
}
},
sampleData: {
type: 'update',
date_time: '2024-02-28T07:16:48-06:00',
initiated_from: 'admin',
initiated_by: 'admin',
list: '0',
contact: {
id: '3',
email: 'code.test@gmail.com',
first_name: 'John',
last_name: 'Wick',
phone: '',
ip: '0.0.0.0',
tags: 'tag1, tag2',
fields: ['Option 1', '||Option 1||Option 2||'],
customer_acct_name: '',
orgname: '',
},
customer_acct_name: '',
customer_acct_id: '0',
orgname: '',
},
});