diff --git a/packages/backend/src/apps/pdf-monkey/actions/generate-document/index.js b/packages/backend/src/apps/pdf-monkey/actions/generate-document/index.js
new file mode 100644
index 00000000..d4a67875
--- /dev/null
+++ b/packages/backend/src/apps/pdf-monkey/actions/generate-document/index.js
@@ -0,0 +1,241 @@
+import defineAction from '../../../../helpers/define-action.js';
+
+export default defineAction({
+ name: 'Generate document',
+ key: 'generateDocument',
+ description: 'Creates a new document.',
+ arguments: [
+ {
+ label: 'Workspace',
+ key: 'workspaceId',
+ type: 'dropdown',
+ required: true,
+ description: '',
+ variables: true,
+ source: {
+ type: 'query',
+ name: 'getDynamicData',
+ arguments: [
+ {
+ name: 'key',
+ value: 'listWorkspaces',
+ },
+ ],
+ },
+ },
+ {
+ label: 'Template',
+ key: 'templateId',
+ type: 'dropdown',
+ required: false,
+ depensOn: ['parameters.workspaceId'],
+ description: '',
+ variables: true,
+ source: {
+ type: 'query',
+ name: 'getDynamicData',
+ arguments: [
+ {
+ name: 'key',
+ value: 'listTemplates',
+ },
+ {
+ name: 'parameters.workspaceId',
+ value: '{parameters.workspaceId}',
+ },
+ ],
+ },
+ },
+ {
+ label: 'Use a Custom Json Structure?',
+ key: 'useCustomJsonStructure',
+ type: 'dropdown',
+ required: true,
+ description:
+ 'Please indicate "yes" if you would rather create a full JSON payload instead of relying on Automatisch mapping for the Document data.',
+ variables: true,
+ options: [
+ {
+ label: 'Yes',
+ value: true,
+ },
+ {
+ label: 'No',
+ value: false,
+ },
+ ],
+ additionalFields: {
+ type: 'query',
+ name: 'getDynamicFields',
+ arguments: [
+ {
+ name: 'key',
+ value: 'listDocumentData',
+ },
+ {
+ name: 'parameters.useCustomJsonStructure',
+ value: '{parameters.useCustomJsonStructure}',
+ },
+ ],
+ },
+ },
+ {
+ label: 'Add Line Items?',
+ key: 'addLineItems',
+ type: 'dropdown',
+ required: true,
+ description:
+ 'Choose "yes" to include information for Line Items (such as in an invoice).',
+ variables: true,
+ options: [
+ {
+ label: 'Yes',
+ value: true,
+ },
+ {
+ label: 'No',
+ value: false,
+ },
+ ],
+ additionalFields: {
+ type: 'query',
+ name: 'getDynamicFields',
+ arguments: [
+ {
+ name: 'key',
+ value: 'listLineItems',
+ },
+ {
+ name: 'parameters.addLineItems',
+ value: '{parameters.addLineItems}',
+ },
+ ],
+ },
+ },
+ {
+ label: 'Custom Filename',
+ key: 'customFilename',
+ type: 'string',
+ required: false,
+ description:
+ 'You have the option to define a custom filename for generated documents. If left blank, a random value will be assigned.',
+ variables: true,
+ },
+ {
+ label: 'Meta Data',
+ key: 'metaData',
+ type: 'dynamic',
+ required: false,
+ description:
+ 'Extra information appended to the generated Document but not accessible within its Template.',
+ fields: [
+ {
+ label: 'Key',
+ key: 'metaDataKey',
+ type: 'string',
+ required: false,
+ description: '',
+ variables: true,
+ },
+ {
+ label: 'Value',
+ key: 'metaDataValue',
+ type: 'string',
+ required: false,
+ description: '',
+ variables: true,
+ },
+ ],
+ },
+ ],
+
+ async run($) {
+ const {
+ templateId,
+ useCustomJsonStructure,
+ customJsonPayload,
+ customFilename,
+ addLineItems,
+ lineItems,
+ documentData,
+ metaData,
+ } = $.step.parameters;
+ let payload = {};
+ let meta = {};
+
+ const documentDataObject = documentData.reduce((result, entry) => {
+ const key = entry.documentDataKey?.toLowerCase();
+ const value = entry.documentDataValue;
+
+ if (key && value) {
+ return {
+ ...result,
+ [entry.documentDataKey?.toLowerCase()]: entry.documentDataValue,
+ };
+ }
+
+ return result;
+ }, {});
+
+ const lineItemsObject = lineItems.reduce((result, entry) => {
+ const key = entry.lineItemKey?.toLowerCase();
+ const value = entry.lineItemValue;
+
+ if (key && value) {
+ return {
+ ...result,
+ [entry.lineItemKey?.toLowerCase()]: entry.lineItemValue,
+ };
+ }
+
+ return result;
+ }, {});
+
+ const metaDataObject = metaData.reduce((result, entry) => {
+ const key = entry.metaDataKey?.toLowerCase();
+ const value = entry.metaDataValue;
+
+ if (key && value) {
+ return {
+ ...result,
+ [entry.metaDataKey?.toLowerCase()]: entry.metaDataValue,
+ };
+ }
+
+ return result;
+ }, {});
+
+ if (metaDataObject) {
+ meta = metaDataObject;
+ }
+
+ if (customFilename) {
+ meta._filename = customFilename;
+ }
+
+ if (useCustomJsonStructure) {
+ payload = JSON.parse(customJsonPayload);
+ } else {
+ payload = documentDataObject;
+ }
+
+ if (addLineItems) {
+ payload.lineItems = [lineItemsObject];
+ }
+
+ const body = {
+ document: {
+ document_template_id: templateId,
+ meta: JSON.stringify(meta),
+ payload: JSON.stringify(payload),
+ status: 'pending',
+ },
+ };
+
+ const { data } = await $.http.post('/v1/documents', body);
+
+ $.setActionItem({
+ raw: data,
+ });
+ },
+});
diff --git a/packages/backend/src/apps/pdf-monkey/actions/index.js b/packages/backend/src/apps/pdf-monkey/actions/index.js
new file mode 100644
index 00000000..162024ce
--- /dev/null
+++ b/packages/backend/src/apps/pdf-monkey/actions/index.js
@@ -0,0 +1,3 @@
+import generateDocument from './generate-document/index.js';
+
+export default [generateDocument];
diff --git a/packages/backend/src/apps/pdf-monkey/dynamic-fields/index.js b/packages/backend/src/apps/pdf-monkey/dynamic-fields/index.js
new file mode 100644
index 00000000..964a6d32
--- /dev/null
+++ b/packages/backend/src/apps/pdf-monkey/dynamic-fields/index.js
@@ -0,0 +1,4 @@
+import listDocumentData from './list-document-data/index.js';
+import listLineItems from './list-line-items/index.js';
+
+export default [listDocumentData, listLineItems];
diff --git a/packages/backend/src/apps/pdf-monkey/dynamic-fields/list-document-data/index.js b/packages/backend/src/apps/pdf-monkey/dynamic-fields/list-document-data/index.js
new file mode 100644
index 00000000..d80c99e8
--- /dev/null
+++ b/packages/backend/src/apps/pdf-monkey/dynamic-fields/list-document-data/index.js
@@ -0,0 +1,48 @@
+export default {
+ name: 'List document data',
+ key: 'listDocumentData',
+
+ async run($) {
+ if ($.step.parameters.useCustomJsonStructure) {
+ return [
+ {
+ label: 'Data for the Document (JSON Payload)',
+ key: 'customJsonPayload',
+ type: 'string',
+ required: false,
+ description:
+ 'Use the JSON format { "firstname": "John", "lastname": "Doe" }.',
+ variables: true,
+ },
+ ];
+ } else {
+ return [
+ {
+ label: 'Data for the Document',
+ key: 'documentData',
+ type: 'dynamic',
+ required: false,
+ description: '',
+ fields: [
+ {
+ label: 'Key',
+ key: 'documentDataKey',
+ type: 'string',
+ required: false,
+ description: '',
+ variables: true,
+ },
+ {
+ label: 'Value',
+ key: 'documentDataValue',
+ type: 'string',
+ required: false,
+ description: '',
+ variables: true,
+ },
+ ],
+ },
+ ];
+ }
+ },
+};
diff --git a/packages/backend/src/apps/pdf-monkey/dynamic-fields/list-line-items/index.js b/packages/backend/src/apps/pdf-monkey/dynamic-fields/list-line-items/index.js
new file mode 100644
index 00000000..c4380a18
--- /dev/null
+++ b/packages/backend/src/apps/pdf-monkey/dynamic-fields/list-line-items/index.js
@@ -0,0 +1,37 @@
+export default {
+ name: 'List line items',
+ key: 'listLineItems',
+
+ async run($) {
+ if ($.step.parameters.addLineItems) {
+ return [
+ {
+ label: 'Line Items',
+ key: 'lineItems',
+ type: 'dynamic',
+ required: false,
+ description:
+ 'Data for a single item. Available as "lineItems" in your PDFMonkey Template.',
+ fields: [
+ {
+ label: 'Key',
+ key: 'lineItemKey',
+ type: 'string',
+ required: false,
+ description: '',
+ variables: true,
+ },
+ {
+ label: 'Value',
+ key: 'lineItemValue',
+ type: 'string',
+ required: false,
+ description: '',
+ variables: true,
+ },
+ ],
+ },
+ ];
+ }
+ },
+};
diff --git a/packages/backend/src/apps/pdf-monkey/index.js b/packages/backend/src/apps/pdf-monkey/index.js
index 1ec0b8f0..06dab42f 100644
--- a/packages/backend/src/apps/pdf-monkey/index.js
+++ b/packages/backend/src/apps/pdf-monkey/index.js
@@ -3,6 +3,8 @@ import addAuthHeader from './common/add-auth-header.js';
import auth from './auth/index.js';
import triggers from './triggers/index.js';
import dynamicData from './dynamic-data/index.js';
+import actions from './actions/index.js';
+import dynamicFields from './dynamic-fields/index.js';
export default defineApp({
name: 'PDFMonkey',
@@ -17,4 +19,6 @@ export default defineApp({
auth,
triggers,
dynamicData,
+ actions,
+ dynamicFields,
});
diff --git a/packages/docs/pages/.vitepress/config.js b/packages/docs/pages/.vitepress/config.js
index de07e952..2af7d451 100644
--- a/packages/docs/pages/.vitepress/config.js
+++ b/packages/docs/pages/.vitepress/config.js
@@ -258,6 +258,7 @@ export default defineConfig({
collapsed: true,
items: [
{ text: 'Triggers', link: '/apps/pdf-monkey/triggers' },
+ { text: 'Actions', link: '/apps/pdf-monkey/actions' },
{ text: 'Connection', link: '/apps/pdf-monkey/connection' },
],
},
diff --git a/packages/docs/pages/apps/pdf-monkey/actions.md b/packages/docs/pages/apps/pdf-monkey/actions.md
new file mode 100644
index 00000000..afcbb7d8
--- /dev/null
+++ b/packages/docs/pages/apps/pdf-monkey/actions.md
@@ -0,0 +1,12 @@
+---
+favicon: /favicons/pdf-monkey.svg
+items:
+ - name: Generate documents
+ desc: Creates a new document.
+---
+
+
+
+
diff --git a/packages/docs/pages/guide/available-apps.md b/packages/docs/pages/guide/available-apps.md
index 90f8ba0a..62da4dcb 100644
--- a/packages/docs/pages/guide/available-apps.md
+++ b/packages/docs/pages/guide/available-apps.md
@@ -26,6 +26,7 @@ The following integrations are currently supported by Automatisch.
- [Ntfy](/apps/ntfy/actions)
- [Odoo](/apps/odoo/actions)
- [OpenAI](/apps/openai/actions)
+- [PDFMonkey](/apps/pdf-monkey/actions)
- [Pipedrive](/apps/pipedrive/triggers)
- [Placetel](/apps/placetel/triggers)
- [PostgreSQL](/apps/postgresql/actions)