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,18 @@
{
"extends": ["../../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View File

@@ -0,0 +1,7 @@
# pieces-jotform
This library was generated with [Nx](https://nx.dev).
## Running lint
Run `nx lint pieces-jotform` to execute the lint via [ESLint](https://eslint.org/).

View File

@@ -0,0 +1,4 @@
{
"name": "@activepieces/piece-jotform",
"version": "0.1.9"
}

View File

@@ -0,0 +1,51 @@
{
"name": "pieces-jotform",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/pieces/community/jotform/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/packages/pieces/community/jotform",
"tsConfig": "packages/pieces/community/jotform/tsconfig.lib.json",
"packageJson": "packages/pieces/community/jotform/package.json",
"main": "packages/pieces/community/jotform/src/index.ts",
"assets": [
"packages/pieces/community/jotform/*.md",
{
"input": "packages/pieces/community/jotform/src/i18n",
"output": "./src/i18n",
"glob": "**/!(i18n.json)"
}
],
"buildableProjectDepsInPackageJsonType": "dependencies",
"updateBuildableProjectDepsInPackageJson": true
},
"dependsOn": [
"^build",
"prebuild"
]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}"
]
},
"prebuild": {
"executor": "nx:run-commands",
"options": {
"cwd": "packages/pieces/community/jotform",
"command": "bun install --no-save --silent"
},
"dependsOn": [
"^build"
]
}
},
"tags": []
}

View File

@@ -0,0 +1,29 @@
{
"Create online forms and surveys": "Online-Formulare und Umfragen erstellen",
"API Key": "API-Schlüssel",
"Region": "Region",
"US (api.jotform.com)": "US (api.jotform.com)",
"EU (eu-api.jotform.com)": "EU (eu-api.jotform.com)",
"HIPAA (hipaa-api.jotform.com)": "HIPAA (hipaa-api.jotform.com)",
"\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n": "\nUm api Schlüssel zu erhalten, folgen Sie den folgenden Schritten:\n1. Gehen Sie zu Einstellungen -> API\n2. Klicken Sie auf \"Neuen Schlüssel erstellen\" Knopf\n3. Ändern Sie die Berechtigungen auf \"Vollzugriff\"\n4. Kopieren Sie den API-Schlüssel und fügen Sie ihn in das API-Schlüsselfeld\n ein",
"Custom API Call": "Eigener API-Aufruf",
"Make a custom API call to a specific endpoint": "Einen benutzerdefinierten API-Aufruf an einen bestimmten Endpunkt machen",
"Method": "Methode",
"Headers": "Kopfzeilen",
"Query Parameters": "Abfrageparameter",
"Body": "Körper",
"Response is Binary ?": "Antwort ist binär?",
"No Error on Failure": "Kein Fehler bei Fehler",
"Timeout (in seconds)": "Timeout (in Sekunden)",
"Authorization headers are injected automatically from your connection.": "Autorisierungs-Header werden automatisch von Ihrer Verbindung injiziert.",
"Enable for files like PDFs, images, etc..": "Aktivieren für Dateien wie PDFs, Bilder, etc..",
"GET": "ERHALTEN",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "LÖSCHEN",
"HEAD": "HEAD",
"New Submission": "Neue Einreichung",
"Triggers when a new submission is submitted": "Wird ausgelöst, wenn eine neue Einreichung eingereicht wird",
"Form": "Formular"
}

View File

@@ -0,0 +1,29 @@
{
"Create online forms and surveys": "Crear formularios y encuestas en línea",
"API Key": "Clave API",
"Region": "Región",
"US (api.jotform.com)": "US (api.jotform.com)",
"EU (eu-api.jotform.com)": "EU (eu-api.jotform.com)",
"HIPAA (hipaa-api.jotform.com)": "HIPAA (hipaa-api.jotform.com)",
"\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n": "\nPara obtener la clave api, siga los siguientes pasos:\n1. Ve a Ajustes -> API\n2. Haz clic en el botón \"Crear nueva clave\"\n3. Cambie los permisos a \"Acceso completo\"\n4. Copie la clave API y péguela en el campo Clave API\n",
"Custom API Call": "Llamada API personalizada",
"Make a custom API call to a specific endpoint": "Hacer una llamada API personalizada a un extremo específico",
"Method": "Método",
"Headers": "Encabezados",
"Query Parameters": "Parámetros de consulta",
"Body": "Cuerpo",
"Response is Binary ?": "¿Respuesta es binaria?",
"No Error on Failure": "No hay ningún error en fallo",
"Timeout (in seconds)": "Tiempo de espera (en segundos)",
"Authorization headers are injected automatically from your connection.": "Las cabeceras de autorización se inyectan automáticamente desde tu conexión.",
"Enable for files like PDFs, images, etc..": "Activar para archivos como PDFs, imágenes, etc.",
"GET": "RECOGER",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "BORRAR",
"HEAD": "LIMPIO",
"New Submission": "Nuevo envío",
"Triggers when a new submission is submitted": "Dispara cuando se envía un nuevo envío",
"Form": "Forma"
}

View File

@@ -0,0 +1,29 @@
{
"Create online forms and surveys": "Créer des formulaires et des enquêtes en ligne",
"API Key": "Clé API",
"Region": "Région",
"US (api.jotform.com)": "US (api.jotform.com)",
"EU (eu-api.jotform.com)": "EU (eu-api.jotform.com)",
"HIPAA (hipaa-api.jotform.com)": "HIPAA (hipaa-api.jotform.com)",
"\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n": "\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n",
"Custom API Call": "Appel API personnalisé",
"Make a custom API call to a specific endpoint": "Passez un appel API personnalisé à un point de terminaison spécifique",
"Method": "Méthode",
"Headers": "En-têtes",
"Query Parameters": "Paramètres de requête",
"Body": "Corps",
"Response is Binary ?": "La réponse est Binaire ?",
"No Error on Failure": "Aucune erreur en cas d'échec",
"Timeout (in seconds)": "Délai d'attente (en secondes)",
"Authorization headers are injected automatically from your connection.": "Les en-têtes d'autorisation sont injectés automatiquement à partir de votre connexion.",
"Enable for files like PDFs, images, etc..": "Activer pour les fichiers comme les PDFs, les images, etc.",
"GET": "OBTENIR",
"POST": "POSTER",
"PATCH": "PATCH",
"PUT": "EFFACER",
"DELETE": "SUPPRIMER",
"HEAD": "TÊTE",
"New Submission": "Nouvelle soumission",
"Triggers when a new submission is submitted": "Déclenche quand une nouvelle soumission est soumise",
"Form": "Forme"
}

View File

@@ -0,0 +1,29 @@
{
"Create online forms and surveys": "オンラインフォームとアンケートを作成する",
"API Key": "API キー",
"Region": "地域",
"US (api.jotform.com)": "US (api.jotform.com)",
"EU (eu-api.jotform.com)": "EU (eu-api.jotform.com)",
"HIPAA (hipaa-api.jotform.com)": "HIPAA (hipaa-api.jotform.com)",
"\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n": "\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n",
"Custom API Call": "カスタムAPI通話",
"Make a custom API call to a specific endpoint": "特定のエンドポイントへのカスタム API コールを実行します。",
"Method": "方法",
"Headers": "ヘッダー",
"Query Parameters": "クエリパラメータ",
"Body": "本文",
"Response is Binary ?": "応答はバイナリですか?",
"No Error on Failure": "失敗時にエラーはありません",
"Timeout (in seconds)": "タイムアウト(秒)",
"Authorization headers are injected automatically from your connection.": "認証ヘッダは接続から自動的に注入されます。",
"Enable for files like PDFs, images, etc..": "PDF、画像などのファイルを有効にします。",
"GET": "取得",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "削除",
"HEAD": "頭",
"New Submission": "新しい提出",
"Triggers when a new submission is submitted": "新しい提出物が提出されたときにトリガーします",
"Form": "フォーム"
}

View File

@@ -0,0 +1,29 @@
{
"Create online forms and surveys": "Online formulieren en enquêtes maken",
"API Key": "API Sleutel",
"Region": "Regio",
"US (api.jotform.com)": "US (api.jotform.com)",
"EU (eu-api.jotform.com)": "EU (eu-api.jotform.com)",
"HIPAA (hipaa-api.jotform.com)": "HIPAA (hipaa-api.jotform.com)",
"\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n": "\nOm de API key te verkrijgen, volg de onderstaande stappen:\n1. Ga naar Instellingen -> API\n2. Klik op \"Nieuwe Sleutel maken\" knop\n3. Verander de rechten naar \"Volledige Toegang\"\n4. Kopieer de API-sleutel en plak deze in het API-sleutelveld\n",
"Custom API Call": "Custom API Call",
"Make a custom API call to a specific endpoint": "Maak een aangepaste API call naar een specifiek eindpunt",
"Method": "Methode",
"Headers": "Kopteksten",
"Query Parameters": "Query parameters",
"Body": "Lichaam",
"Response is Binary ?": "Antwoord is binair?",
"No Error on Failure": "Geen fout bij fout",
"Timeout (in seconds)": "Time-out (in seconden)",
"Authorization headers are injected automatically from your connection.": "Autorisatie headers worden automatisch geïnjecteerd vanuit uw verbinding.",
"Enable for files like PDFs, images, etc..": "Inschakelen voor bestanden zoals PDF's, afbeeldingen etc..",
"GET": "KRIJG",
"POST": "POSTE",
"PATCH": "BEKIJK",
"PUT": "PUT",
"DELETE": "VERWIJDEREN",
"HEAD": "HOOFD",
"New Submission": "Nieuwe inzending",
"Triggers when a new submission is submitted": "Triggert wanneer een nieuwe uitwerking wordt ingediend",
"Form": "Vorm"
}

View File

@@ -0,0 +1,29 @@
{
"Create online forms and surveys": "Criar formulários e pesquisas online",
"API Key": "Chave de API",
"Region": "Região",
"US (api.jotform.com)": "US (api.jotform.com)",
"EU (eu-api.jotform.com)": "EU (eu-api.jotform.com)",
"HIPAA (hipaa-api.jotform.com)": "HIPAA (hipaa-api.jotform.com)",
"\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n": "\nPara obter chave de api, siga os passos abaixo:\n1. Vá para Configurações -> API\n2. Clique no botão \"Criar Nova Chave\"\n3. Altere as permissões para \"Acesso Completo\"\n4. Copie a chave da API e cole-o no campo Chave da API\n",
"Custom API Call": "Chamada de API personalizada",
"Make a custom API call to a specific endpoint": "Faça uma chamada de API personalizada para um ponto de extremidade específico",
"Method": "Método",
"Headers": "Cabeçalhos",
"Query Parameters": "Parâmetros da consulta",
"Body": "Conteúdo",
"Response is Binary ?": "A resposta é binária ?",
"No Error on Failure": "Nenhum erro no Failure",
"Timeout (in seconds)": "Tempo limite (em segundos)",
"Authorization headers are injected automatically from your connection.": "Os cabeçalhos de autorização são inseridos automaticamente a partir da sua conexão.",
"Enable for files like PDFs, images, etc..": "Habilitar para arquivos como PDFs, imagens, etc..",
"GET": "OBTER",
"POST": "POSTAR",
"PATCH": "COMPRAR",
"PUT": "COLOCAR",
"DELETE": "EXCLUIR",
"HEAD": "CABEÇA",
"New Submission": "Nova Submissão",
"Triggers when a new submission is submitted": "Dispara quando uma nova submissão é submetida",
"Form": "Formulário"
}

View File

@@ -0,0 +1,28 @@
{
"Jotform": "Jotform",
"Create online forms and surveys": "Создать онлайн формы и опросы",
"API Key": "Ключ API",
"Region": "Регион",
"US (api.jotform.com)": "US (api.jotform.com)",
"EU (eu-api.jotform.com)": "EU (eu-api.jotform.com)",
"HIPAA (hipaa-api.jotform.com)": "HIPAA (hipaa-api.jotform.com)",
"\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n": "\nДля получения ключа api следуйте инструкциям ниже:\n1. Перейдите в Настройки -> API\n2. Нажмите на кнопку \"Создать новый ключ\"\n3. Изменить права на \"Full Access\"\n4. Скопируйте ключ API и вставьте его в поле ключа API\n",
"Custom API Call": "Пользовательский вызов API",
"Make a custom API call to a specific endpoint": "Сделать пользовательский API вызов к определенной конечной точке",
"Method": "Метод",
"Headers": "Заголовки",
"Query Parameters": "Параметры запроса",
"Body": "Тело",
"No Error on Failure": "Нет ошибок при ошибке",
"Timeout (in seconds)": "Таймаут (в секундах)",
"Authorization headers are injected automatically from your connection.": "Заголовки авторизации включаются автоматически из вашего соединения.",
"GET": "ПОЛУЧИТЬ",
"POST": "ПОСТ",
"PATCH": "ПАТЧ",
"PUT": "ПОКУПИТЬ",
"DELETE": "УДАЛИТЬ",
"HEAD": "HEAD",
"New Submission": "Новая заявка",
"Triggers when a new submission is submitted": "Триггеры при отправке нового сообщения",
"Form": "Форма"
}

View File

@@ -0,0 +1,29 @@
{
"Create online forms and surveys": "Create online forms and surveys",
"API Key": "API Key",
"Region": "Region",
"US (api.jotform.com)": "US (api.jotform.com)",
"EU (eu-api.jotform.com)": "EU (eu-api.jotform.com)",
"HIPAA (hipaa-api.jotform.com)": "HIPAA (hipaa-api.jotform.com)",
"\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n": "\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n",
"Custom API Call": "Custom API Call",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"Enable for files like PDFs, images, etc..": "Enable for files like PDFs, images, etc..",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD",
"New Submission": "New Submission",
"Triggers when a new submission is submitted": "Triggers when a new submission is submitted",
"Form": "Form"
}

View File

@@ -0,0 +1,28 @@
{
"Jotform": "Jotform",
"Create online forms and surveys": "Create online forms and surveys",
"API Key": "API Key",
"Region": "Region",
"US (api.jotform.com)": "US (api.jotform.com)",
"EU (eu-api.jotform.com)": "EU (eu-api.jotform.com)",
"HIPAA (hipaa-api.jotform.com)": "HIPAA (hipaa-api.jotform.com)",
"\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n": "\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n",
"Custom API Call": "Custom API Call",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD",
"New Submission": "New Submission",
"Triggers when a new submission is submitted": "Triggers when a new submission is submitted",
"Form": "Form"
}

View File

@@ -0,0 +1,29 @@
{
"Create online forms and surveys": "Create online forms and surveys",
"API Key": "API 密钥",
"Region": "Region",
"US (api.jotform.com)": "US (api.jotform.com)",
"EU (eu-api.jotform.com)": "EU (eu-api.jotform.com)",
"HIPAA (hipaa-api.jotform.com)": "HIPAA (hipaa-api.jotform.com)",
"\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n": "\nTo obtain api key, follow the steps below:\n1. Go to Settings -> API\n2. Click on \"Create New Key\" button\n3. Change the permissions to \"Full Access\"\n4. Copy the API Key and paste it in the API Key field\n",
"Custom API Call": "自定义 API 呼叫",
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
"Method": "方法",
"Headers": "信头",
"Query Parameters": "查询参数",
"Body": "正文内容",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "失败时没有错误",
"Timeout (in seconds)": "超时(秒)",
"Authorization headers are injected automatically from your connection.": "授权头自动从您的连接中注入。",
"Enable for files like PDFs, images, etc..": "Enable for files like PDFs, images, etc..",
"GET": "获取",
"POST": "帖子",
"PATCH": "PATCH",
"PUT": "弹出",
"DELETE": "删除",
"HEAD": "黑色",
"New Submission": "New Submission",
"Triggers when a new submission is submitted": "Triggers when a new submission is submitted",
"Form": "Form"
}

View File

@@ -0,0 +1,71 @@
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import {
PieceAuth,
Property,
createPiece,
} from '@activepieces/pieces-framework';
import { PieceCategory } from '@activepieces/shared';
import { jotformCommon } from './lib/common';
import { newSubmission } from './lib/triggers/new-submission';
const markdownDescription = `
To obtain api key, follow the steps below:
1. Go to Settings -> API
2. Click on "Create New Key" button
3. Change the permissions to "Full Access"
4. Copy the API Key and paste it in the API Key field
`;
export const jotformAuth = PieceAuth.CustomAuth({
required: true,
description: markdownDescription,
props: {
apiKey: PieceAuth.SecretText({
displayName: 'API Key',
required: true,
}),
region: Property.StaticDropdown({
displayName: 'Region',
required: true,
options: {
options: [
{
label: 'US (api.jotform.com)',
value: 'us',
},
{
label: 'EU (eu-api.jotform.com)',
value: 'eu',
},
{
label: 'HIPAA (hipaa-api.jotform.com)',
value: 'hipaa',
},
],
},
}),
},
});
export const jotform = createPiece({
displayName: 'Jotform',
description: 'Create online forms and surveys',
minimumSupportedRelease: '0.30.0',
logoUrl: 'https://cdn.activepieces.com/pieces/jotform.svg',
categories: [PieceCategory.FORMS_AND_SURVEYS],
authors: ["kishanprmr","MoShizzle","khaledmashaly","abuaboud", "PFernandez98"],
auth: jotformAuth,
actions: [
createCustomApiCallAction({
baseUrl: (auth) =>
auth?
jotformCommon.baseUrl(auth.props.region) : '',
auth: jotformAuth,
authMapping: async (auth) => ({
APIKEY: auth.props.apiKey,
}),
}),
],
triggers: [newSubmission],
});

View File

@@ -0,0 +1,142 @@
import { AppConnectionValueForAuthProperty, Property } from '@activepieces/pieces-framework';
import {
HttpRequest,
HttpMethod,
httpClient,
} from '@activepieces/pieces-common';
import { jotformAuth } from '../..';
export const jotformCommon = {
baseUrl: (region: string) => {
if (region === 'eu') {
return 'https://eu-api.jotform.com';
}
if (region === 'hipaa') {
return 'https://hipaa-api.jotform.com';
}
return 'https://api.jotform.com';
},
form: Property.Dropdown({
auth: jotformAuth,
displayName: 'Form',
required: true,
refreshers: [],
options: async ({ auth }) => {
if (!auth) {
return {
disabled: true,
options: [],
placeholder: 'Enter API Key',
};
}
const authProp = auth.props;
const options: any[] = await jotformCommon.getUserForms(
authProp.apiKey,
authProp.region
);
return {
options: options,
placeholder: 'Choose form to connect',
};
},
}),
getUserForms: async (apiKey: string, region: string) => {
const request: HttpRequest = {
method: HttpMethod.GET,
url: `${jotformCommon.baseUrl(region)}/user/forms`,
headers: {
APIKEY: apiKey,
},
};
const response = await httpClient.sendRequest(request);
const newValues = response.body.content.map((form: JotformForm) => {
return {
label: form.title,
value: form.id,
};
});
return newValues;
},
subscribeWebhook: async (
formId: any,
webhookUrl: string,
authentication: AppConnectionValueForAuthProperty<typeof jotformAuth>
) => {
const request: HttpRequest = {
method: HttpMethod.POST,
url: `${jotformCommon.baseUrl(
authentication.props.region
)}/form/${formId}/webhooks`,
headers: {
APIKEY: authentication.props.apiKey,
'Content-Type': 'multipart/form-data',
},
body: {
webhookURL: webhookUrl,
},
};
await httpClient.sendRequest(request);
},
unsubscribeWebhook: async (
formId: any,
webhookUrl: string,
authentication: AppConnectionValueForAuthProperty<typeof jotformAuth>
) => {
const getWebhooksRequest: HttpRequest = {
method: HttpMethod.GET,
url: `${jotformCommon.baseUrl(
authentication.props.region
)}/form/${formId}/webhooks`,
headers: {
APIKEY: authentication.props.apiKey,
},
};
const response = await httpClient.sendRequest(getWebhooksRequest);
let webhookId;
Object.entries(response.body.content).forEach(([key, value]) => {
if (value == webhookUrl) {
webhookId = key;
}
});
const request: HttpRequest = {
method: HttpMethod.DELETE,
url: `${jotformCommon.baseUrl(
authentication.props.region
)}/form/${formId}/webhooks/${webhookId}`,
headers: {
APIKEY: authentication.props. apiKey,
},
};
const deleteResponse = await httpClient.sendRequest(request);
return deleteResponse;
},
};
export interface JotformForm {
id: string;
username: string;
title: string;
height: string;
status: string;
created_at: string;
updated_at: string;
last_submission: string;
new: string;
count: string;
type: string;
favorite: string;
archived: string;
url: string;
}
export interface WebhookInformation {
jotformWebhook: string;
}

View File

@@ -0,0 +1,48 @@
import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
import { WebhookInformation, jotformCommon } from '../common';
import { jotformAuth } from '../..';
export const newSubmission = createTrigger({
auth: jotformAuth,
name: 'new_submission',
displayName: 'New Submission',
description: 'Triggers when a new submission is submitted',
type: TriggerStrategy.WEBHOOK,
sampleData: {},
props: {
formId: jotformCommon.form,
},
//Set the webhook URL in Jotform and save the webhook URL in store for disable behavior
async onEnable(context) {
await jotformCommon.subscribeWebhook(
context.propsValue['formId'],
context.webhookUrl,
context.auth
);
await context.store?.put<WebhookInformation>(
'_new_jotform_submission_trigger',
{
jotformWebhook: context.webhookUrl,
}
);
},
//Delete the webhook URL from Jotform
async onDisable(context) {
const response = await context.store?.get<WebhookInformation>(
'_new_jotform_submission_trigger'
);
if (response !== null && response !== undefined) {
await jotformCommon.unsubscribeWebhook(
context.propsValue['formId'],
response.jotformWebhook,
context.auth
);
}
},
//Return new submission
async run(context) {
return [context.payload.body];
},
});

View File

@@ -0,0 +1,16 @@
{
"extends": "../../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
],
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}

View File

@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}