n8n-nodes-chatflow 1.1.2 → 1.1.4
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.
|
@@ -3,37 +3,6 @@ class ChatflowMessage {
|
|
|
3
3
|
this.description = ChatflowMessage.description;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
methods = {
|
|
7
|
-
loadOptions: {
|
|
8
|
-
async getPlatform() {
|
|
9
|
-
try {
|
|
10
|
-
const credentials = await this.getCredentials('chatflowApi');
|
|
11
|
-
const serverUrl = (credentials.serverUrl || 'https://app.chatflow.kz').replace(/\/+$/, '');
|
|
12
|
-
if (!credentials.flowId) return [];
|
|
13
|
-
|
|
14
|
-
const response = await this.helpers.httpRequest({
|
|
15
|
-
method: 'GET',
|
|
16
|
-
url: `${serverUrl}/api/v1/n8n/flow-info/${credentials.flowId}`,
|
|
17
|
-
qs: { token: credentials.token },
|
|
18
|
-
json: true,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
if (response && response.platform) {
|
|
22
|
-
const platName = response.platform === 'telegram' ? 'Telegram' : 'WhatsApp';
|
|
23
|
-
return [{ name: platName, value: response.platform }];
|
|
24
|
-
}
|
|
25
|
-
} catch(e) {
|
|
26
|
-
console.error('Failed to load platform:', e);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return [
|
|
30
|
-
{ name: 'WhatsApp', value: 'whatsapp' },
|
|
31
|
-
{ name: 'Telegram', value: 'telegram' }
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
6
|
async execute() {
|
|
38
7
|
const items = this.getInputData();
|
|
39
8
|
const out = [];
|
|
@@ -41,26 +10,38 @@ class ChatflowMessage {
|
|
|
41
10
|
const token = credentials.token;
|
|
42
11
|
const flowId = credentials.flowId;
|
|
43
12
|
const serverUrl = 'https://lk.chatflow.kz';
|
|
44
|
-
const platform = this.getNodeParameter('platform', 0, 'whatsapp');
|
|
45
13
|
|
|
46
14
|
const operation = this.getNodeParameter('operation', 0);
|
|
47
15
|
const continueOnFail = this.getNodeParameter('continueOnFail', 0);
|
|
48
16
|
|
|
17
|
+
// Fetch platform automatically from server
|
|
18
|
+
let platform = 'whatsapp';
|
|
19
|
+
try {
|
|
20
|
+
const infoResp = await this.helpers.httpRequest({
|
|
21
|
+
method: 'GET',
|
|
22
|
+
url: `${serverUrl}/api/v1/n8n/flow-info/${flowId}`,
|
|
23
|
+
qs: { token },
|
|
24
|
+
json: true,
|
|
25
|
+
});
|
|
26
|
+
if (infoResp && infoResp.platform) {
|
|
27
|
+
platform = infoResp.platform;
|
|
28
|
+
}
|
|
29
|
+
} catch(e) {
|
|
30
|
+
// fallback to whatsapp
|
|
31
|
+
}
|
|
32
|
+
|
|
49
33
|
for (let i = 0; i < items.length; i++) {
|
|
50
34
|
try {
|
|
51
35
|
const recipient = this.getNodeParameter('recipient', i);
|
|
52
36
|
|
|
53
|
-
// Build query string params
|
|
54
37
|
const qs = { token, flow_id: flowId };
|
|
55
38
|
|
|
56
|
-
// Set recipient field based on platform
|
|
57
39
|
if (platform === 'telegram') {
|
|
58
40
|
qs.chat_id = recipient;
|
|
59
41
|
} else {
|
|
60
42
|
qs.jid = recipient;
|
|
61
43
|
}
|
|
62
44
|
|
|
63
|
-
// Operation-specific params
|
|
64
45
|
if (operation === 'text') {
|
|
65
46
|
qs.msg = this.getNodeParameter('msg', i);
|
|
66
47
|
}
|
|
@@ -119,7 +100,7 @@ ChatflowMessage.description = {
|
|
|
119
100
|
},
|
|
120
101
|
group: ['output'],
|
|
121
102
|
version: 2,
|
|
122
|
-
subtitle: '={{$parameter["operation"]}}
|
|
103
|
+
subtitle: '={{$parameter["operation"]}}',
|
|
123
104
|
description: 'Send WhatsApp & Telegram messages via Chatflow API',
|
|
124
105
|
defaults: { name: 'Chatflow' },
|
|
125
106
|
inputs: [{ type: 'main' }],
|
|
@@ -128,15 +109,6 @@ ChatflowMessage.description = {
|
|
|
128
109
|
{ name: 'chatflowApi', required: true },
|
|
129
110
|
],
|
|
130
111
|
properties: [
|
|
131
|
-
{
|
|
132
|
-
displayName: 'Messaging Platform',
|
|
133
|
-
name: 'platform',
|
|
134
|
-
type: 'options',
|
|
135
|
-
typeOptions: { loadOptionsMethod: 'getPlatform' },
|
|
136
|
-
default: '',
|
|
137
|
-
required: true,
|
|
138
|
-
description: 'Automatically determined from your Chatflow credentials (Flow ID)',
|
|
139
|
-
},
|
|
140
112
|
{
|
|
141
113
|
displayName: 'Operation',
|
|
142
114
|
name: 'operation',
|
|
@@ -152,23 +124,13 @@ ChatflowMessage.description = {
|
|
|
152
124
|
default: 'text',
|
|
153
125
|
},
|
|
154
126
|
{
|
|
155
|
-
displayName: 'Recipient
|
|
156
|
-
name: 'recipient',
|
|
157
|
-
type: 'string',
|
|
158
|
-
default: '',
|
|
159
|
-
required: true,
|
|
160
|
-
displayOptions: { show: { platform: ['whatsapp'] } },
|
|
161
|
-
description: 'WhatsApp phone number (e.g. 77001234567)',
|
|
162
|
-
placeholder: '77001234567',
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
displayName: 'Chat ID (Telegram)',
|
|
127
|
+
displayName: 'Recipient',
|
|
166
128
|
name: 'recipient',
|
|
167
129
|
type: 'string',
|
|
168
130
|
default: '',
|
|
169
131
|
required: true,
|
|
170
|
-
|
|
171
|
-
|
|
132
|
+
description: 'WhatsApp number (e.g. 77001234567) or Telegram Chat ID — determined automatically from Flow',
|
|
133
|
+
placeholder: '77001234567 or -100123456789',
|
|
172
134
|
},
|
|
173
135
|
// --- Text ---
|
|
174
136
|
{
|
|
@@ -179,25 +141,15 @@ ChatflowMessage.description = {
|
|
|
179
141
|
default: '',
|
|
180
142
|
required: true,
|
|
181
143
|
displayOptions: { show: { operation: ['text'] } },
|
|
182
|
-
description: 'Text of the message to send',
|
|
183
144
|
},
|
|
184
|
-
// ---
|
|
145
|
+
// --- Audio ---
|
|
185
146
|
{
|
|
186
|
-
displayName: '
|
|
187
|
-
name: '
|
|
147
|
+
displayName: 'Audio URL',
|
|
148
|
+
name: 'audiourl',
|
|
188
149
|
type: 'string',
|
|
189
150
|
default: '',
|
|
190
151
|
required: true,
|
|
191
|
-
displayOptions: { show: { operation: ['
|
|
192
|
-
description: 'Public URL of the image file',
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
displayName: 'Caption',
|
|
196
|
-
name: 'captionImg',
|
|
197
|
-
type: 'string',
|
|
198
|
-
default: '',
|
|
199
|
-
displayOptions: { show: { operation: ['image'] } },
|
|
200
|
-
description: 'Optional caption for the image',
|
|
152
|
+
displayOptions: { show: { operation: ['audio'] } },
|
|
201
153
|
},
|
|
202
154
|
// --- Video ---
|
|
203
155
|
{
|
|
@@ -207,7 +159,6 @@ ChatflowMessage.description = {
|
|
|
207
159
|
default: '',
|
|
208
160
|
required: true,
|
|
209
161
|
displayOptions: { show: { operation: ['video'] } },
|
|
210
|
-
description: 'Public URL of the video file',
|
|
211
162
|
},
|
|
212
163
|
{
|
|
213
164
|
displayName: 'Caption',
|
|
@@ -215,17 +166,6 @@ ChatflowMessage.description = {
|
|
|
215
166
|
type: 'string',
|
|
216
167
|
default: '',
|
|
217
168
|
displayOptions: { show: { operation: ['video'] } },
|
|
218
|
-
description: 'Optional caption for the video',
|
|
219
|
-
},
|
|
220
|
-
// --- Audio ---
|
|
221
|
-
{
|
|
222
|
-
displayName: 'Audio URL',
|
|
223
|
-
name: 'audiourl',
|
|
224
|
-
type: 'string',
|
|
225
|
-
default: '',
|
|
226
|
-
required: true,
|
|
227
|
-
displayOptions: { show: { operation: ['audio'] } },
|
|
228
|
-
description: 'Public URL of the audio file',
|
|
229
169
|
},
|
|
230
170
|
// --- Document ---
|
|
231
171
|
{
|
|
@@ -235,7 +175,6 @@ ChatflowMessage.description = {
|
|
|
235
175
|
default: '',
|
|
236
176
|
required: true,
|
|
237
177
|
displayOptions: { show: { operation: ['document'] } },
|
|
238
|
-
description: 'Public URL of the document file',
|
|
239
178
|
},
|
|
240
179
|
{
|
|
241
180
|
displayName: 'Caption',
|
|
@@ -243,15 +182,29 @@ ChatflowMessage.description = {
|
|
|
243
182
|
type: 'string',
|
|
244
183
|
default: '',
|
|
245
184
|
displayOptions: { show: { operation: ['document'] } },
|
|
246
|
-
description: 'Optional caption for the document',
|
|
247
185
|
},
|
|
248
|
-
// ---
|
|
186
|
+
// --- Image ---
|
|
187
|
+
{
|
|
188
|
+
displayName: 'Image URL',
|
|
189
|
+
name: 'imageurl',
|
|
190
|
+
type: 'string',
|
|
191
|
+
default: '',
|
|
192
|
+
required: true,
|
|
193
|
+
displayOptions: { show: { operation: ['image'] } },
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
displayName: 'Caption',
|
|
197
|
+
name: 'captionImg',
|
|
198
|
+
type: 'string',
|
|
199
|
+
default: '',
|
|
200
|
+
displayOptions: { show: { operation: ['image'] } },
|
|
201
|
+
},
|
|
202
|
+
// Continue on fail
|
|
249
203
|
{
|
|
250
204
|
displayName: 'Continue On Fail',
|
|
251
205
|
name: 'continueOnFail',
|
|
252
206
|
type: 'boolean',
|
|
253
|
-
default:
|
|
254
|
-
description: 'Whether to continue workflow execution on send failure',
|
|
207
|
+
default: false,
|
|
255
208
|
},
|
|
256
209
|
],
|
|
257
210
|
};
|