@growsalesai/n8n-nodes-ycloud 2.7.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ import type { IHookFunctions, IWebhookFunctions, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow';
2
+ export declare class YCloudInboundTrigger implements INodeType {
3
+ description: INodeTypeDescription;
4
+ webhookMethods: {
5
+ default: {
6
+ checkExists(this: IHookFunctions): Promise<boolean>;
7
+ create(this: IHookFunctions): Promise<boolean>;
8
+ delete(this: IHookFunctions): Promise<boolean>;
9
+ };
10
+ };
11
+ webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
12
+ }
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.YCloudInboundTrigger = void 0;
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ const n8n_workflow_1 = require("n8n-workflow");
9
+ const GenericFunctions_1 = require("./GenericFunctions");
10
+ const MSG_TYPES = ['text', 'image', 'video', 'audio', 'document', 'location', 'interactive', 'sticker', 'reaction'];
11
+ // Output 0 = "All" always fires (ensures n8n starts workflow execution); outputs 1–9 = type-specific; output 10 = "Other"
12
+ const OUTPUT_NAMES = ['All', 'Text', 'Image', 'Video', 'Audio', 'Document', 'Location', 'Interactive', 'Sticker', 'Reaction', 'Other'];
13
+ class YCloudInboundTrigger {
14
+ constructor() {
15
+ this.description = {
16
+ displayName: 'YCloud Inbound Trigger',
17
+ name: 'yCloudInboundTrigger',
18
+ icon: 'file:logo-ycloud.png',
19
+ group: ['trigger'],
20
+ version: 1,
21
+ description: 'Starts the workflow when a WhatsApp inbound message is received and routes it directly by message type — no extra Switch/Router node needed.',
22
+ defaults: { name: 'YCloud Inbound Trigger' },
23
+ inputs: [],
24
+ outputs: Array(OUTPUT_NAMES.length).fill(n8n_workflow_1.NodeConnectionTypes.Main),
25
+ outputNames: OUTPUT_NAMES,
26
+ credentials: [{ name: 'yCloudApi', required: true }],
27
+ webhooks: [
28
+ {
29
+ name: 'default',
30
+ httpMethod: 'POST',
31
+ responseMode: 'onReceived',
32
+ path: 'webhook',
33
+ },
34
+ ],
35
+ properties: [
36
+ {
37
+ displayName: 'Options',
38
+ name: 'options',
39
+ type: 'collection',
40
+ placeholder: 'Add Option',
41
+ default: {},
42
+ options: [
43
+ {
44
+ displayName: 'Validate Signature',
45
+ name: 'validateSignature',
46
+ type: 'boolean',
47
+ default: false,
48
+ description: 'Whether to validate the HMAC-SHA256 signature sent by YCloud',
49
+ },
50
+ {
51
+ displayName: 'Keyword Rules (Text Messages)',
52
+ name: 'keywordRules',
53
+ type: 'fixedCollection',
54
+ typeOptions: { multipleValues: true },
55
+ default: { rules: [] },
56
+ placeholder: 'Add Keyword Rule',
57
+ description: 'Detect keywords in text messages and add a "_keyword" label field to the output item',
58
+ options: [
59
+ {
60
+ name: 'rules',
61
+ displayName: 'Rule',
62
+ values: [
63
+ { displayName: 'Keyword', name: 'keyword', type: 'string', default: '', description: 'Case-insensitive partial match' },
64
+ { displayName: 'Label', name: 'label', type: 'string', default: '', description: 'Written to _keyword field when matched' },
65
+ ],
66
+ },
67
+ ],
68
+ },
69
+ ],
70
+ },
71
+ ],
72
+ };
73
+ this.webhookMethods = {
74
+ default: {
75
+ async checkExists() {
76
+ const webhookData = this.getWorkflowStaticData('node');
77
+ if (!webhookData.webhookId)
78
+ return false;
79
+ try {
80
+ await GenericFunctions_1.ycloudApiRequest.call(this, 'GET', `/webhookEndpoints/${webhookData.webhookId}`);
81
+ return true;
82
+ }
83
+ catch {
84
+ return false;
85
+ }
86
+ },
87
+ async create() {
88
+ const webhookUrl = this.getNodeWebhookUrl('default');
89
+ const nodeName = this.getNode().name;
90
+ const response = await GenericFunctions_1.ycloudApiRequest.call(this, 'POST', '/webhookEndpoints', {
91
+ url: webhookUrl,
92
+ enabledEvents: ['whatsapp.inbound_message.received'],
93
+ description: nodeName,
94
+ status: 'active',
95
+ });
96
+ const webhookData = this.getWorkflowStaticData('node');
97
+ webhookData.webhookId = response.id;
98
+ webhookData.webhookSecret = response.secret;
99
+ return true;
100
+ },
101
+ async delete() {
102
+ const webhookData = this.getWorkflowStaticData('node');
103
+ if (!webhookData.webhookId)
104
+ return true;
105
+ try {
106
+ await GenericFunctions_1.ycloudApiRequest.call(this, 'DELETE', `/webhookEndpoints/${webhookData.webhookId}`);
107
+ }
108
+ catch {
109
+ return false;
110
+ }
111
+ delete webhookData.webhookId;
112
+ delete webhookData.webhookSecret;
113
+ return true;
114
+ },
115
+ },
116
+ };
117
+ }
118
+ async webhook() {
119
+ var _a;
120
+ const bodyData = this.getBodyData();
121
+ const options = this.getNodeParameter('options');
122
+ // Signature validation (optional)
123
+ if (options.validateSignature === true) {
124
+ const webhookData = this.getWorkflowStaticData('node');
125
+ const secret = webhookData.webhookSecret;
126
+ if (secret) {
127
+ const headers = this.getHeaderData();
128
+ const sigHeader = (headers['ycloud-signature'] ||
129
+ headers['x-ycloud-signature'] ||
130
+ headers['x-signature-256']);
131
+ if (sigHeader) {
132
+ const hmac = crypto_1.default.createHmac('sha256', secret).update(JSON.stringify(bodyData)).digest('hex');
133
+ if (sigHeader !== `sha256=${hmac}`) {
134
+ const out = Array(OUTPUT_NAMES.length).fill(null);
135
+ out[0] = [{ json: { ...bodyData, _signatureValid: false } }];
136
+ out[OUTPUT_NAMES.length - 1] = [{ json: { ...bodyData, _signatureValid: false } }];
137
+ return { workflowData: out };
138
+ }
139
+ }
140
+ }
141
+ }
142
+ // Support both top-level and data-nested payload structures from YCloud
143
+ const dataObj = bodyData.data || {};
144
+ const message = bodyData.whatsappInboundMessage ||
145
+ dataObj.whatsappInboundMessage || {};
146
+ const msgType = (message.type || '').toLowerCase();
147
+ // Keyword detection for text messages
148
+ const enriched = { ...bodyData };
149
+ if (msgType === 'text') {
150
+ const keywordRulesData = options.keywordRules || {};
151
+ const keywordRules = keywordRulesData.rules || [];
152
+ if (keywordRules.length > 0) {
153
+ const textBody = (((_a = message.text) === null || _a === void 0 ? void 0 : _a.body) || '').toLowerCase();
154
+ const matched = keywordRules.find((r) => textBody.includes((r.keyword || '').toLowerCase()));
155
+ if (matched)
156
+ enriched._keyword = matched.label;
157
+ }
158
+ }
159
+ // Type-specific output index: known types are shifted by 1 (output 0 = "All"); unknown = last output
160
+ const typeIdx = MSG_TYPES.indexOf(msgType);
161
+ const typeOutputIdx = typeIdx === -1 ? OUTPUT_NAMES.length - 1 : typeIdx + 1;
162
+ // Output 0 ("All") always receives data so n8n always starts workflow execution.
163
+ // The matched type output also receives data for type-specific routing.
164
+ const workflowData = Array(OUTPUT_NAMES.length).fill(null);
165
+ workflowData[0] = [{ json: enriched }];
166
+ workflowData[typeOutputIdx] = [{ json: enriched }];
167
+ return { workflowData };
168
+ }
169
+ }
170
+ exports.YCloudInboundTrigger = YCloudInboundTrigger;
171
+ //# sourceMappingURL=YCloudInboundTrigger.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YCloudInboundTrigger.node.js","sourceRoot":"","sources":["../../../nodes/YCloud/YCloudInboundTrigger.node.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAU5B,+CAAmD;AACnD,yDAAsD;AAEtD,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACpH,0HAA0H;AAC1H,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAEvI,MAAa,oBAAoB;IAAjC;QACE,gBAAW,GAAyB;YAClC,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,GAAG,CAAC,EAAE,CAAC;gBAC5B,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAC,OAAO,CAAC,IAAoB,0CAAE,IAAe,KAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;gBACvF,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAiB,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;gBACvG,IAAI,OAAO;oBAAE,QAAQ,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;YACjD,CAAC;QACH,CAAC;QAED,qGAAqG;QACrG,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,aAAa,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;QAE7E,iFAAiF;QACjF,wEAAwE;QACxE,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAA2B,CAAC;QACrF,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QACvC,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEnD,OAAO,EAAE,YAAY,EAAE,CAAC;IAC1B,CAAC;CACF;AAnKD,oDAmKC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growsalesai/n8n-nodes-ycloud",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "description": "n8n community nodes for YCloud API — WhatsApp, SMS, Email, Voice, Verification and more",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -43,6 +43,7 @@
43
43
  "nodes": [
44
44
  "dist/nodes/YCloud/YCloud.node.js",
45
45
  "dist/nodes/YCloud/YCloudTrigger.node.js",
46
+ "dist/nodes/YCloud/YCloudInboundTrigger.node.js",
46
47
  "dist/nodes/YCloud/YCloudSequences.node.js"
47
48
  ]
48
49
  },