mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-27 13:39:44 -08:00
600013a1ab
Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import type {
|
|
IExecuteFunctions,
|
|
INodeExecutionData,
|
|
INodeType,
|
|
INodeTypeDescription,
|
|
} from 'n8n-workflow';
|
|
|
|
export class N8nTrainingCustomerMessenger implements INodeType {
|
|
description: INodeTypeDescription = {
|
|
displayName: 'Customer Messenger (n8n training)',
|
|
name: 'n8nTrainingCustomerMessenger',
|
|
icon: {
|
|
light: 'file:n8nTrainingCustomerMessenger.svg',
|
|
dark: 'file:n8nTrainingCustomerMessenger.dark.svg',
|
|
},
|
|
group: ['transform'],
|
|
version: 1,
|
|
description: 'Dummy node used for n8n training',
|
|
defaults: {
|
|
name: 'Customer Messenger (n8n training)',
|
|
},
|
|
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: INodeExecutionData[] = [];
|
|
const length = items.length;
|
|
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}` };
|
|
const executionData = this.helpers.constructExecutionMetaData(
|
|
this.helpers.returnJsonArray(responseData),
|
|
{ itemData: { item: i } },
|
|
);
|
|
|
|
returnData.push(...executionData);
|
|
}
|
|
return [returnData];
|
|
}
|
|
}
|