n8n-nodes-vendschat 1.0.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/LICENSE +21 -0
- package/README.md +79 -0
- package/dist/credentials/VendsChatApi.credentials.d.ts +9 -0
- package/dist/credentials/VendsChatApi.credentials.js +61 -0
- package/dist/credentials/VendsChatApi.credentials.js.map +1 -0
- package/dist/credentials/vendschat.svg +58 -0
- package/dist/lib/adapters/baseAdapter.d.ts +3 -0
- package/dist/lib/adapters/baseAdapter.js +14 -0
- package/dist/lib/adapters/baseAdapter.js.map +1 -0
- package/dist/lib/adapters/index.d.ts +2 -0
- package/dist/lib/adapters/index.js +21 -0
- package/dist/lib/adapters/index.js.map +1 -0
- package/dist/lib/adapters/instagramAdapter.d.ts +2 -0
- package/dist/lib/adapters/instagramAdapter.js +6 -0
- package/dist/lib/adapters/instagramAdapter.js.map +1 -0
- package/dist/lib/adapters/lineAdapter.d.ts +2 -0
- package/dist/lib/adapters/lineAdapter.js +6 -0
- package/dist/lib/adapters/lineAdapter.js.map +1 -0
- package/dist/lib/adapters/messengerAdapter.d.ts +2 -0
- package/dist/lib/adapters/messengerAdapter.js +6 -0
- package/dist/lib/adapters/messengerAdapter.js.map +1 -0
- package/dist/lib/adapters/telegramAdapter.d.ts +2 -0
- package/dist/lib/adapters/telegramAdapter.js +6 -0
- package/dist/lib/adapters/telegramAdapter.js.map +1 -0
- package/dist/lib/adapters/types.d.ts +6 -0
- package/dist/lib/adapters/types.js +3 -0
- package/dist/lib/adapters/types.js.map +1 -0
- package/dist/lib/adapters/whatsappAdapter.d.ts +2 -0
- package/dist/lib/adapters/whatsappAdapter.js +15 -0
- package/dist/lib/adapters/whatsappAdapter.js.map +1 -0
- package/dist/lib/buildSendMessageRequest.d.ts +19 -0
- package/dist/lib/buildSendMessageRequest.js +125 -0
- package/dist/lib/buildSendMessageRequest.js.map +1 -0
- package/dist/lib/contactFields.d.ts +9 -0
- package/dist/lib/contactFields.js +163 -0
- package/dist/lib/contactFields.js.map +1 -0
- package/dist/lib/events.d.ts +4 -0
- package/dist/lib/events.js +35 -0
- package/dist/lib/events.js.map +1 -0
- package/dist/lib/http.d.ts +10 -0
- package/dist/lib/http.js +20 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/integrationApi.d.ts +8 -0
- package/dist/lib/integrationApi.js +17 -0
- package/dist/lib/integrationApi.js.map +1 -0
- package/dist/lib/productCopy.d.ts +7 -0
- package/dist/lib/productCopy.js +11 -0
- package/dist/lib/productCopy.js.map +1 -0
- package/dist/lib/sendMessageFields.d.ts +2 -0
- package/dist/lib/sendMessageFields.js +257 -0
- package/dist/lib/sendMessageFields.js.map +1 -0
- package/dist/lib/types.d.ts +26 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/vendsChatCodex.d.ts +2 -0
- package/dist/lib/vendsChatCodex.js +12 -0
- package/dist/lib/vendsChatCodex.js.map +1 -0
- package/dist/nodes/VendsChat/VendsChat.node.d.ts +21 -0
- package/dist/nodes/VendsChat/VendsChat.node.js +228 -0
- package/dist/nodes/VendsChat/VendsChat.node.js.map +1 -0
- package/dist/nodes/VendsChat/VendsChat.node.json +19 -0
- package/dist/nodes/VendsChat/VendsChatSendMessage.node.d.ts +17 -0
- package/dist/nodes/VendsChat/VendsChatSendMessage.node.js +130 -0
- package/dist/nodes/VendsChat/VendsChatSendMessage.node.js.map +1 -0
- package/dist/nodes/VendsChat/VendsChatSendMessage.node.json +18 -0
- package/dist/nodes/VendsChat/VendsChatTrigger.node.d.ts +23 -0
- package/dist/nodes/VendsChat/VendsChatTrigger.node.js +200 -0
- package/dist/nodes/VendsChat/VendsChatTrigger.node.js.map +1 -0
- package/dist/nodes/VendsChat/VendsChatTrigger.node.json +19 -0
- package/dist/nodes/VendsChat/vendschat.svg +58 -0
- package/index.js +6 -0
- package/package.json +60 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class VendsChat implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
getChannels(this: ILoadOptionsFunctions): Promise<{
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[]>;
|
|
10
|
+
getTemplates(this: ILoadOptionsFunctions): Promise<{
|
|
11
|
+
name: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[]>;
|
|
14
|
+
getLabels(this: ILoadOptionsFunctions): Promise<{
|
|
15
|
+
name: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}[]>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VendsChat = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const integrationApi_1 = require("../../lib/integrationApi");
|
|
6
|
+
const productCopy_1 = require("../../lib/productCopy");
|
|
7
|
+
const sendMessageFields_1 = require("../../lib/sendMessageFields");
|
|
8
|
+
const vendsChatCodex_1 = require("../../lib/vendsChatCodex");
|
|
9
|
+
function buildSendMessagePayload(item) {
|
|
10
|
+
var _a;
|
|
11
|
+
const templateVars = {};
|
|
12
|
+
const rawVars = item.templateVariables;
|
|
13
|
+
for (const row of (_a = rawVars === null || rawVars === void 0 ? void 0 : rawVars.variable) !== null && _a !== void 0 ? _a : []) {
|
|
14
|
+
if (row.key)
|
|
15
|
+
templateVars[row.key] = row.value;
|
|
16
|
+
}
|
|
17
|
+
const channelMode = item.channelMode;
|
|
18
|
+
return {
|
|
19
|
+
identifier_type: item.identifierType,
|
|
20
|
+
identifier_value: item.identifierValue,
|
|
21
|
+
channel_mode: channelMode,
|
|
22
|
+
channel_id: item.channelId ? Number(item.channelId) : undefined,
|
|
23
|
+
content_mode: item.contentMode,
|
|
24
|
+
message_type: item.messageType,
|
|
25
|
+
attachment_type: item.attachmentType,
|
|
26
|
+
text: channelMode === 'specific'
|
|
27
|
+
? item.specificText || undefined
|
|
28
|
+
: item.text || undefined,
|
|
29
|
+
media_url: channelMode === 'specific'
|
|
30
|
+
? item.specificMediaUrl || undefined
|
|
31
|
+
: item.mediaUrl || undefined,
|
|
32
|
+
caption: channelMode === 'specific'
|
|
33
|
+
? item.specificCaption || undefined
|
|
34
|
+
: item.caption || undefined,
|
|
35
|
+
filename: channelMode === 'specific'
|
|
36
|
+
? item.specificFilename || undefined
|
|
37
|
+
: item.filename || undefined,
|
|
38
|
+
template_id: item.templateId ? Number(item.templateId) : undefined,
|
|
39
|
+
template_variables: Object.keys(templateVars).length > 0 ? templateVars : undefined,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function parseLabelIds(raw) {
|
|
43
|
+
if (raw == null || raw === '')
|
|
44
|
+
return [];
|
|
45
|
+
if (Array.isArray(raw)) {
|
|
46
|
+
return raw
|
|
47
|
+
.map((v) => Number(v))
|
|
48
|
+
.filter((n) => Number.isInteger(n) && n > 0);
|
|
49
|
+
}
|
|
50
|
+
return String(raw)
|
|
51
|
+
.split(',')
|
|
52
|
+
.map((s) => Number(s.trim()))
|
|
53
|
+
.filter((n) => Number.isInteger(n) && n > 0);
|
|
54
|
+
}
|
|
55
|
+
function optionalString(value) {
|
|
56
|
+
if (value == null)
|
|
57
|
+
return undefined;
|
|
58
|
+
const s = String(value).trim();
|
|
59
|
+
return s === '' ? undefined : s;
|
|
60
|
+
}
|
|
61
|
+
async function executeContactOperation(ctx, cred, operation, itemIndex) {
|
|
62
|
+
const identifierType = ctx.getNodeParameter('identifierType', itemIndex, '');
|
|
63
|
+
const identifierValue = ctx.getNodeParameter('identifierValue', itemIndex, '');
|
|
64
|
+
if (operation === 'getContact') {
|
|
65
|
+
return (0, integrationApi_1.vendsChatIntegrationRequest)(ctx, cred, '/integrations/contacts/lookup', 'POST', {
|
|
66
|
+
identifier_type: identifierType,
|
|
67
|
+
identifier_value: identifierValue,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (operation === 'createContact') {
|
|
71
|
+
return (0, integrationApi_1.vendsChatIntegrationRequest)(ctx, cred, '/integrations/contacts', 'POST', {
|
|
72
|
+
name: optionalString(ctx.getNodeParameter('name', itemIndex, '')),
|
|
73
|
+
phone_number: optionalString(ctx.getNodeParameter('phoneNumber', itemIndex, '')),
|
|
74
|
+
email: optionalString(ctx.getNodeParameter('email', itemIndex, '')),
|
|
75
|
+
note: optionalString(ctx.getNodeParameter('note', itemIndex, '')),
|
|
76
|
+
country: optionalString(ctx.getNodeParameter('country', itemIndex, '')),
|
|
77
|
+
language: optionalString(ctx.getNodeParameter('language', itemIndex, '')),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (operation === 'updateContact') {
|
|
81
|
+
return (0, integrationApi_1.vendsChatIntegrationRequest)(ctx, cred, '/integrations/contacts', 'PATCH', {
|
|
82
|
+
identifier_type: identifierType,
|
|
83
|
+
identifier_value: identifierValue,
|
|
84
|
+
name: optionalString(ctx.getNodeParameter('name', itemIndex, '')),
|
|
85
|
+
phone_number: optionalString(ctx.getNodeParameter('updatePhoneNumber', itemIndex, '')),
|
|
86
|
+
email: optionalString(ctx.getNodeParameter('updateEmail', itemIndex, '')),
|
|
87
|
+
note: optionalString(ctx.getNodeParameter('note', itemIndex, '')),
|
|
88
|
+
country: optionalString(ctx.getNodeParameter('country', itemIndex, '')),
|
|
89
|
+
language: optionalString(ctx.getNodeParameter('language', itemIndex, '')),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (operation === 'deleteContact') {
|
|
93
|
+
return (0, integrationApi_1.vendsChatIntegrationRequest)(ctx, cred, '/integrations/contacts', 'DELETE', {
|
|
94
|
+
identifier_type: identifierType,
|
|
95
|
+
identifier_value: identifierValue,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (operation === 'addContactLabels') {
|
|
99
|
+
return (0, integrationApi_1.vendsChatIntegrationRequest)(ctx, cred, '/integrations/contacts/labels/add', 'POST', {
|
|
100
|
+
identifier_type: identifierType,
|
|
101
|
+
identifier_value: identifierValue,
|
|
102
|
+
label_ids: parseLabelIds(ctx.getNodeParameter('labelIds', itemIndex, [])),
|
|
103
|
+
labels: optionalString(ctx.getNodeParameter('labelNames', itemIndex, '')),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (operation === 'removeContactLabels') {
|
|
107
|
+
return (0, integrationApi_1.vendsChatIntegrationRequest)(ctx, cred, '/integrations/contacts/labels/remove', 'POST', {
|
|
108
|
+
identifier_type: identifierType,
|
|
109
|
+
identifier_value: identifierValue,
|
|
110
|
+
label_ids: parseLabelIds(ctx.getNodeParameter('removeLabelIds', itemIndex, [])),
|
|
111
|
+
labels: optionalString(ctx.getNodeParameter('removeLabelNames', itemIndex, '')),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (operation === 'upsertContactNote') {
|
|
115
|
+
return (0, integrationApi_1.vendsChatIntegrationRequest)(ctx, cred, '/integrations/contacts/note', 'PUT', {
|
|
116
|
+
identifier_type: identifierType,
|
|
117
|
+
identifier_value: identifierValue,
|
|
118
|
+
note: ctx.getNodeParameter('note', itemIndex, ''),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `Operation "${operation}" is not supported`);
|
|
122
|
+
}
|
|
123
|
+
class VendsChat {
|
|
124
|
+
constructor() {
|
|
125
|
+
this.description = {
|
|
126
|
+
displayName: productCopy_1.displayNameAction,
|
|
127
|
+
name: 'vendsChat',
|
|
128
|
+
icon: 'file:vendschat.svg',
|
|
129
|
+
group: ['input'],
|
|
130
|
+
version: 1,
|
|
131
|
+
subtitle: productCopy_1.subtitleAction,
|
|
132
|
+
description: productCopy_1.descriptionAction,
|
|
133
|
+
defaults: { name: 'Vendschat' },
|
|
134
|
+
inputs: ['main'],
|
|
135
|
+
outputs: ['main'],
|
|
136
|
+
usableAsTool: true,
|
|
137
|
+
credentials: [{ name: 'vendsChatApi', required: true }],
|
|
138
|
+
properties: sendMessageFields_1.sendMessageFields,
|
|
139
|
+
codex: vendsChatCodex_1.vendsChatCodex,
|
|
140
|
+
};
|
|
141
|
+
this.methods = {
|
|
142
|
+
loadOptions: {
|
|
143
|
+
async getChannels() {
|
|
144
|
+
var _a;
|
|
145
|
+
const cred = (await this.getCredentials('vendsChatApi'));
|
|
146
|
+
const res = await (0, integrationApi_1.vendsChatIntegrationRequest)(this, cred, '/integrations/messages/channels');
|
|
147
|
+
const channels = (_a = res.channels) !== null && _a !== void 0 ? _a : [];
|
|
148
|
+
return channels.map((ch) => ({
|
|
149
|
+
name: `${ch.display_name} (${ch.channel_type})`,
|
|
150
|
+
value: String(ch.id),
|
|
151
|
+
}));
|
|
152
|
+
},
|
|
153
|
+
async getTemplates() {
|
|
154
|
+
var _a;
|
|
155
|
+
const cred = (await this.getCredentials('vendsChatApi'));
|
|
156
|
+
const channelId = this.getNodeParameter('channelId', 0);
|
|
157
|
+
const res = await (0, integrationApi_1.vendsChatIntegrationRequest)(this, cred, `/integrations/messages/templates?channel_id=${channelId}`);
|
|
158
|
+
const templates = (_a = res.templates) !== null && _a !== void 0 ? _a : [];
|
|
159
|
+
return templates.map((t) => {
|
|
160
|
+
var _a;
|
|
161
|
+
return ({
|
|
162
|
+
name: String((_a = t.label) !== null && _a !== void 0 ? _a : t.name),
|
|
163
|
+
value: String(t.id),
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
async getLabels() {
|
|
168
|
+
var _a;
|
|
169
|
+
const cred = (await this.getCredentials('vendsChatApi'));
|
|
170
|
+
const res = await (0, integrationApi_1.vendsChatIntegrationRequest)(this, cred, '/integrations/labels');
|
|
171
|
+
const rows = (_a = res.labels) !== null && _a !== void 0 ? _a : [];
|
|
172
|
+
return rows.map((row) => ({
|
|
173
|
+
name: String(row.name || `Label ${row.id}`),
|
|
174
|
+
value: String(row.id),
|
|
175
|
+
}));
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
async execute() {
|
|
181
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
182
|
+
const cred = (await this.getCredentials('vendsChatApi'));
|
|
183
|
+
const items = this.getInputData();
|
|
184
|
+
const out = [];
|
|
185
|
+
for (let i = 0; i < items.length; i++) {
|
|
186
|
+
try {
|
|
187
|
+
let response;
|
|
188
|
+
if (operation === 'sendMessage') {
|
|
189
|
+
const payload = buildSendMessagePayload({
|
|
190
|
+
identifierType: this.getNodeParameter('identifierType', i),
|
|
191
|
+
identifierValue: this.getNodeParameter('identifierValue', i),
|
|
192
|
+
channelMode: this.getNodeParameter('channelMode', i),
|
|
193
|
+
contentMode: this.getNodeParameter('contentMode', i),
|
|
194
|
+
text: this.getNodeParameter('text', i),
|
|
195
|
+
attachmentType: this.getNodeParameter('attachmentType', i),
|
|
196
|
+
channelId: this.getNodeParameter('channelId', i, ''),
|
|
197
|
+
messageType: this.getNodeParameter('messageType', i, ''),
|
|
198
|
+
templateId: this.getNodeParameter('templateId', i, ''),
|
|
199
|
+
templateVariables: this.getNodeParameter('templateVariables', i, {}),
|
|
200
|
+
specificText: this.getNodeParameter('specificText', i, ''),
|
|
201
|
+
mediaUrl: this.getNodeParameter('mediaUrl', i, ''),
|
|
202
|
+
specificMediaUrl: this.getNodeParameter('specificMediaUrl', i, ''),
|
|
203
|
+
caption: this.getNodeParameter('caption', i, ''),
|
|
204
|
+
specificCaption: this.getNodeParameter('specificCaption', i, ''),
|
|
205
|
+
filename: this.getNodeParameter('filename', i, ''),
|
|
206
|
+
specificFilename: this.getNodeParameter('specificFilename', i, ''),
|
|
207
|
+
});
|
|
208
|
+
response = await (0, integrationApi_1.vendsChatIntegrationRequest)(this, cred, '/integrations/messages/send', 'POST', payload);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
response = await executeContactOperation(this, cred, operation, i);
|
|
212
|
+
}
|
|
213
|
+
out.push({ json: response, pairedItem: { item: i } });
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
if (this.continueOnFail()) {
|
|
217
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
218
|
+
out.push({ json: { success: false, error: message }, pairedItem: { item: i } });
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return [out];
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
exports.VendsChat = VendsChat;
|
|
228
|
+
//# sourceMappingURL=VendsChat.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VendsChat.node.js","sourceRoot":"","sources":["../../../nodes/VendsChat/VendsChat.node.ts"],"names":[],"mappings":";;;AAQA,+CAAkD;AAElD,6DAAuE;AACvE,uDAI+B;AAC/B,mEAAgE;AAChE,6DAA0D;AAE1D,SAAS,uBAAuB,CAAC,IAAiB;;IACjD,MAAM,YAAY,GAA2B,EAAE,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAyE,CAAC;IAC/F,KAAK,MAAM,GAAG,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,mCAAI,EAAE,EAAE,CAAC;QAC3C,IAAI,GAAG,CAAC,GAAG;YAAE,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC;IAChD,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,WAAqB,CAAC;IAE/C,OAAO;QACN,eAAe,EAAE,IAAI,CAAC,cAAc;QACpC,gBAAgB,EAAE,IAA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AAS,EAAE,CAAC,CAAC,CAAC;gBACpE,CAAC;gBAED,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACvD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC3B,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACvE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;oBAChF,SAAS;gBACV,CAAC;gBACD,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAc,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;YAChF,CAAC;QACF,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,CAAC;IACd,CAAC;CACD;AA9GD,8BA8GC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-vendschat.vendsChat",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["Communication"],
|
|
6
|
+
"alias": ["Vendschat", "vendschat", "whatsapp", "instagram", "messenger"],
|
|
7
|
+
"resources": {
|
|
8
|
+
"credentialDocumentation": [
|
|
9
|
+
{
|
|
10
|
+
"url": "https://docs.vendschat.com/docs/auth"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"primaryDocumentation": [
|
|
14
|
+
{
|
|
15
|
+
"url": "https://docs.vendschat.com"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class VendsChatSendMessage implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
getChannels(this: ILoadOptionsFunctions): Promise<{
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[]>;
|
|
10
|
+
getTemplates(this: ILoadOptionsFunctions): Promise<{
|
|
11
|
+
name: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[]>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VendsChatSendMessage = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const integrationApi_1 = require("../../lib/integrationApi");
|
|
6
|
+
const productCopy_1 = require("../../lib/productCopy");
|
|
7
|
+
const sendMessageFields_1 = require("../../lib/sendMessageFields");
|
|
8
|
+
const vendsChatCodex_1 = require("../../lib/vendsChatCodex");
|
|
9
|
+
function buildPayload(item) {
|
|
10
|
+
var _a;
|
|
11
|
+
const templateVars = {};
|
|
12
|
+
const rawVars = item.templateVariables;
|
|
13
|
+
for (const row of (_a = rawVars === null || rawVars === void 0 ? void 0 : rawVars.variable) !== null && _a !== void 0 ? _a : []) {
|
|
14
|
+
if (row.key)
|
|
15
|
+
templateVars[row.key] = row.value;
|
|
16
|
+
}
|
|
17
|
+
const channelMode = item.channelMode;
|
|
18
|
+
return {
|
|
19
|
+
identifier_type: item.identifierType,
|
|
20
|
+
identifier_value: item.identifierValue,
|
|
21
|
+
channel_mode: channelMode,
|
|
22
|
+
channel_id: item.channelId ? Number(item.channelId) : undefined,
|
|
23
|
+
content_mode: item.contentMode,
|
|
24
|
+
message_type: item.messageType,
|
|
25
|
+
attachment_type: item.attachmentType,
|
|
26
|
+
text: channelMode === 'specific'
|
|
27
|
+
? item.specificText || undefined
|
|
28
|
+
: item.text || undefined,
|
|
29
|
+
media_url: channelMode === 'specific'
|
|
30
|
+
? item.specificMediaUrl || undefined
|
|
31
|
+
: item.mediaUrl || undefined,
|
|
32
|
+
caption: channelMode === 'specific'
|
|
33
|
+
? item.specificCaption || undefined
|
|
34
|
+
: item.caption || undefined,
|
|
35
|
+
filename: channelMode === 'specific'
|
|
36
|
+
? item.specificFilename || undefined
|
|
37
|
+
: item.filename || undefined,
|
|
38
|
+
template_id: item.templateId ? Number(item.templateId) : undefined,
|
|
39
|
+
template_variables: Object.keys(templateVars).length > 0 ? templateVars : undefined,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
class VendsChatSendMessage {
|
|
43
|
+
constructor() {
|
|
44
|
+
this.description = {
|
|
45
|
+
displayName: productCopy_1.displayNameSendMessage,
|
|
46
|
+
name: 'vendsChatSendMessage',
|
|
47
|
+
icon: 'file:vendschat.svg',
|
|
48
|
+
group: ['transform'],
|
|
49
|
+
version: 1,
|
|
50
|
+
subtitle: productCopy_1.subtitleSendMessage,
|
|
51
|
+
description: productCopy_1.descriptionSendMessage,
|
|
52
|
+
defaults: { name: productCopy_1.displayNameSendMessage },
|
|
53
|
+
inputs: ['main'],
|
|
54
|
+
outputs: ['main'],
|
|
55
|
+
usableAsTool: true,
|
|
56
|
+
credentials: [{ name: 'vendsChatApi', required: true }],
|
|
57
|
+
properties: sendMessageFields_1.sendMessageFields,
|
|
58
|
+
codex: vendsChatCodex_1.vendsChatCodex,
|
|
59
|
+
};
|
|
60
|
+
this.methods = {
|
|
61
|
+
loadOptions: {
|
|
62
|
+
async getChannels() {
|
|
63
|
+
var _a;
|
|
64
|
+
const cred = (await this.getCredentials('vendsChatApi'));
|
|
65
|
+
const res = await (0, integrationApi_1.vendsChatIntegrationRequest)(this, cred, '/integrations/messages/channels');
|
|
66
|
+
const channels = (_a = res.channels) !== null && _a !== void 0 ? _a : [];
|
|
67
|
+
return channels.map((ch) => ({
|
|
68
|
+
name: `${ch.display_name} (${ch.channel_type})`,
|
|
69
|
+
value: String(ch.id),
|
|
70
|
+
}));
|
|
71
|
+
},
|
|
72
|
+
async getTemplates() {
|
|
73
|
+
var _a;
|
|
74
|
+
const cred = (await this.getCredentials('vendsChatApi'));
|
|
75
|
+
const channelId = this.getNodeParameter('channelId', 0);
|
|
76
|
+
const res = await (0, integrationApi_1.vendsChatIntegrationRequest)(this, cred, `/integrations/messages/templates?channel_id=${channelId}`);
|
|
77
|
+
const templates = (_a = res.templates) !== null && _a !== void 0 ? _a : [];
|
|
78
|
+
return templates.map((t) => {
|
|
79
|
+
var _a;
|
|
80
|
+
return ({
|
|
81
|
+
name: String((_a = t.label) !== null && _a !== void 0 ? _a : t.name),
|
|
82
|
+
value: String(t.id),
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async execute() {
|
|
90
|
+
const cred = (await this.getCredentials('vendsChatApi'));
|
|
91
|
+
const items = this.getInputData();
|
|
92
|
+
const out = [];
|
|
93
|
+
for (let i = 0; i < items.length; i++) {
|
|
94
|
+
try {
|
|
95
|
+
const payload = buildPayload({
|
|
96
|
+
identifierType: this.getNodeParameter('identifierType', i),
|
|
97
|
+
identifierValue: this.getNodeParameter('identifierValue', i),
|
|
98
|
+
channelMode: this.getNodeParameter('channelMode', i),
|
|
99
|
+
contentMode: this.getNodeParameter('contentMode', i),
|
|
100
|
+
text: this.getNodeParameter('text', i),
|
|
101
|
+
attachmentType: this.getNodeParameter('attachmentType', i),
|
|
102
|
+
channelId: this.getNodeParameter('channelId', i, ''),
|
|
103
|
+
messageType: this.getNodeParameter('messageType', i, ''),
|
|
104
|
+
templateId: this.getNodeParameter('templateId', i, ''),
|
|
105
|
+
templateVariables: this.getNodeParameter('templateVariables', i, {}),
|
|
106
|
+
specificText: this.getNodeParameter('specificText', i, ''),
|
|
107
|
+
mediaUrl: this.getNodeParameter('mediaUrl', i, ''),
|
|
108
|
+
specificMediaUrl: this.getNodeParameter('specificMediaUrl', i, ''),
|
|
109
|
+
caption: this.getNodeParameter('caption', i, ''),
|
|
110
|
+
specificCaption: this.getNodeParameter('specificCaption', i, ''),
|
|
111
|
+
filename: this.getNodeParameter('filename', i, ''),
|
|
112
|
+
specificFilename: this.getNodeParameter('specificFilename', i, ''),
|
|
113
|
+
});
|
|
114
|
+
const response = await (0, integrationApi_1.vendsChatIntegrationRequest)(this, cred, '/integrations/messages/send', 'POST', payload);
|
|
115
|
+
out.push({ json: response, pairedItem: { item: i } });
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (this.continueOnFail()) {
|
|
119
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
120
|
+
out.push({ json: { success: false, error: message }, pairedItem: { item: i } });
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return [out];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.VendsChatSendMessage = VendsChatSendMessage;
|
|
130
|
+
//# sourceMappingURL=VendsChatSendMessage.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VendsChatSendMessage.node.js","sourceRoot":"","sources":["../../../nodes/VendsChat/VendsChatSendMessage.node.ts"],"names":[],"mappings":";;;AAQA,+CAAkD;AAElD,6DAAuE;AACvE,uDAI+B;AAC/B,mEAAgE;AAChE,6DAA0D;AAE1D,SAAS,YAAY,CAAC,IAAiB;;IACtC,MAAM,YAAY,GAA2B,EAAE,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kB,EAAE,CAAC,EAAE,EAAE,CAAC;iBAClE,CAAC,CAAC;gBAEH,MAAM,QAAQ,GAAG,MAAM,IAAA,4CAA2B,EACjD,IAAI,EACJ,IAAI,EACJ,6BAA6B,EAC7B,MAAM,EACN,OAAO,CACP,CAAC;gBAEF,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACvD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC3B,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACvE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;oBAChF,SAAS;gBACV,CAAC;gBACD,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAc,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;YAChF,CAAC;QACF,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,CAAC;IACd,CAAC;CACD;AA9FD,oDA8FC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-vendschat",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["Communication"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"credentialDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://docs.vendschat.com/docs/auth"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"primaryDocumentation": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://docs.vendschat.com"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IHookFunctions, ILoadOptionsFunctions, INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
|
|
2
|
+
declare function registerWebhook(this: IHookFunctions): Promise<boolean>;
|
|
3
|
+
declare function unregisterWebhook(this: IHookFunctions): Promise<boolean>;
|
|
4
|
+
export declare class VendsChatTrigger implements INodeType {
|
|
5
|
+
description: INodeTypeDescription;
|
|
6
|
+
methods: {
|
|
7
|
+
loadOptions: {
|
|
8
|
+
getEvents(this: ILoadOptionsFunctions): Promise<{
|
|
9
|
+
name: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}[]>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
webhookMethods: {
|
|
15
|
+
default: {
|
|
16
|
+
checkExists(this: IHookFunctions): Promise<boolean>;
|
|
17
|
+
create: typeof registerWebhook;
|
|
18
|
+
delete: typeof unregisterWebhook;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|