diff --git a/credentials/WpformsApi.credentials.ts b/credentials/WpformsApi.credentials.ts
new file mode 100644
index 0000000..6bd9443
--- /dev/null
+++ b/credentials/WpformsApi.credentials.ts
@@ -0,0 +1,29 @@
+import type {
+ ICredentialType,
+ INodeProperties,
+} from 'n8n-workflow';
+
+/**
+ * WPForms API credentials.
+ *
+ * @since 1.0
+ */
+export class WpformsApi implements ICredentialType {
+ name = 'wpformsApi';
+ displayName = 'WPForms API';
+ documentationUrl = 'https://wpforms.com/docs/n8n-addon/?utm_source=n8n&utm_medium=referral&utm_campaign=n8n_integration&utm_content=wpforms_trigger_docs&utm_locale=en_US';
+ properties: INodeProperties[] = [
+ {
+ displayName: 'Secret Key',
+ name: 'secretKey',
+ type: 'string',
+ typeOptions: {
+ password: true,
+ },
+ default: '',
+ required: true,
+ description: 'The secret key used to verify webhook requests',
+ hint: 'Copy the value from your WPForms n8n settings. Read more',
+ },
+ ];
+}
diff --git a/nodes/WPForms/WpformsTrigger.node.ts b/nodes/WPForms/WpformsTrigger.node.ts
index 774082c..3aa7128 100644
--- a/nodes/WPForms/WpformsTrigger.node.ts
+++ b/nodes/WPForms/WpformsTrigger.node.ts
@@ -26,6 +26,12 @@ export class WpformsTrigger implements INodeType {
},
inputs: [], // Trigger nodes have no inputs.
outputs: [NodeConnectionType.Main],
+ credentials: [
+ {
+ name: 'wpformsApi',
+ required: true,
+ },
+ ],
webhooks: [
{
name: 'default',
@@ -36,18 +42,6 @@ export class WpformsTrigger implements INodeType {
},
],
properties: [
- {
- displayName: 'Secret Key',
- name: 'scrKey',
- type: 'string',
- typeOptions: {
- password: true,
- },
- default: '',
- required: true,
- description: 'The secret key used to verify the request',
- hint: 'Copy the value from your WPForms n8n settings. Read more',
- },
{
displayName: 'Output Schema',
name: 'outputSchema',
@@ -88,8 +82,11 @@ export class WpformsTrigger implements INodeType {
// Access the raw HTTP request from n8n's webhook context.
const request = this.getRequestObject();
+ // Get credentials
+ const credentials = await this.getCredentials('wpformsApi');
+ const secretKey = credentials.secretKey as string;
+
// Node parameters configured by the user in the UI
- const secretKey = this.getNodeParameter('scrKey') as string;
const timestampSkew = this.getNodeParameter('timestampSkew') as number;
const outputSchema = this.getNodeParameter('outputSchema') as string;
diff --git a/package.json b/package.json
index 7f2dcd4..a17cd28 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,9 @@
],
"n8n": {
"n8nNodesApiVersion": 1,
- "credentials": [],
+ "credentials": [
+ "dist/credentials/WpformsApi.credentials.js"
+ ],
"nodes": [
"dist/nodes/WPForms/WpformsTrigger.node.js"
]