Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions credentials/WpformsApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -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';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would definitely be open to any suggestions here 😄

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. <a href="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" target="_blank">Read more</a>',
},
];
}
23 changes: 10 additions & 13 deletions nodes/WPForms/WpformsTrigger.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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. <a href="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">Read more</a>',
},
{
displayName: 'Output Schema',
name: 'outputSchema',
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
],
"n8n": {
"n8nNodesApiVersion": 1,
"credentials": [],
"credentials": [
"dist/credentials/WpformsApi.credentials.js"
],
"nodes": [
"dist/nodes/WPForms/WpformsTrigger.node.js"
]
Expand Down