@growsalesai/n8n-nodes-ycloud 2.7.0 → 2.7.1

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,164 @@
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
+ const OUTPUT_NAMES = ['Text', 'Image', 'Video', 'Audio', 'Document', 'Location', 'Interactive', 'Sticker', 'Reaction', 'Other'];
12
+ class YCloudInboundTrigger {
13
+ constructor() {
14
+ this.description = {
15
+ displayName: 'YCloud Inbound Trigger',
16
+ name: 'yCloudInboundTrigger',
17
+ icon: 'file:logo-ycloud.png',
18
+ group: ['trigger'],
19
+ version: 1,
20
+ description: 'Starts the workflow when a WhatsApp inbound message is received and routes it directly by message type — no extra Switch/Router node needed.',
21
+ defaults: { name: 'YCloud Inbound Trigger' },
22
+ inputs: [],
23
+ outputs: Array(OUTPUT_NAMES.length).fill(n8n_workflow_1.NodeConnectionTypes.Main),
24
+ outputNames: OUTPUT_NAMES,
25
+ credentials: [{ name: 'yCloudApi', required: true }],
26
+ webhooks: [
27
+ {
28
+ name: 'default',
29
+ httpMethod: 'POST',
30
+ responseMode: 'onReceived',
31
+ path: 'webhook',
32
+ },
33
+ ],
34
+ properties: [
35
+ {
36
+ displayName: 'Options',
37
+ name: 'options',
38
+ type: 'collection',
39
+ placeholder: 'Add Option',
40
+ default: {},
41
+ options: [
42
+ {
43
+ displayName: 'Validate Signature',
44
+ name: 'validateSignature',
45
+ type: 'boolean',
46
+ default: false,
47
+ description: 'Whether to validate the HMAC-SHA256 signature sent by YCloud',
48
+ },
49
+ {
50
+ displayName: 'Keyword Rules (Text Messages)',
51
+ name: 'keywordRules',
52
+ type: 'fixedCollection',
53
+ typeOptions: { multipleValues: true },
54
+ default: { rules: [] },
55
+ placeholder: 'Add Keyword Rule',
56
+ description: 'Detect keywords in text messages and add a "_keyword" label field to the output item',
57
+ options: [
58
+ {
59
+ name: 'rules',
60
+ displayName: 'Rule',
61
+ values: [
62
+ { displayName: 'Keyword', name: 'keyword', type: 'string', default: '', description: 'Case-insensitive partial match' },
63
+ { displayName: 'Label', name: 'label', type: 'string', default: '', description: 'Written to _keyword field when matched' },
64
+ ],
65
+ },
66
+ ],
67
+ },
68
+ ],
69
+ },
70
+ ],
71
+ };
72
+ this.webhookMethods = {
73
+ default: {
74
+ async checkExists() {
75
+ const webhookData = this.getWorkflowStaticData('node');
76
+ if (!webhookData.webhookId)
77
+ return false;
78
+ try {
79
+ await GenericFunctions_1.ycloudApiRequest.call(this, 'GET', `/webhookEndpoints/${webhookData.webhookId}`);
80
+ return true;
81
+ }
82
+ catch {
83
+ return false;
84
+ }
85
+ },
86
+ async create() {
87
+ const webhookUrl = this.getNodeWebhookUrl('default');
88
+ const nodeName = this.getNode().name;
89
+ const response = await GenericFunctions_1.ycloudApiRequest.call(this, 'POST', '/webhookEndpoints', {
90
+ url: webhookUrl,
91
+ enabledEvents: ['whatsapp.inbound_message.received'],
92
+ description: nodeName,
93
+ status: 'active',
94
+ });
95
+ const webhookData = this.getWorkflowStaticData('node');
96
+ webhookData.webhookId = response.id;
97
+ webhookData.webhookSecret = response.secret;
98
+ return true;
99
+ },
100
+ async delete() {
101
+ const webhookData = this.getWorkflowStaticData('node');
102
+ if (!webhookData.webhookId)
103
+ return true;
104
+ try {
105
+ await GenericFunctions_1.ycloudApiRequest.call(this, 'DELETE', `/webhookEndpoints/${webhookData.webhookId}`);
106
+ }
107
+ catch {
108
+ return false;
109
+ }
110
+ delete webhookData.webhookId;
111
+ delete webhookData.webhookSecret;
112
+ return true;
113
+ },
114
+ },
115
+ };
116
+ }
117
+ async webhook() {
118
+ var _a;
119
+ const bodyData = this.getBodyData();
120
+ const options = this.getNodeParameter('options');
121
+ // Signature validation (optional)
122
+ if (options.validateSignature === true) {
123
+ const webhookData = this.getWorkflowStaticData('node');
124
+ const secret = webhookData.webhookSecret;
125
+ if (secret) {
126
+ const headers = this.getHeaderData();
127
+ const sigHeader = (headers['ycloud-signature'] ||
128
+ headers['x-ycloud-signature'] ||
129
+ headers['x-signature-256']);
130
+ if (sigHeader) {
131
+ const hmac = crypto_1.default.createHmac('sha256', secret).update(JSON.stringify(bodyData)).digest('hex');
132
+ if (sigHeader !== `sha256=${hmac}`) {
133
+ const out = Array(OUTPUT_NAMES.length).fill(null).map(() => []);
134
+ out[OUTPUT_NAMES.length - 1] = [{ json: { ...bodyData, _signatureValid: false } }];
135
+ return { workflowData: out };
136
+ }
137
+ }
138
+ }
139
+ }
140
+ // Extract message type
141
+ const message = bodyData.whatsappInboundMessage || {};
142
+ const msgType = (message.type || 'other').toLowerCase();
143
+ // Keyword detection for text messages
144
+ const enriched = { ...bodyData };
145
+ if (msgType === 'text') {
146
+ const keywordRulesData = options.keywordRules || {};
147
+ const keywordRules = keywordRulesData.rules || [];
148
+ if (keywordRules.length > 0) {
149
+ const textBody = (((_a = message.text) === null || _a === void 0 ? void 0 : _a.body) || '').toLowerCase();
150
+ const matched = keywordRules.find((r) => textBody.includes((r.keyword || '').toLowerCase()));
151
+ if (matched)
152
+ enriched._keyword = matched.label;
153
+ }
154
+ }
155
+ // Route to the correct output — all other outputs get empty arrays
156
+ const typeIdx = MSG_TYPES.indexOf(msgType);
157
+ const outputIdx = typeIdx === -1 ? OUTPUT_NAMES.length - 1 : typeIdx;
158
+ const workflowData = Array(OUTPUT_NAMES.length).fill(null).map(() => []);
159
+ workflowData[outputIdx] = [{ json: enriched }];
160
+ return { workflowData };
161
+ }
162
+ }
163
+ exports.YCloudInboundTrigger = YCloudInboundTrigger;
164
+ //# 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,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAEhI,MAAa,oBAAoB;IAAjC;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,wBAAwB;YACrC,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,sBAAsB;YAC5B,KAAK,EAAE,CAAC,SAAS,CAAC;YAClB,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,8IAA8I;YAC3J,QAAQ,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE;YAC5C,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,kCAA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C,OAAO,CAAC,CAAC;QAC3C,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAErE,MAAM,YAAY,GAA2B,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QACjG,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAE/C,OAAO,EAAE,YAAY,EAAE,CAAC;IAC1B,CAAC;CACF;AA7JD,oDA6JC"}
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.1",
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
  },