@growsalesai/n8n-nodes-ycloud 0.2.3 → 2.6.0
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.
- package/dist/nodes/YCloud/YCloud.node.js +1 -0
- package/dist/nodes/YCloud/YCloud.node.js.map +1 -1
- package/dist/nodes/YCloud/YCloudAutoResponder.node.d.ts +5 -0
- package/dist/nodes/YCloud/YCloudAutoResponder.node.js +236 -0
- package/dist/nodes/YCloud/YCloudAutoResponder.node.js.map +1 -0
- package/dist/nodes/YCloud/YCloudContactOnboarding.node.d.ts +5 -0
- package/dist/nodes/YCloud/YCloudContactOnboarding.node.js +195 -0
- package/dist/nodes/YCloud/YCloudContactOnboarding.node.js.map +1 -0
- package/dist/nodes/YCloud/YCloudContactUpsert.node.d.ts +5 -0
- package/dist/nodes/YCloud/YCloudContactUpsert.node.js +120 -0
- package/dist/nodes/YCloud/YCloudContactUpsert.node.js.map +1 -0
- package/dist/nodes/YCloud/YCloudInboundRouter.node.d.ts +5 -0
- package/dist/nodes/YCloud/YCloudInboundRouter.node.js +100 -0
- package/dist/nodes/YCloud/YCloudInboundRouter.node.js.map +1 -0
- package/dist/nodes/YCloud/YCloudMessageStatusRouter.node.d.ts +5 -0
- package/dist/nodes/YCloud/YCloudMessageStatusRouter.node.js +51 -0
- package/dist/nodes/YCloud/YCloudMessageStatusRouter.node.js.map +1 -0
- package/dist/nodes/YCloud/YCloudOptHandler.node.d.ts +5 -0
- package/dist/nodes/YCloud/YCloudOptHandler.node.js +136 -0
- package/dist/nodes/YCloud/YCloudOptHandler.node.js.map +1 -0
- package/dist/nodes/YCloud/YCloudTagCampaign.node.d.ts +5 -0
- package/dist/nodes/YCloud/YCloudTagCampaign.node.js +178 -0
- package/dist/nodes/YCloud/YCloudTagCampaign.node.js.map +1 -0
- package/dist/nodes/YCloud/sequences/YCloudAutoResponder.node.d.ts +5 -0
- package/dist/nodes/YCloud/sequences/YCloudAutoResponder.node.js +241 -0
- package/dist/nodes/YCloud/sequences/YCloudAutoResponder.node.js.map +1 -0
- package/dist/nodes/YCloud/sequences/YCloudContactOnboarding.node.d.ts +5 -0
- package/dist/nodes/YCloud/sequences/YCloudContactOnboarding.node.js +200 -0
- package/dist/nodes/YCloud/sequences/YCloudContactOnboarding.node.js.map +1 -0
- package/dist/nodes/YCloud/sequences/YCloudContactUpsert.node.d.ts +5 -0
- package/dist/nodes/YCloud/sequences/YCloudContactUpsert.node.js +125 -0
- package/dist/nodes/YCloud/sequences/YCloudContactUpsert.node.js.map +1 -0
- package/dist/nodes/YCloud/sequences/YCloudInboundRouter.node.d.ts +5 -0
- package/dist/nodes/YCloud/sequences/YCloudInboundRouter.node.js +105 -0
- package/dist/nodes/YCloud/sequences/YCloudInboundRouter.node.js.map +1 -0
- package/dist/nodes/YCloud/sequences/YCloudMessageStatusRouter.node.d.ts +5 -0
- package/dist/nodes/YCloud/sequences/YCloudMessageStatusRouter.node.js +56 -0
- package/dist/nodes/YCloud/sequences/YCloudMessageStatusRouter.node.js.map +1 -0
- package/dist/nodes/YCloud/sequences/YCloudOptHandler.node.d.ts +5 -0
- package/dist/nodes/YCloud/sequences/YCloudOptHandler.node.js +141 -0
- package/dist/nodes/YCloud/sequences/YCloudOptHandler.node.js.map +1 -0
- package/dist/nodes/YCloud/sequences/YCloudTagCampaign.node.d.ts +5 -0
- package/dist/nodes/YCloud/sequences/YCloudTagCampaign.node.js +183 -0
- package/dist/nodes/YCloud/sequences/YCloudTagCampaign.node.js.map +1 -0
- package/package.json +9 -2
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YCloudInboundRouter = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const MESSAGE_TYPES = [
|
|
6
|
+
'text',
|
|
7
|
+
'image',
|
|
8
|
+
'video',
|
|
9
|
+
'audio',
|
|
10
|
+
'document',
|
|
11
|
+
'location',
|
|
12
|
+
'interactive',
|
|
13
|
+
'sticker',
|
|
14
|
+
'reaction',
|
|
15
|
+
'other',
|
|
16
|
+
];
|
|
17
|
+
const OUTPUT_LABELS = ['Text', 'Image', 'Video', 'Audio', 'Document', 'Location', 'Interactive', 'Sticker', 'Reaction', 'Other'];
|
|
18
|
+
class YCloudInboundRouter {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.description = {
|
|
21
|
+
displayName: 'YCloud Inbound Router',
|
|
22
|
+
name: 'yCloudInboundRouter',
|
|
23
|
+
icon: 'file:logo-ycloud.png',
|
|
24
|
+
group: ['transform'],
|
|
25
|
+
version: 1,
|
|
26
|
+
subtitle: 'Route by message type',
|
|
27
|
+
description: 'Routes incoming WhatsApp messages from YCloud Trigger based on message type. Connect after "YCloud Trigger" listening for whatsapp.inbound_message.received events.',
|
|
28
|
+
defaults: { name: 'YCloud Inbound Router' },
|
|
29
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
30
|
+
outputs: Array(OUTPUT_LABELS.length).fill(n8n_workflow_1.NodeConnectionTypes.Main),
|
|
31
|
+
outputNames: OUTPUT_LABELS,
|
|
32
|
+
properties: [
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Message Object Field',
|
|
35
|
+
name: 'messageField',
|
|
36
|
+
type: 'string',
|
|
37
|
+
default: 'whatsappInboundMessage',
|
|
38
|
+
description: 'Top-level field in the incoming data that contains the WhatsApp message object. Default matches the YCloud Trigger output.',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
displayName: 'Keyword Rules (Text Messages)',
|
|
42
|
+
name: 'keywordRules',
|
|
43
|
+
type: 'fixedCollection',
|
|
44
|
+
typeOptions: { multipleValues: true },
|
|
45
|
+
default: { rules: [] },
|
|
46
|
+
placeholder: 'Add Keyword Rule',
|
|
47
|
+
description: 'Detect keywords in text messages and add a "_keyword" label field to the output item',
|
|
48
|
+
options: [
|
|
49
|
+
{
|
|
50
|
+
name: 'rules',
|
|
51
|
+
displayName: 'Rule',
|
|
52
|
+
values: [
|
|
53
|
+
{
|
|
54
|
+
displayName: 'Keyword',
|
|
55
|
+
name: 'keyword',
|
|
56
|
+
type: 'string',
|
|
57
|
+
default: '',
|
|
58
|
+
description: 'Keyword to detect (case-insensitive, partial match)',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
displayName: 'Label',
|
|
62
|
+
name: 'label',
|
|
63
|
+
type: 'string',
|
|
64
|
+
default: '',
|
|
65
|
+
description: 'Value written to the "_keyword" field when this keyword is matched',
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async execute() {
|
|
75
|
+
var _a;
|
|
76
|
+
const items = this.getInputData();
|
|
77
|
+
const outputs = Array.from({ length: OUTPUT_LABELS.length }, () => []);
|
|
78
|
+
for (let i = 0; i < items.length; i++) {
|
|
79
|
+
const messageField = this.getNodeParameter('messageField', i);
|
|
80
|
+
const keywordRulesData = this.getNodeParameter('keywordRules', i);
|
|
81
|
+
const keywordRules = keywordRulesData.rules || [];
|
|
82
|
+
const data = items[i].json;
|
|
83
|
+
const message = data[messageField] || {};
|
|
84
|
+
const msgType = (message.type || 'other').toLowerCase();
|
|
85
|
+
const enriched = { ...data };
|
|
86
|
+
if (msgType === 'text' && keywordRules.length > 0) {
|
|
87
|
+
const textBody = (((_a = message.text) === null || _a === void 0 ? void 0 : _a.body) || '').toLowerCase();
|
|
88
|
+
const matched = keywordRules.find((r) => textBody.includes((r.keyword || '').toLowerCase()));
|
|
89
|
+
if (matched)
|
|
90
|
+
enriched._keyword = matched.label;
|
|
91
|
+
}
|
|
92
|
+
const typeIdx = MESSAGE_TYPES.indexOf(msgType);
|
|
93
|
+
const outputIdx = typeIdx === -1 ? OUTPUT_LABELS.length - 1 : typeIdx;
|
|
94
|
+
outputs[outputIdx].push({ json: enriched, pairedItem: { item: i } });
|
|
95
|
+
}
|
|
96
|
+
return outputs;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.YCloudInboundRouter = YCloudInboundRouter;
|
|
100
|
+
//# sourceMappingURL=YCloudInboundRouter.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YCloudInboundRouter.node.js","sourceRoot":"","sources":["../../../nodes/YCloud/YCloudInboundRouter.node.ts"],"names":[],"mappings":";;;AACA,+CAAmD;AAEnD,MAAM,aAAa,GAAG;IACpB,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,UAAU;IACV,UAAU;IACV,aAAa;IACb,SAAS;IACT,UAAU;IACV,OAAO;CACC,CAAC;AAEX,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAEjI,MAAa,mBAAmB;IAAhC;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,uBAAuB;YACpC,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE,sBAAsB;YAC5B,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,uBAAuB;YACjC,WAAW,EAAE,qKAAqK;YAClL,QAAQ,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE;YAC3C,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,kCAAmB,CAAC,IAAI,CAAsC;YACxG,WAAW,EAAE,aAAa;YAC1B,UAAU,EAAE;gBACV;oBACE,WAAW,EAAE,sBAAsB;oBACnC,IAAI,EAAE,cAAc;oBACpB,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,wBAAwB;oBACjC,WAAW,EAAE,4HAA4H;i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n8n-workflow';
|
|
2
|
+
export declare class YCloudMessageStatusRouter implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YCloudMessageStatusRouter = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const STATUSES = ['sent', 'delivered', 'read', 'failed'];
|
|
6
|
+
const OUTPUT_LABELS = ['Sent', 'Delivered', 'Read', 'Failed', 'Other'];
|
|
7
|
+
class YCloudMessageStatusRouter {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.description = {
|
|
10
|
+
displayName: 'YCloud Message Status Router',
|
|
11
|
+
name: 'yCloudMessageStatusRouter',
|
|
12
|
+
icon: 'file:logo-ycloud.png',
|
|
13
|
+
group: ['transform'],
|
|
14
|
+
version: 1,
|
|
15
|
+
subtitle: 'Sent / Delivered / Read / Failed',
|
|
16
|
+
description: 'Routes incoming whatsapp.message.updated events based on the message delivery status. Connect after "YCloud Trigger" listening for whatsapp.message.updated events.',
|
|
17
|
+
defaults: { name: 'YCloud Message Status Router' },
|
|
18
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
19
|
+
outputs: Array(OUTPUT_LABELS.length).fill(n8n_workflow_1.NodeConnectionTypes.Main),
|
|
20
|
+
outputNames: OUTPUT_LABELS,
|
|
21
|
+
properties: [
|
|
22
|
+
{
|
|
23
|
+
displayName: 'Message Object Field',
|
|
24
|
+
name: 'messageField',
|
|
25
|
+
type: 'string',
|
|
26
|
+
default: 'whatsappMessage',
|
|
27
|
+
description: 'Top-level field in the incoming data that contains the WhatsApp message object. Default matches the YCloud Trigger whatsapp.message.updated payload.',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async execute() {
|
|
33
|
+
const items = this.getInputData();
|
|
34
|
+
const outputs = Array.from({ length: OUTPUT_LABELS.length }, () => []);
|
|
35
|
+
for (let i = 0; i < items.length; i++) {
|
|
36
|
+
const messageField = this.getNodeParameter('messageField', i);
|
|
37
|
+
const data = items[i].json;
|
|
38
|
+
const message = data[messageField] || {};
|
|
39
|
+
const status = (message.status || '').toLowerCase();
|
|
40
|
+
const statusIdx = STATUSES.indexOf(status);
|
|
41
|
+
const outputIdx = statusIdx === -1 ? OUTPUT_LABELS.length - 1 : statusIdx;
|
|
42
|
+
outputs[outputIdx].push({
|
|
43
|
+
json: { ...data, _status: status },
|
|
44
|
+
pairedItem: { item: i },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return outputs;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.YCloudMessageStatusRouter = YCloudMessageStatusRouter;
|
|
51
|
+
//# sourceMappingURL=YCloudMessageStatusRouter.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YCloudMessageStatusRouter.node.js","sourceRoot":"","sources":["../../../nodes/YCloud/YCloudMessageStatusRouter.node.ts"],"names":[],"mappings":";;;AACA,+CAAmD;AAEnD,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAU,CAAC;AAClE,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAEvE,MAAa,yBAAyB;IAAtC;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,8BAA8B;YAC3C,IAAI,EAAE,2BAA2B;YACjC,IAAI,EAAE,sBAAsB;YAC5B,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,kCAAkC;YAC5C,WAAW,EAAE,qKAAqK;YAClL,QAAQ,EAAE,EAAE,IAAI,EAAE,8BAA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AAC,IAAI,CAAC;gBACtB,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE;gBAClC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;aACxB,CAAC,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA7CD,8DA6CC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class YCloudOptHandler implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YCloudOptHandler = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
6
|
+
class YCloudOptHandler {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.description = {
|
|
9
|
+
displayName: 'YCloud Opt-in / Opt-out Handler',
|
|
10
|
+
name: 'yCloudOptHandler',
|
|
11
|
+
icon: 'file:logo-ycloud.png',
|
|
12
|
+
group: ['output'],
|
|
13
|
+
version: 1,
|
|
14
|
+
subtitle: 'Opted Out / Opted In / Other',
|
|
15
|
+
description: 'Reads inbound WhatsApp messages, detects opt-in or opt-out keywords, manages the YCloud unsubscriber list, and routes accordingly. Connect after "YCloud Trigger".',
|
|
16
|
+
defaults: { name: 'YCloud Opt Handler' },
|
|
17
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
18
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main, n8n_workflow_1.NodeConnectionTypes.Main, n8n_workflow_1.NodeConnectionTypes.Main],
|
|
19
|
+
outputNames: ['Opted Out', 'Opted In', 'Other'],
|
|
20
|
+
credentials: [{ name: 'yCloudApi', required: true }],
|
|
21
|
+
properties: [
|
|
22
|
+
{
|
|
23
|
+
displayName: 'Message Object Field',
|
|
24
|
+
name: 'messageField',
|
|
25
|
+
type: 'string',
|
|
26
|
+
default: 'whatsappInboundMessage',
|
|
27
|
+
description: 'Field in the input item containing the WhatsApp message object (from YCloud Trigger)',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
displayName: 'Opt-out Keywords',
|
|
31
|
+
name: 'optOutKeywords',
|
|
32
|
+
type: 'string',
|
|
33
|
+
default: 'STOP,PARAR,SAIR,CANCELAR,UNSUBSCRIBE,NÃO QUERO',
|
|
34
|
+
description: 'Comma-separated keywords that trigger an opt-out (case-insensitive)',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
displayName: 'Opt-in Keywords',
|
|
38
|
+
name: 'optInKeywords',
|
|
39
|
+
type: 'string',
|
|
40
|
+
default: 'START,INICIAR,QUERO,CONTINUAR,SUBSCRIBE,SIM',
|
|
41
|
+
description: 'Comma-separated keywords that trigger an opt-in (case-insensitive)',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Channel',
|
|
45
|
+
name: 'channel',
|
|
46
|
+
type: 'options',
|
|
47
|
+
default: 'whatsApp',
|
|
48
|
+
description: 'Channel to manage in the unsubscriber list',
|
|
49
|
+
options: [
|
|
50
|
+
{ name: 'WhatsApp', value: 'whatsApp' },
|
|
51
|
+
{ name: 'SMS', value: 'sms' },
|
|
52
|
+
{ name: 'Voice', value: 'voice' },
|
|
53
|
+
{ name: 'Email', value: 'email' },
|
|
54
|
+
{ name: 'All', value: 'all' },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Match Mode',
|
|
59
|
+
name: 'matchMode',
|
|
60
|
+
type: 'options',
|
|
61
|
+
default: 'contains',
|
|
62
|
+
options: [
|
|
63
|
+
{ name: 'Contains keyword', value: 'contains' },
|
|
64
|
+
{ name: 'Exact match (whole message)', value: 'exact' },
|
|
65
|
+
],
|
|
66
|
+
description: 'How to compare the message text against keywords',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async execute() {
|
|
72
|
+
var _a;
|
|
73
|
+
const items = this.getInputData();
|
|
74
|
+
const optedOutItems = [];
|
|
75
|
+
const optedInItems = [];
|
|
76
|
+
const otherItems = [];
|
|
77
|
+
for (let i = 0; i < items.length; i++) {
|
|
78
|
+
try {
|
|
79
|
+
const messageField = this.getNodeParameter('messageField', i);
|
|
80
|
+
const optOutRaw = this.getNodeParameter('optOutKeywords', i);
|
|
81
|
+
const optInRaw = this.getNodeParameter('optInKeywords', i);
|
|
82
|
+
const channel = this.getNodeParameter('channel', i);
|
|
83
|
+
const matchMode = this.getNodeParameter('matchMode', i);
|
|
84
|
+
const optOutKeywords = optOutRaw.split(',').map((k) => k.trim().toLowerCase()).filter(Boolean);
|
|
85
|
+
const optInKeywords = optInRaw.split(',').map((k) => k.trim().toLowerCase()).filter(Boolean);
|
|
86
|
+
const data = items[i].json;
|
|
87
|
+
const message = data[messageField] || {};
|
|
88
|
+
const phone = message.from || '';
|
|
89
|
+
const rawText = (((_a = message.text) === null || _a === void 0 ? void 0 : _a.body) || '').trim();
|
|
90
|
+
const text = rawText.toLowerCase();
|
|
91
|
+
const matches = (keywords) => matchMode === 'exact'
|
|
92
|
+
? keywords.includes(text)
|
|
93
|
+
: keywords.some((k) => text.includes(k));
|
|
94
|
+
const enriched = { ...data, _phone: phone, _text: rawText };
|
|
95
|
+
if (matches(optOutKeywords)) {
|
|
96
|
+
if (phone) {
|
|
97
|
+
try {
|
|
98
|
+
await GenericFunctions_1.ycloudApiRequest.call(this, 'POST', '/unsubscribers', { customer: phone, channel });
|
|
99
|
+
}
|
|
100
|
+
catch (_) {
|
|
101
|
+
// already unsubscribed — ignore
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
enriched._optAction = 'opted_out';
|
|
105
|
+
optedOutItems.push({ json: enriched, pairedItem: { item: i } });
|
|
106
|
+
}
|
|
107
|
+
else if (matches(optInKeywords)) {
|
|
108
|
+
if (phone) {
|
|
109
|
+
try {
|
|
110
|
+
await GenericFunctions_1.ycloudApiRequest.call(this, 'DELETE', `/unsubscribers/${encodeURIComponent(phone)}/${channel}`);
|
|
111
|
+
}
|
|
112
|
+
catch (_) {
|
|
113
|
+
// was not unsubscribed — ignore
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
enriched._optAction = 'opted_in';
|
|
117
|
+
optedInItems.push({ json: enriched, pairedItem: { item: i } });
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
otherItems.push({ json: enriched, pairedItem: { item: i } });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (this.continueOnFail()) {
|
|
125
|
+
otherItems.push({ json: { error: error.message }, pairedItem: { item: i } });
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return [optedOutItems, optedInItems, otherItems];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.YCloudOptHandler = YCloudOptHandler;
|
|
136
|
+
//# sourceMappingURL=YCloudOptHandler.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YCloudOptHandler.node.js","sourceRoot":"","sources":["../../../nodes/YCloud/YCloudOptHandler.node.ts"],"names":[],"mappings":";;;AACA,+CAAmD;AACnD,yDAAsD;AAEtD,MAAa,gBAAgB;IAA7B;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,iCAAiC;YAC9C,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,sBAAsB;YAC5B,KAAK,EAAE,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8BAA8B;YACxC,WAAW,EAAE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,CAAC;QACH,CAAC;QAED,OAAO,CAAC,aAAa,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACnD,CAAC;CACF;AAhID,4CAgIC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class YCloudTagCampaign implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YCloudTagCampaign = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
6
|
+
class YCloudTagCampaign {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.description = {
|
|
9
|
+
displayName: 'YCloud Tag Campaign',
|
|
10
|
+
name: 'yCloudTagCampaign',
|
|
11
|
+
icon: 'file:logo-ycloud.png',
|
|
12
|
+
group: ['output'],
|
|
13
|
+
version: 1,
|
|
14
|
+
subtitle: '={{ $parameter["tag"] }}',
|
|
15
|
+
description: 'Lists all contacts with a specific tag, filters out unsubscribers, and sends a WhatsApp template to each. Returns one result item per contact.',
|
|
16
|
+
defaults: { name: 'YCloud Tag Campaign' },
|
|
17
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
18
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
19
|
+
outputNames: ['Results'],
|
|
20
|
+
credentials: [{ name: 'yCloudApi', required: true }],
|
|
21
|
+
properties: [
|
|
22
|
+
{
|
|
23
|
+
displayName: 'Tag',
|
|
24
|
+
name: 'tag',
|
|
25
|
+
type: 'string',
|
|
26
|
+
required: true,
|
|
27
|
+
default: '',
|
|
28
|
+
placeholder: 'premium',
|
|
29
|
+
description: 'Only contacts that have this tag will receive the campaign message',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
displayName: 'From Phone Number',
|
|
33
|
+
name: 'fromPhone',
|
|
34
|
+
type: 'string',
|
|
35
|
+
required: true,
|
|
36
|
+
default: '',
|
|
37
|
+
placeholder: '+16315551111',
|
|
38
|
+
description: 'Your WhatsApp Business phone number registered in YCloud',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
displayName: 'Template Name',
|
|
42
|
+
name: 'templateName',
|
|
43
|
+
type: 'string',
|
|
44
|
+
required: true,
|
|
45
|
+
default: '',
|
|
46
|
+
placeholder: 'campaign_offer',
|
|
47
|
+
description: 'Name of the approved WhatsApp template to send',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
displayName: 'Template Language',
|
|
51
|
+
name: 'templateLanguage',
|
|
52
|
+
type: 'string',
|
|
53
|
+
required: true,
|
|
54
|
+
default: 'pt_BR',
|
|
55
|
+
description: 'Language code of the template, e.g. pt_BR, en_US',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Template Body Variables (JSON)',
|
|
59
|
+
name: 'templateVarsJSON',
|
|
60
|
+
type: 'string',
|
|
61
|
+
typeOptions: { rows: 3 },
|
|
62
|
+
default: '[]',
|
|
63
|
+
description: 'JSON array of string values for template body variables: ["Promo10", "31/12/2025"]. Supports expressions.',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
displayName: 'Options',
|
|
67
|
+
name: 'options',
|
|
68
|
+
type: 'collection',
|
|
69
|
+
placeholder: 'Add Option',
|
|
70
|
+
default: {},
|
|
71
|
+
options: [
|
|
72
|
+
{
|
|
73
|
+
displayName: 'Filter Unsubscribed',
|
|
74
|
+
name: 'filterUnsubscribed',
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
default: true,
|
|
77
|
+
description: 'Let YCloud skip contacts that have opted out of WhatsApp messages',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
displayName: 'Header Media URL or ID',
|
|
81
|
+
name: 'headerMedia',
|
|
82
|
+
type: 'string',
|
|
83
|
+
default: '',
|
|
84
|
+
description: 'URL or media ID for image/video/document header (if your template uses one)',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
displayName: 'Delay Between Sends (ms)',
|
|
88
|
+
name: 'delay',
|
|
89
|
+
type: 'number',
|
|
90
|
+
default: 0,
|
|
91
|
+
description: 'Milliseconds to wait between each message send. Use to avoid rate limit bursts.',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async execute() {
|
|
99
|
+
const items = this.getInputData();
|
|
100
|
+
const resultItems = [];
|
|
101
|
+
for (let i = 0; i < items.length; i++) {
|
|
102
|
+
try {
|
|
103
|
+
const tag = this.getNodeParameter('tag', i);
|
|
104
|
+
const fromPhone = this.getNodeParameter('fromPhone', i);
|
|
105
|
+
const templateName = this.getNodeParameter('templateName', i);
|
|
106
|
+
const templateLanguage = this.getNodeParameter('templateLanguage', i);
|
|
107
|
+
const templateVarsRaw = this.getNodeParameter('templateVarsJSON', i);
|
|
108
|
+
const options = this.getNodeParameter('options', i);
|
|
109
|
+
const templateVars = JSON.parse(templateVarsRaw || '[]');
|
|
110
|
+
const components = [];
|
|
111
|
+
if (options.headerMedia) {
|
|
112
|
+
const headerMedia = options.headerMedia;
|
|
113
|
+
const isUrl = headerMedia.startsWith('http');
|
|
114
|
+
components.push({
|
|
115
|
+
type: 'header',
|
|
116
|
+
parameters: [{ type: 'image', image: isUrl ? { link: headerMedia } : { id: headerMedia } }],
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (templateVars.length > 0) {
|
|
120
|
+
components.push({
|
|
121
|
+
type: 'body',
|
|
122
|
+
parameters: templateVars.map((v) => ({ type: 'text', text: v })),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const allContacts = await GenericFunctions_1.ycloudApiRequestAllItems.call(this, 'GET', '/contact/contacts', {}, { tag });
|
|
126
|
+
const delay = options.delay || 0;
|
|
127
|
+
for (const contact of allContacts) {
|
|
128
|
+
const toPhone = contact.phoneNumber;
|
|
129
|
+
if (!toPhone)
|
|
130
|
+
continue;
|
|
131
|
+
const messageBody = {
|
|
132
|
+
from: fromPhone,
|
|
133
|
+
to: toPhone,
|
|
134
|
+
type: 'template',
|
|
135
|
+
filterUnsubscribed: options.filterUnsubscribed !== false,
|
|
136
|
+
template: {
|
|
137
|
+
name: templateName,
|
|
138
|
+
language: { code: templateLanguage },
|
|
139
|
+
...(components.length > 0 ? { components } : {}),
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
let sendResult = {};
|
|
143
|
+
let sendError = null;
|
|
144
|
+
try {
|
|
145
|
+
sendResult = await GenericFunctions_1.ycloudApiRequest.call(this, 'POST', '/whatsapp/messages', messageBody);
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
sendError = err.message;
|
|
149
|
+
}
|
|
150
|
+
resultItems.push({
|
|
151
|
+
json: {
|
|
152
|
+
contact,
|
|
153
|
+
message: sendResult,
|
|
154
|
+
error: sendError,
|
|
155
|
+
_sent: sendError === null,
|
|
156
|
+
_tag: tag,
|
|
157
|
+
},
|
|
158
|
+
pairedItem: { item: i },
|
|
159
|
+
});
|
|
160
|
+
if (delay > 0) {
|
|
161
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
if (this.continueOnFail()) {
|
|
167
|
+
resultItems.push({ json: { error: error.message }, pairedItem: { item: i } });
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return [resultItems];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.YCloudTagCampaign = YCloudTagCampaign;
|
|
178
|
+
//# sourceMappingURL=YCloudTagCampaign.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YCloudTagCampaign.node.js","sourceRoot":"","sources":["../../../nodes/YCloud/YCloudTagCampaign.node.ts"],"names":[],"mappings":";;;AACA,+CAAmD;AACnD,yDAAgF;AAEhF,MAAa,iBAAiB;IAA9B;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,qBAAqB;YAClC,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,sBAAsB;YAC5B,KAAK,EAAE,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,0BAA0B;YACpC,WAAW,EAAE,gJAAgJ;YAC7J,QAAQ,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE;YACzC,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,WAAW,EAAE,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACpD,UAAU,EAAE;gBACV;oBACE,WAAW,EAAE,KAAK;oBAClB,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,SAAS;oBACtB,WAAW,EAAE,oEAAoE;iBAClF;gBACD;oBACE,WAAW,EAAE,mBAAmB;oBAChC,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,cAAc;oBAC3B,WAAW,EAAE,0DAA0D;iBACxE;gBACD;oBACE,WAAW,EAAE,eAAe;oBAC5B,IAAI,EAAE,cAAc;oBACpB,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI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CAAC,IAAI,CAAC;wBACf,IAAI,EAAE;4BACJ,OAAO;4BACP,OAAO,EAAE,UAAU;4BACnB,KAAK,EAAE,SAAS;4BAChB,KAAK,EAAE,SAAS,KAAK,IAAI;4BACzB,IAAI,EAAE,GAAG;yBACV;wBACD,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;qBACxB,CAAC,CAAC;oBAEH,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;wBACd,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;oBAC7D,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC1B,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC3F,CAAC;qBAAM,CAAC;oBACN,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,WAAW,CAAC,CAAC;IACvB,CAAC;CACF;AAhLD,8CAgLC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class YCloudAutoResponder implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|