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,33 @@
|
||||
{
|
||||
"extends": [
|
||||
"../../../../.eslintrc.base.json"
|
||||
],
|
||||
"ignorePatterns": [
|
||||
"!**/*"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.ts",
|
||||
"*.tsx",
|
||||
"*.js",
|
||||
"*.jsx"
|
||||
],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.ts",
|
||||
"*.tsx"
|
||||
],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.js",
|
||||
"*.jsx"
|
||||
],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# pieces-echowin
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
|
||||
## Building
|
||||
|
||||
Run `nx build pieces-echowin` to build the library.
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "@activepieces/piece-echowin",
|
||||
"version": "0.0.1",
|
||||
"type": "commonjs",
|
||||
"main": "./src/index.js",
|
||||
"types": "./src/index.d.ts",
|
||||
"dependencies": {
|
||||
"tslib": "^2.3.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "pieces-echowin",
|
||||
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "packages/pieces/community/echowin/src",
|
||||
"projectType": "library",
|
||||
"release": {
|
||||
"version": {
|
||||
"manifestRootsToUpdate": [
|
||||
"dist/{projectRoot}"
|
||||
],
|
||||
"currentVersionResolver": "git-tag",
|
||||
"fallbackCurrentVersionResolver": "disk"
|
||||
}
|
||||
},
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/js:tsc",
|
||||
"outputs": [
|
||||
"{options.outputPath}"
|
||||
],
|
||||
"options": {
|
||||
"outputPath": "dist/packages/pieces/community/echowin",
|
||||
"tsConfig": "packages/pieces/community/echowin/tsconfig.lib.json",
|
||||
"packageJson": "packages/pieces/community/echowin/package.json",
|
||||
"main": "packages/pieces/community/echowin/src/index.ts",
|
||||
"assets": [
|
||||
"packages/pieces/community/echowin/*.md",
|
||||
{
|
||||
"input": "packages/pieces/community/echowin/src/i18n",
|
||||
"output": "./src/i18n",
|
||||
"glob": "**/!(i18n.json)"
|
||||
}
|
||||
],
|
||||
"buildableProjectDepsInPackageJsonType": "dependencies",
|
||||
"updateBuildableProjectDepsInPackageJson": true
|
||||
},
|
||||
"dependsOn": [
|
||||
"prebuild",
|
||||
"^build"
|
||||
]
|
||||
},
|
||||
"nx-release-publish": {
|
||||
"options": {
|
||||
"packageRoot": "dist/{projectRoot}"
|
||||
}
|
||||
},
|
||||
"prebuild": {
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
],
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/pieces/community/echowin",
|
||||
"command": "bun install --no-save --silent"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"outputs": [
|
||||
"{options.outputFile}"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { createPiece } from '@activepieces/pieces-framework';
|
||||
import { echowinAuth } from './lib/common/auth';
|
||||
import { createContact } from './lib/actions/create-contact';
|
||||
import { findContactByName } from './lib/actions/find-contact-by-name';
|
||||
import { deleteContact } from './lib/actions/delete-contact';
|
||||
import { newContact } from './lib/triggers/new-contact';
|
||||
import { PieceCategory } from '@activepieces/shared';
|
||||
|
||||
export const echowin = createPiece({
|
||||
displayName: 'Echowin',
|
||||
auth: echowinAuth,
|
||||
minimumSupportedRelease: '0.36.1',
|
||||
logoUrl: 'https://cdn.activepieces.com/pieces/echowin.png',
|
||||
categories: [PieceCategory.ARTIFICIAL_INTELLIGENCE],
|
||||
authors: ['sanket-a11y'],
|
||||
actions: [createContact, deleteContact, findContactByName],
|
||||
triggers: [newContact],
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { echowinAuth } from '../common/auth';
|
||||
import { makeRequest } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
|
||||
export const createContact = createAction({
|
||||
auth: echowinAuth,
|
||||
name: 'createContact',
|
||||
displayName: 'Create Contact',
|
||||
description:
|
||||
'Create a new contact with optional tags, custom fields, notes, and board assignments',
|
||||
props: {
|
||||
firstName: Property.ShortText({
|
||||
displayName: 'First Name',
|
||||
description: "Contact's first name",
|
||||
required: false,
|
||||
}),
|
||||
lastName: Property.ShortText({
|
||||
displayName: 'Last Name',
|
||||
description: "Contact's last name",
|
||||
required: false,
|
||||
}),
|
||||
email: Property.ShortText({
|
||||
displayName: 'Email',
|
||||
description: "Contact's email address",
|
||||
required: false,
|
||||
}),
|
||||
number: Property.ShortText({
|
||||
displayName: 'Phone Number',
|
||||
description: 'Contact phone number (will be automatically cleaned)',
|
||||
required: true,
|
||||
}),
|
||||
carrier: Property.ShortText({
|
||||
displayName: 'Phone Carrier',
|
||||
description: 'Phone carrier name',
|
||||
required: false,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { firstName, lastName, email, number, carrier } =
|
||||
context.propsValue;
|
||||
|
||||
const payload: any = {
|
||||
number,
|
||||
};
|
||||
if (firstName) {
|
||||
payload.firstName = firstName;
|
||||
}
|
||||
if (lastName) {
|
||||
payload.lastName = lastName;
|
||||
}
|
||||
if (email) {
|
||||
payload.email = email;
|
||||
}
|
||||
if (carrier) {
|
||||
payload.carrier = carrier;
|
||||
}
|
||||
|
||||
const response = await makeRequest(
|
||||
context.auth.secret_text,
|
||||
HttpMethod.POST,
|
||||
'/contacts',
|
||||
payload
|
||||
);
|
||||
|
||||
return response.body;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { echowinAuth } from '../common/auth';
|
||||
import { makeRequest } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
|
||||
export const deleteContact = createAction({
|
||||
auth: echowinAuth,
|
||||
name: 'deleteContact',
|
||||
displayName: 'Delete Contact',
|
||||
description: 'Delete a contact by ID',
|
||||
props: {
|
||||
contactId: Property.ShortText({
|
||||
displayName: 'Contact ID',
|
||||
description: 'The unique identifier of the contact to delete',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { contactId } = context.propsValue;
|
||||
|
||||
const response = await makeRequest(
|
||||
context.auth.secret_text,
|
||||
HttpMethod.DELETE,
|
||||
`/contacts/${contactId}`
|
||||
);
|
||||
|
||||
return response.body;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { echowinAuth } from '../common/auth';
|
||||
import { makeRequest } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
|
||||
export const findContactByName = createAction({
|
||||
auth: echowinAuth,
|
||||
name: 'findContactByName',
|
||||
displayName: 'Find Contact ',
|
||||
description:
|
||||
'Get a paginated list of contacts and search by name, email, or phone number',
|
||||
props: {
|
||||
search: Property.ShortText({
|
||||
displayName: 'Search',
|
||||
description: 'Search contacts by name, email, or phone number',
|
||||
required: false,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { search } = context.propsValue;
|
||||
|
||||
const queryParams = new URLSearchParams();
|
||||
|
||||
if (search) {
|
||||
queryParams.append('search', search);
|
||||
}
|
||||
|
||||
const queryString = queryParams.toString();
|
||||
|
||||
const response = await makeRequest(
|
||||
context.auth.secret_text,
|
||||
HttpMethod.GET,
|
||||
`/contacts?${queryString}`
|
||||
);
|
||||
|
||||
return response.body;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import { PieceAuth } from '@activepieces/pieces-framework';
|
||||
|
||||
export const echowinAuth = PieceAuth.SecretText({
|
||||
displayName: 'Echowin API Key',
|
||||
description: 'API Key for Echowin. Get it from [Echowin Settings](https://echo.win/portal/settings/integrations)',
|
||||
required: true,
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { HttpMethod, httpClient } from '@activepieces/pieces-common';
|
||||
|
||||
export const BASE_URL = `https://echo.win/api/v1`;
|
||||
|
||||
export async function makeRequest(
|
||||
apiKey: string,
|
||||
method: HttpMethod,
|
||||
path: string,
|
||||
body?: unknown
|
||||
) {
|
||||
try {
|
||||
const response = await httpClient.sendRequest({
|
||||
method,
|
||||
url: `${BASE_URL}${path}`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-API-Key': apiKey,
|
||||
},
|
||||
body,
|
||||
});
|
||||
return response.body;
|
||||
} catch (error: any) {
|
||||
throw new Error(`Unexpected error: ${error.message || String(error)}`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import {
|
||||
createTrigger,
|
||||
TriggerStrategy,
|
||||
AppConnectionValueForAuthProperty,
|
||||
} from '@activepieces/pieces-framework';
|
||||
import {
|
||||
DedupeStrategy,
|
||||
HttpMethod,
|
||||
Polling,
|
||||
pollingHelper,
|
||||
} from '@activepieces/pieces-common';
|
||||
import { echowinAuth } from '../common/auth';
|
||||
import dayjs from 'dayjs';
|
||||
import { makeRequest } from '../common/client';
|
||||
|
||||
const polling: Polling<
|
||||
AppConnectionValueForAuthProperty<typeof echowinAuth>,
|
||||
Record<string, never>
|
||||
> = {
|
||||
strategy: DedupeStrategy.TIMEBASED,
|
||||
items: async ({ auth, lastFetchEpochMS }) => {
|
||||
const queryParams = new URLSearchParams({
|
||||
page: '1',
|
||||
limit: '100',
|
||||
sortBy: 'createdAt',
|
||||
sortOrder: 'desc',
|
||||
});
|
||||
|
||||
const response = await makeRequest(
|
||||
auth.secret_text,
|
||||
HttpMethod.GET,
|
||||
`/contacts?${queryParams.toString()}`
|
||||
);
|
||||
|
||||
const contacts = response.data;
|
||||
|
||||
return contacts
|
||||
.filter((contact: any) => {
|
||||
const createdAtEpoch = dayjs(contact.createdAt).valueOf();
|
||||
return createdAtEpoch > lastFetchEpochMS;
|
||||
})
|
||||
.map((contact: any) => ({
|
||||
epochMilliSeconds: dayjs(contact.createdAt).valueOf(),
|
||||
data: contact,
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
export const newContact = createTrigger({
|
||||
auth: echowinAuth,
|
||||
name: 'newContact',
|
||||
displayName: 'New Contact',
|
||||
description: 'Trigger when a new contact is created in Echowin',
|
||||
props: {},
|
||||
sampleData: {
|
||||
id: '123e4567-e89b-12d3-a456-426614174000',
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
email: 'john@example.com',
|
||||
number: '+15551234567',
|
||||
carrier: 'AT&T',
|
||||
customFields: {
|
||||
company: 'Acme Corp',
|
||||
role: 'Manager',
|
||||
},
|
||||
tags: [
|
||||
{
|
||||
id: 'tag-id-1',
|
||||
name: 'VIP',
|
||||
color: '#10B981',
|
||||
},
|
||||
{
|
||||
id: 'tag-id-2',
|
||||
name: 'Lead',
|
||||
color: '#3B82F6',
|
||||
},
|
||||
],
|
||||
crmStage: {
|
||||
id: 'stage-id',
|
||||
name: 'Lead',
|
||||
},
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
},
|
||||
type: TriggerStrategy.POLLING,
|
||||
async test(context) {
|
||||
return await pollingHelper.test(polling, context);
|
||||
},
|
||||
async onEnable(context) {
|
||||
const { store, auth, propsValue } = context;
|
||||
await pollingHelper.onEnable(polling, { store, auth, propsValue });
|
||||
},
|
||||
async onDisable(context) {
|
||||
const { store, auth, propsValue } = context;
|
||||
await pollingHelper.onDisable(polling, { store, auth, propsValue });
|
||||
},
|
||||
async run(context) {
|
||||
return await pollingHelper.poll(polling, context);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"importHelpers": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noPropertyAccessFromIndexSignature": true
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../../../dist/out-tsc",
|
||||
"declaration": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user