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,114 @@
import { Property, createAction } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { randomUUID } from 'crypto';
import { SEARCH_ENGINE_OPTIONS } from '../../common/search-engines';
import { serpstatApiCall } from '../../common/client';
import { serpstatAuth } from '../../common/auth';
export const getKeywords = createAction({
name: 'get_keywords',
auth: serpstatAuth,
displayName: 'Get Keywords',
description: 'Get keywords data from Serpstat > Keyword Analysis.',
props: {
query: Property.ShortText({
displayName: 'Query',
description: 'The search query to find keywords for',
required: true,
}),
se: Property.StaticDropdown({
displayName: 'Search Engine',
description: 'Search engine to use for keyword analysis',
required: true,
defaultValue: 'g_us',
options: {
options: SEARCH_ENGINE_OPTIONS,
},
}),
minusKeywords: Property.Array({
displayName: 'Minus Keywords',
description: 'List of keywords to exclude from the search',
required: false,
}),
withIntents: Property.Checkbox({
displayName: 'With Intents',
description: 'Include keyword intent (works for g_au and g_us only)',
required: false,
}),
sortField: Property.StaticDropdown({
displayName: 'Sort Field',
description: 'Field to sort by (any numeric fields in response data)',
required: false,
defaultValue: 'region_queries_count',
options: {
options: [
{ label: 'Region Queries Count', value: 'region_queries_count' },
{ label: 'Search Volume', value: 'search_volume' },
{ label: 'CPC', value: 'cpc' },
{ label: 'Competition', value: 'competition' },
{ label: 'Results Count', value: 'results_count' },
],
},
}),
sortOrder: Property.StaticDropdown({
displayName: 'Sort Order',
description: 'Sort direction',
required: false,
defaultValue: 'desc',
options: {
options: [
{ label: 'Descending', value: 'desc' },
{ label: 'Ascending', value: 'asc' },
],
},
}),
size: Property.Number({
displayName: 'Size',
description: 'Number of results to return (max 100)',
required: false,
defaultValue: 10,
}),
page: Property.Number({
displayName: 'Page',
description: 'Page number for pagination',
required: false,
defaultValue: 1,
}),
filters: Property.Json({
displayName: 'Filters',
description: 'See the docs for syntax - https://api-docs.serpstat.com/docs/serpstat-public-api/w7jh5sk9kc0cm-get-keywords',
required: false,
}),
},
async run({ auth, propsValue }) {
const token = auth;
const id = randomUUID();
// Build params object
const params: Record<string, any> = {
keyword: propsValue['query'],
se: propsValue['se'],
page: propsValue['page'],
size: propsValue['size'],
};
if (propsValue['minusKeywords']) params['minusKeywords'] = propsValue['minusKeywords'];
if (propsValue['withIntents'] !== undefined) params['withIntents'] = propsValue['withIntents'];
if (propsValue['sortField'] && propsValue['sortOrder']) {
params['sort'] = { [propsValue['sortField']]: propsValue['sortOrder'] };
}
if (propsValue['filters']) params['filters'] = propsValue['filters'];
const body = {
id,
method: 'SerpstatKeywordProcedure.getKeywords',
params,
};
return await serpstatApiCall({
apiToken: token.secret_text,
method: HttpMethod.POST,
resourceUri: '/',
body,
});
},
});

View File

@@ -0,0 +1,72 @@
import { Property, createAction } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { randomUUID } from 'crypto';
import { SEARCH_ENGINE_OPTIONS } from '../../common/search-engines';
import { serpstatApiCall } from '../../common/client';
import { serpstatAuth } from '../../common/auth';
export const getSuggestions = createAction({
name: 'get_suggestions',
displayName: 'Get Suggestions',
description: 'Get keyword suggestions from Serpstat > Keyword Analysis.',
auth: serpstatAuth,
props: {
keyword: Property.ShortText({
displayName: 'Keyword',
description: 'The keyword to get suggestions for.',
required: true,
}),
se: Property.StaticDropdown({
displayName: 'Search Engine',
description: 'Search engine to use for suggestions.',
required: true,
defaultValue: 'g_us',
options: {
options: SEARCH_ENGINE_OPTIONS,
},
}),
filters: Property.Json({
displayName: 'Filters',
description: 'See the docs for syntax - https://api-docs.serpstat.com/docs/serpstat-public-api/mmd9zlcqjaoe4-get-suggestions',
required: false,
}),
page: Property.Number({
displayName: 'Page',
description: 'Page number in response.',
required: false,
defaultValue: 1,
}),
size: Property.Number({
displayName: 'Size',
description: 'Number of results per page in response.',
required: false,
defaultValue: 100,
}),
},
async run({ auth, propsValue }) {
const token = auth;
const id = randomUUID();
// Build params object
const params: Record<string, any> = {
keyword: propsValue['keyword'],
se: propsValue['se'],
page: propsValue['page'],
size: propsValue['size'],
};
if (propsValue['filters']) params['filters'] = propsValue['filters'];
const body = {
id,
method: 'SerpstatKeywordProcedure.getSuggestions',
params,
};
return await serpstatApiCall({
apiToken: token.secret_text,
method: HttpMethod.POST,
resourceUri: '/',
body,
});
},
});

View File

@@ -0,0 +1,31 @@
import { PieceAuth } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
export const serpstatAuth = PieceAuth.SecretText({
displayName: 'API Token',
description: `You can obtain your API token from your Serpstat account. Go to your Serpstat dashboard and navigate to API settings to get your token.`,
required: true,
validate: async ({ auth }) => {
try {
await httpClient.sendRequest({
method: HttpMethod.GET,
url: 'https://api.serpstat.com/v4/',
queryParams: {
token: auth,
},
});
return { valid: true };
} catch (error: any) {
if (error.response?.status === 401) {
return {
valid: false,
error: 'Invalid API token. Please check your token and try again.',
};
}
return {
valid: false,
error: 'Authentication failed. Please check your API token.',
};
}
},
});

View File

@@ -0,0 +1,35 @@
import { httpClient, HttpMethod, HttpRequest } from '@activepieces/pieces-common';
export const BASE_URL = 'https://api.serpstat.com/v4';
export interface SerpstatApiCallProps {
apiToken: string;
method: HttpMethod;
resourceUri: string;
queryParams?: Record<string, any>;
body?: any;
}
export const serpstatApiCall = async ({
apiToken,
method,
resourceUri,
queryParams,
body,
}: SerpstatApiCallProps) => {
const request: HttpRequest = {
method,
url: `${BASE_URL}${resourceUri}`,
headers: {
'Content-Type': 'application/json',
},
queryParams: {
token: apiToken,
...queryParams,
},
body,
};
const response = await httpClient.sendRequest(request);
return response.body;
};

View File

@@ -0,0 +1,8 @@
export const SEARCH_ENGINE_OPTIONS = [
{ label: 'United States', value: 'g_us' },
{ label: 'Singapore', value: 'g_sg' },
{ label: 'Indonesia', value: 'g_id' },
{ label: 'Malaysia', value: 'g_my' },
{ label: 'Vietnam', value: 'g_vn' },
{ label: 'Thailand', value: 'g_th' },
];