mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ Add n8n training nodes (#1898)
* ⚡ n8n training node * ⚡ Improvements * ⚡ cosmetic changes * ⚡ Improvements * ⚡ Formatting fix Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class N8nTrainingCustomerMessenger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Customer Messenger (n8n training)',
|
||||
name: 'n8nTrainingCustomeMessenger',
|
||||
icon: 'file:n8nTrainingCustomerMessenger.svg',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
description: 'Dummy node used for n8n training',
|
||||
defaults: {
|
||||
name: 'Customer Messenger',
|
||||
color: '#ff6d5a',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Message',
|
||||
name: 'message',
|
||||
type: 'string',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
rows: 4,
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
const length = (items.length as unknown) as number;
|
||||
let responseData;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
|
||||
const customerId = this.getNodeParameter('customerId', i) as string;
|
||||
|
||||
const message = this.getNodeParameter('message', i) as string;
|
||||
|
||||
responseData = { output: `Sent message to customer ${customerId}: ${message}` };
|
||||
|
||||
returnData.push(responseData);
|
||||
}
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user