@tiledesk/tiledesk-tybot-connector 0.2.130 → 0.2.131-rc2
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/CHANGELOG.md +7 -0
- package/index.js +11 -11
- package/models/TiledeskChatbotUtil.js +7 -4
- package/package.json +1 -1
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +29 -9
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +369 -0
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +10 -13
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +18 -57
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +4 -4
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +5 -8
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +5 -8
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +14 -18
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +4 -7
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +5 -8
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +2 -29
- package/tiledeskChatbotPlugs/directives/DirQapla.js +5 -8
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +2 -60
- package/tiledeskChatbotPlugs/directives/Directives.js +2 -0
|
@@ -19,6 +19,7 @@ class DirAskGPTV2 {
|
|
|
19
19
|
this.tdcache = this.context.tdcache;
|
|
20
20
|
this.requestId = this.context.requestId;
|
|
21
21
|
this.intentDir = new DirIntent(context);
|
|
22
|
+
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
22
23
|
this.log = context.log;
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -136,18 +137,13 @@ class DirAskGPTV2 {
|
|
|
136
137
|
if (this.log) { console.log("DirAskGPT transcript ", transcript) }
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
140
140
|
const kb_endpoint = process.env.KB_ENDPOINT_QA
|
|
141
|
-
|
|
142
|
-
if (this.log) {
|
|
143
|
-
console.log("DirAskGPT ApiEndpoint URL: ", server_base_url);
|
|
144
|
-
console.log("DirAskGPT KbEndpoint URL: ", kb_endpoint);
|
|
145
|
-
}
|
|
141
|
+
if (this.log) { console.log("DirAskGPT KbEndpoint URL: ", kb_endpoint); }
|
|
146
142
|
|
|
147
|
-
let key = await this.getKeyFromIntegrations(
|
|
143
|
+
let key = await this.getKeyFromIntegrations();
|
|
148
144
|
if (!key) {
|
|
149
145
|
if (this.log) { console.log("DirAskGPT - Key not found in Integrations. Searching in kb settings..."); }
|
|
150
|
-
key = await this.getKeyFromKbSettings(
|
|
146
|
+
key = await this.getKeyFromKbSettings();
|
|
151
147
|
}
|
|
152
148
|
|
|
153
149
|
if (!key) {
|
|
@@ -169,7 +165,7 @@ class DirAskGPTV2 {
|
|
|
169
165
|
}
|
|
170
166
|
|
|
171
167
|
if (publicKey === true) {
|
|
172
|
-
let keep_going = await this.checkQuoteAvailability(
|
|
168
|
+
let keep_going = await this.checkQuoteAvailability();
|
|
173
169
|
if (keep_going === false) {
|
|
174
170
|
if (this.log) { console.log("DirAskGPT - Quota exceeded for tokens. Skip the action")}
|
|
175
171
|
await this.chatbot.addParameter("flowError", "AskGPT Error: tokens quota exceeded");
|
|
@@ -183,12 +179,11 @@ class DirAskGPTV2 {
|
|
|
183
179
|
if (action.namespaceAsName) {
|
|
184
180
|
// Namespace could be an attribute
|
|
185
181
|
const filled_namespace = filler.fill(action.namespace, requestVariables)
|
|
186
|
-
|
|
187
|
-
ns = await this.getNamespace(server_base_url, filled_namespace, null);
|
|
182
|
+
ns = await this.getNamespace(filled_namespace, null);
|
|
188
183
|
namespace = ns.id;
|
|
189
184
|
if (this.log) { console.log("DirAskGPT - Retrieved namespace id from name ", namespace); }
|
|
190
185
|
} else {
|
|
191
|
-
ns = await this.getNamespace(
|
|
186
|
+
ns = await this.getNamespace(null, namespace);
|
|
192
187
|
}
|
|
193
188
|
|
|
194
189
|
if (ns.engine) {
|
|
@@ -242,7 +237,6 @@ class DirAskGPTV2 {
|
|
|
242
237
|
if (this.log) { console.log("DirAskGPT json:", json); }
|
|
243
238
|
|
|
244
239
|
const HTTPREQUEST = {
|
|
245
|
-
// url: server_base_url + "/" + this.context.projectId + "/kb/qa",
|
|
246
240
|
url: kb_endpoint + "/qa",
|
|
247
241
|
headers: {
|
|
248
242
|
'Content-Type': 'application/json',
|
|
@@ -284,7 +278,7 @@ class DirAskGPTV2 {
|
|
|
284
278
|
tokens: resbody.prompt_token_size,
|
|
285
279
|
model: json.model
|
|
286
280
|
}
|
|
287
|
-
this.updateQuote(
|
|
281
|
+
this.updateQuote(tokens_usage);
|
|
288
282
|
}
|
|
289
283
|
|
|
290
284
|
if (trueIntent) {
|
|
@@ -420,11 +414,11 @@ class DirAskGPTV2 {
|
|
|
420
414
|
});
|
|
421
415
|
}
|
|
422
416
|
|
|
423
|
-
async getKeyFromIntegrations(
|
|
417
|
+
async getKeyFromIntegrations() {
|
|
424
418
|
return new Promise((resolve) => {
|
|
425
419
|
|
|
426
420
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
427
|
-
url:
|
|
421
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/openai",
|
|
428
422
|
headers: {
|
|
429
423
|
'Content-Type': 'application/json',
|
|
430
424
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -452,11 +446,11 @@ class DirAskGPTV2 {
|
|
|
452
446
|
})
|
|
453
447
|
}
|
|
454
448
|
|
|
455
|
-
async getKeyFromKbSettings(
|
|
449
|
+
async getKeyFromKbSettings() {
|
|
456
450
|
return new Promise((resolve) => {
|
|
457
451
|
|
|
458
452
|
const KB_HTTPREQUEST = {
|
|
459
|
-
url:
|
|
453
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/kbsettings",
|
|
460
454
|
headers: {
|
|
461
455
|
'Content-Type': 'application/json',
|
|
462
456
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -482,11 +476,11 @@ class DirAskGPTV2 {
|
|
|
482
476
|
})
|
|
483
477
|
}
|
|
484
478
|
|
|
485
|
-
async checkQuoteAvailability(
|
|
479
|
+
async checkQuoteAvailability() {
|
|
486
480
|
return new Promise((resolve) => {
|
|
487
481
|
|
|
488
482
|
const HTTPREQUEST = {
|
|
489
|
-
url:
|
|
483
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/quotes/tokens",
|
|
490
484
|
headers: {
|
|
491
485
|
'Content-Type': 'application/json',
|
|
492
486
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -512,11 +506,11 @@ class DirAskGPTV2 {
|
|
|
512
506
|
})
|
|
513
507
|
}
|
|
514
508
|
|
|
515
|
-
async updateQuote(
|
|
509
|
+
async updateQuote(tokens_usage) {
|
|
516
510
|
return new Promise((resolve) => {
|
|
517
511
|
|
|
518
512
|
const HTTPREQUEST = {
|
|
519
|
-
url:
|
|
513
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/quotes/incr/tokens",
|
|
520
514
|
headers: {
|
|
521
515
|
'Content-Type': 'application/json',
|
|
522
516
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -588,10 +582,10 @@ class DirAskGPTV2 {
|
|
|
588
582
|
return objectTranscript;
|
|
589
583
|
}
|
|
590
584
|
|
|
591
|
-
async getNamespace(
|
|
585
|
+
async getNamespace(name, id) {
|
|
592
586
|
return new Promise((resolve) => {
|
|
593
587
|
const HTTPREQUEST = {
|
|
594
|
-
url:
|
|
588
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/kb/namespace/all",
|
|
595
589
|
headers: {
|
|
596
590
|
'Content-Type': 'application/json',
|
|
597
591
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -633,39 +627,6 @@ class DirAskGPTV2 {
|
|
|
633
627
|
})
|
|
634
628
|
}
|
|
635
629
|
|
|
636
|
-
// async getNamespaceIdFromName(server_base_url, name) {
|
|
637
|
-
// return new Promise((resolve) => {
|
|
638
|
-
|
|
639
|
-
// const HTTPREQUEST = {
|
|
640
|
-
// url: server_base_url + "/" + this.context.projectId + "/kb/namespace/all",
|
|
641
|
-
// headers: {
|
|
642
|
-
// 'Content-Type': 'application/json',
|
|
643
|
-
// 'Authorization': 'JWT ' + this.context.token
|
|
644
|
-
// },
|
|
645
|
-
// method: "GET"
|
|
646
|
-
// }
|
|
647
|
-
// if (this.log) { console.log("DirAskGPT get all namespaces HTTPREQUEST", HTTPREQUEST); }
|
|
648
|
-
|
|
649
|
-
// this.#myrequest(
|
|
650
|
-
// HTTPREQUEST, async (err, namespaces) => {
|
|
651
|
-
// if (err) {
|
|
652
|
-
// console.error("(httprequest) DirAskGPT get all namespaces err: ", err);
|
|
653
|
-
// resolve(null)
|
|
654
|
-
// } else {
|
|
655
|
-
// if (this.log) { console.log("(httprequest) DirAskGPT get all namespaces resbody: ", namespaces); }
|
|
656
|
-
|
|
657
|
-
// let namespace = namespaces.find(n => n.name === name);
|
|
658
|
-
// let namespace_id = namespace.id;
|
|
659
|
-
|
|
660
|
-
// resolve(namespace_id);
|
|
661
|
-
// }
|
|
662
|
-
// }
|
|
663
|
-
// )
|
|
664
|
-
// })
|
|
665
|
-
|
|
666
|
-
// }
|
|
667
|
-
|
|
668
|
-
|
|
669
630
|
}
|
|
670
631
|
|
|
671
632
|
module.exports = { DirAskGPTV2 }
|
|
@@ -14,6 +14,7 @@ class DirAssistant {
|
|
|
14
14
|
this.tdcache = context.tdcache;
|
|
15
15
|
this.requestId = context.requestId;
|
|
16
16
|
this.intentDir = new DirIntent(context);
|
|
17
|
+
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
17
18
|
this.log = context.log;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -264,8 +265,7 @@ class DirAssistant {
|
|
|
264
265
|
return process.env.TEST_OPENAI_APIKEY
|
|
265
266
|
}
|
|
266
267
|
else {
|
|
267
|
-
|
|
268
|
-
return await this.getKeyFromIntegrations(server_base_url);
|
|
268
|
+
return await this.getKeyFromIntegrations();
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
|
|
@@ -496,11 +496,11 @@ class DirAssistant {
|
|
|
496
496
|
});
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
async getKeyFromIntegrations(
|
|
499
|
+
async getKeyFromIntegrations() {
|
|
500
500
|
return new Promise((resolve) => {
|
|
501
501
|
|
|
502
502
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
503
|
-
url:
|
|
503
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/openai",
|
|
504
504
|
headers: {
|
|
505
505
|
'Content-Type': 'application/json',
|
|
506
506
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -16,6 +16,7 @@ class DirBrevo {
|
|
|
16
16
|
this.tdcache = this.context.tdcache;
|
|
17
17
|
this.requestId = this.context.requestId;
|
|
18
18
|
this.intentDir = new DirIntent(context);
|
|
19
|
+
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
19
20
|
this.log = context.log;
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -71,14 +72,10 @@ class DirBrevo {
|
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
75
75
|
const brevo_base_url = process.env.BREVO_ENDPOINT || "https://api.brevo.com/v3"
|
|
76
|
-
if (this.log) {
|
|
77
|
-
console.log("DirBrevo server_base_url ", server_base_url);
|
|
78
|
-
console.log("DirBrevo brevo_base_url ", brevo_base_url);
|
|
79
|
-
}
|
|
76
|
+
if (this.log) { console.log("DirBrevo brevo_base_url ", brevo_base_url); }
|
|
80
77
|
|
|
81
|
-
let key = await this.getKeyFromIntegrations(
|
|
78
|
+
let key = await this.getKeyFromIntegrations();
|
|
82
79
|
if (this.log) { console.log('DirBrevo key Debug1: ', key) }
|
|
83
80
|
// ONLY FOR DEBUG CANCELLARE!!!!!
|
|
84
81
|
// if (process.env.BREVO_DEBUG == '1') {
|
|
@@ -320,11 +317,11 @@ class DirBrevo {
|
|
|
320
317
|
}
|
|
321
318
|
}
|
|
322
319
|
|
|
323
|
-
async getKeyFromIntegrations(
|
|
320
|
+
async getKeyFromIntegrations() {
|
|
324
321
|
return new Promise((resolve) => {
|
|
325
322
|
|
|
326
323
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
327
|
-
url:
|
|
324
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/Brevo",
|
|
328
325
|
headers: {
|
|
329
326
|
'Content-Type': 'application/json',
|
|
330
327
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -16,6 +16,7 @@ class DirCustomerio {
|
|
|
16
16
|
this.tdcache = this.context.tdcache;
|
|
17
17
|
this.requestId = this.context.requestId;
|
|
18
18
|
this.intentDir = new DirIntent(context);
|
|
19
|
+
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
19
20
|
this.log = context.log;
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -69,14 +70,10 @@ class DirCustomerio {
|
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
73
73
|
const customerio_base_url = process.env.CUSTOMERIO_ENDPOINT || "https://track.customer.io/api/v1";
|
|
74
|
-
if (this.log) {
|
|
75
|
-
console.log("DirCustomerio server_base_url: ", server_base_url);
|
|
76
|
-
console.log("DirCustomerio customerio_base_url: ", customerio_base_url);
|
|
77
|
-
}
|
|
74
|
+
if (this.log) { console.log("DirCustomerio customerio_base_url: ", customerio_base_url); }
|
|
78
75
|
|
|
79
|
-
let key = await this.getKeyFromIntegrations(
|
|
76
|
+
let key = await this.getKeyFromIntegrations();
|
|
80
77
|
if (!key) {
|
|
81
78
|
if (this.log) { console.log("DirCustomerio - Key not found in Integrations."); }
|
|
82
79
|
let status = 422;
|
|
@@ -287,11 +284,11 @@ class DirCustomerio {
|
|
|
287
284
|
}
|
|
288
285
|
}
|
|
289
286
|
|
|
290
|
-
async getKeyFromIntegrations(
|
|
287
|
+
async getKeyFromIntegrations() {
|
|
291
288
|
return new Promise((resolve) => {
|
|
292
289
|
|
|
293
290
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
294
|
-
url:
|
|
291
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/customerio",
|
|
295
292
|
headers: {
|
|
296
293
|
'Content-Type': 'application/json',
|
|
297
294
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -18,6 +18,7 @@ class DirGptTask {
|
|
|
18
18
|
this.tdcache = this.context.tdcache;
|
|
19
19
|
this.requestId = this.context.requestId;
|
|
20
20
|
this.intentDir = new DirIntent(context);
|
|
21
|
+
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
21
22
|
this.log = context.log;
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -112,18 +113,13 @@ class DirGptTask {
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
117
116
|
const openai_url = process.env.OPENAI_ENDPOINT + "/chat/completions";
|
|
118
|
-
if (this.log) {
|
|
119
|
-
console.log("DirGptTask server_base_url ", server_base_url);
|
|
120
|
-
console.log("DirGptTask openai_url ", openai_url);
|
|
121
|
-
}
|
|
117
|
+
if (this.log) { console.log("DirGptTask openai_url ", openai_url); }
|
|
122
118
|
|
|
123
|
-
let key = await this.getKeyFromIntegrations(
|
|
119
|
+
let key = await this.getKeyFromIntegrations();
|
|
124
120
|
if (!key) {
|
|
125
121
|
if (this.log) { console.log("DirGptTask - Key not found in Integrations. Searching in kb settings..."); }
|
|
126
|
-
key = await this.getKeyFromKbSettings(
|
|
122
|
+
key = await this.getKeyFromKbSettings();
|
|
127
123
|
}
|
|
128
124
|
|
|
129
125
|
if (!key) {
|
|
@@ -146,7 +142,7 @@ class DirGptTask {
|
|
|
146
142
|
}
|
|
147
143
|
|
|
148
144
|
if (publicKey === true) {
|
|
149
|
-
let keep_going = await this.checkQuoteAvailability(
|
|
145
|
+
let keep_going = await this.checkQuoteAvailability();
|
|
150
146
|
if (keep_going === false) {
|
|
151
147
|
if (this.log) { console.log("DirGptTask - Quota exceeded for tokens. Skip the action")}
|
|
152
148
|
await this.chatbot.addParameter("flowError", "GPT Error: tokens quota exceeded");
|
|
@@ -230,7 +226,7 @@ class DirGptTask {
|
|
|
230
226
|
tokens: resbody.usage.total_tokens,
|
|
231
227
|
model: json.model
|
|
232
228
|
}
|
|
233
|
-
this.updateQuote(
|
|
229
|
+
this.updateQuote(tokens_usage);
|
|
234
230
|
}
|
|
235
231
|
|
|
236
232
|
if (trueIntent) {
|
|
@@ -368,11 +364,11 @@ class DirGptTask {
|
|
|
368
364
|
});
|
|
369
365
|
}
|
|
370
366
|
|
|
371
|
-
async getKeyFromIntegrations(
|
|
367
|
+
async getKeyFromIntegrations() {
|
|
372
368
|
return new Promise((resolve) => {
|
|
373
369
|
|
|
374
370
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
375
|
-
url:
|
|
371
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/openai",
|
|
376
372
|
headers: {
|
|
377
373
|
'Content-Type': 'application/json',
|
|
378
374
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -399,11 +395,11 @@ class DirGptTask {
|
|
|
399
395
|
})
|
|
400
396
|
}
|
|
401
397
|
|
|
402
|
-
async getKeyFromKbSettings(
|
|
398
|
+
async getKeyFromKbSettings() {
|
|
403
399
|
return new Promise((resolve) => {
|
|
404
400
|
|
|
405
401
|
const KB_HTTPREQUEST = {
|
|
406
|
-
url:
|
|
402
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/kbsettings",
|
|
407
403
|
headers: {
|
|
408
404
|
'Content-Type': 'application/json',
|
|
409
405
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -432,11 +428,11 @@ class DirGptTask {
|
|
|
432
428
|
})
|
|
433
429
|
}
|
|
434
430
|
|
|
435
|
-
async checkQuoteAvailability(
|
|
431
|
+
async checkQuoteAvailability() {
|
|
436
432
|
return new Promise((resolve) => {
|
|
437
433
|
|
|
438
434
|
const HTTPREQUEST = {
|
|
439
|
-
url:
|
|
435
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/quotes/tokens",
|
|
440
436
|
headers: {
|
|
441
437
|
'Content-Type': 'application/json',
|
|
442
438
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -461,11 +457,11 @@ class DirGptTask {
|
|
|
461
457
|
})
|
|
462
458
|
}
|
|
463
459
|
|
|
464
|
-
async updateQuote(
|
|
460
|
+
async updateQuote(tokens_usage) {
|
|
465
461
|
return new Promise((resolve) => {
|
|
466
462
|
|
|
467
463
|
const HTTPREQUEST = {
|
|
468
|
-
url:
|
|
464
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/quotes/incr/tokens",
|
|
469
465
|
headers: {
|
|
470
466
|
'Content-Type': 'application/json',
|
|
471
467
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -15,6 +15,7 @@ class DirGptTask {
|
|
|
15
15
|
this.tdcache = this.context.tdcache;
|
|
16
16
|
this.requestId = this.context.requestId;
|
|
17
17
|
this.intentDir = new DirIntent(context);
|
|
18
|
+
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
18
19
|
this.log = context.log;
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -85,15 +86,11 @@ class DirGptTask {
|
|
|
85
86
|
console.log("DirGptTask temperature: ", temperature);
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
89
89
|
const openai_url = process.env.OPENAI_ENDPOINT + "/chat/completions";
|
|
90
|
-
if (this.log) {
|
|
91
|
-
console.log("DirGptTask server_base_url ", server_base_url);
|
|
92
|
-
console.log("DirGptTask openai_url ", openai_url);
|
|
93
|
-
}
|
|
90
|
+
if (this.log) { console.log("DirGptTask openai_url ", openai_url); }
|
|
94
91
|
|
|
95
92
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
96
|
-
url:
|
|
93
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/openai",
|
|
97
94
|
headers: {
|
|
98
95
|
'Content-Type': 'application/json',
|
|
99
96
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -127,7 +124,7 @@ class DirGptTask {
|
|
|
127
124
|
if (this.log) { console.log("DirGptTask - Key not found in Integrations. Searching in kb settings..."); }
|
|
128
125
|
|
|
129
126
|
const KB_HTTPREQUEST = {
|
|
130
|
-
url:
|
|
127
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/kbsettings",
|
|
131
128
|
headers: {
|
|
132
129
|
'Content-Type': 'application/json',
|
|
133
130
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -16,6 +16,7 @@ class DirHubspot {
|
|
|
16
16
|
this.tdcache = this.context.tdcache;
|
|
17
17
|
this.requestId = this.context.requestId;
|
|
18
18
|
this.intentDir = new DirIntent(context);
|
|
19
|
+
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
19
20
|
this.log = context.log;
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -71,14 +72,10 @@ class DirHubspot {
|
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
75
75
|
const hubspot_base_url = process.env.HUBSPOT_ENDPOINT || "https://api.hubapi.com/crm/v3/";
|
|
76
|
-
if (this.log) {
|
|
77
|
-
console.log("DirHubspot server_base_url ", server_base_url);
|
|
78
|
-
console.log("DirHubspot hubspot_base_url ", hubspot_base_url);
|
|
79
|
-
}
|
|
76
|
+
if (this.log) { console.log("DirHubspot hubspot_base_url ", hubspot_base_url); }
|
|
80
77
|
|
|
81
|
-
let key = await this.getKeyFromIntegrations(
|
|
78
|
+
let key = await this.getKeyFromIntegrations();
|
|
82
79
|
if (!key) {
|
|
83
80
|
if (this.log) { console.log("DirHubspot - Key not found in Integrations."); }
|
|
84
81
|
if (falseIntent) {
|
|
@@ -289,11 +286,11 @@ class DirHubspot {
|
|
|
289
286
|
}
|
|
290
287
|
}
|
|
291
288
|
|
|
292
|
-
async getKeyFromIntegrations(
|
|
289
|
+
async getKeyFromIntegrations() {
|
|
293
290
|
return new Promise((resolve) => {
|
|
294
291
|
|
|
295
292
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
296
|
-
url:
|
|
293
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/hubspot",
|
|
297
294
|
headers: {
|
|
298
295
|
'Content-Type': 'application/json',
|
|
299
296
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -12,32 +12,8 @@ class DirIfOpenHours {
|
|
|
12
12
|
}
|
|
13
13
|
this.tdclient = context.tdclient;
|
|
14
14
|
this.context = context;
|
|
15
|
-
|
|
16
|
-
// projectId: context.projectId,
|
|
17
|
-
// token: context.token,
|
|
18
|
-
// APIURL: context.TILEDESK_APIURL,
|
|
19
|
-
// APIKEY: "___",
|
|
20
|
-
// log: context.log
|
|
21
|
-
// });
|
|
22
|
-
// let context = {
|
|
23
|
-
// projectId: projectId,
|
|
24
|
-
// token: token,
|
|
25
|
-
// requestId: supportRequest,
|
|
26
|
-
// APIURL: API_URL,
|
|
27
|
-
// TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
|
|
28
|
-
// departmentId: depId,
|
|
29
|
-
// log: false
|
|
30
|
-
// }
|
|
15
|
+
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
31
16
|
this.intentDir = new DirIntent(context);
|
|
32
|
-
// {
|
|
33
|
-
// API_ENDPOINT: context.TILEDESK_APIURL,
|
|
34
|
-
// TILEBOT_ENDPOINT: context.TILEBOT_ENDPOINT,
|
|
35
|
-
// supportRequest: context.supportRequest,
|
|
36
|
-
// token: context.token,
|
|
37
|
-
// log: context.log
|
|
38
|
-
// }
|
|
39
|
-
// );
|
|
40
|
-
//this.log = context.log;
|
|
41
17
|
}
|
|
42
18
|
|
|
43
19
|
execute(directive, callback) {
|
|
@@ -95,10 +71,7 @@ class DirIfOpenHours {
|
|
|
95
71
|
slot_id = action.slotId;
|
|
96
72
|
}
|
|
97
73
|
|
|
98
|
-
|
|
99
|
-
if (this.log) { console.log("DirAskGPT ApiEndpoint URL: ", server_base_url); }
|
|
100
|
-
|
|
101
|
-
let isopen_url = server_base_url + "/projects/" + this.context.projectId + "/isopen";
|
|
74
|
+
let isopen_url = this.API_ENDPOINT + "/projects/" + this.context.projectId + "/isopen";
|
|
102
75
|
if (slot_id) {
|
|
103
76
|
isopen_url = isopen_url.concat("?timeSlot=" + slot_id);
|
|
104
77
|
}
|
|
@@ -15,6 +15,7 @@ class DirQapla {
|
|
|
15
15
|
this.tdcache = this.context.tdcache;
|
|
16
16
|
this.requestId = this.context.requestId;
|
|
17
17
|
this.intentDir = new DirIntent(context);
|
|
18
|
+
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
18
19
|
this.log = context.log;
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -82,18 +83,14 @@ class DirQapla {
|
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
|
|
86
86
|
const qapla_base_url = process.env.QAPLA_ENDPOINT || "https://api.qapla.it/1.2"
|
|
87
|
-
if (this.log) {
|
|
88
|
-
console.log("DirQapla server_base_url: ", qapla_base_url);
|
|
89
|
-
console.log("DirQapla qapla_base_url: ", qapla_base_url);
|
|
90
|
-
}
|
|
87
|
+
if (this.log) { console.log("DirQapla qapla_base_url: ", qapla_base_url); }
|
|
91
88
|
|
|
92
89
|
let key = action.apiKey;
|
|
93
90
|
|
|
94
91
|
if (!key) {
|
|
95
92
|
if (this.log) { console.log("DirQapla - Key not found into action. Searching in integrations..."); }
|
|
96
|
-
key = await this.getKeyFromIntegrations(
|
|
93
|
+
key = await this.getKeyFromIntegrations();
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
if (!key) {
|
|
@@ -288,11 +285,11 @@ class DirQapla {
|
|
|
288
285
|
});
|
|
289
286
|
}
|
|
290
287
|
|
|
291
|
-
async getKeyFromIntegrations(
|
|
288
|
+
async getKeyFromIntegrations() {
|
|
292
289
|
return new Promise((resolve) => {
|
|
293
290
|
|
|
294
291
|
const INTEGRATIONS_HTTPREQUEST = {
|
|
295
|
-
url:
|
|
292
|
+
url: this.API_ENDPOINT + "/" + this.context.projectId + "/integration/name/qapla",
|
|
296
293
|
headers: {
|
|
297
294
|
'Content-Type': 'application/json',
|
|
298
295
|
'Authorization': 'JWT ' + this.context.token
|
|
@@ -16,6 +16,7 @@ class DirSendWhatsapp {
|
|
|
16
16
|
this.tdcache = this.context.tdcache;
|
|
17
17
|
this.requestId = this.context.requestId;
|
|
18
18
|
this.intentDir = new DirIntent(context);
|
|
19
|
+
this.API_ENDPOINT = this.context.API_ENDPOINT;
|
|
19
20
|
this.log = context.log;
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -73,12 +74,11 @@ class DirSendWhatsapp {
|
|
|
73
74
|
payload.broadcast = false;
|
|
74
75
|
|
|
75
76
|
const whatsapp_api_url_pre = process.env.WHATSAPP_ENDPOINT;
|
|
76
|
-
const server_base_url = process.env.API_URL || process.env.API_ENDPOINT;
|
|
77
77
|
|
|
78
78
|
if (whatsapp_api_url_pre) {
|
|
79
79
|
whatsapp_api_url = whatsapp_api_url_pre;
|
|
80
80
|
} else {
|
|
81
|
-
whatsapp_api_url =
|
|
81
|
+
whatsapp_api_url = this.API_ENDPOINT + "/modules/whatsapp/api"
|
|
82
82
|
}
|
|
83
83
|
if (this.log) { console.log("DirSendWhatsapp whatsapp_api_url: ", whatsapp_api_url); };
|
|
84
84
|
|
|
@@ -10,6 +10,7 @@ class DirWhatsappByAttribute {
|
|
|
10
10
|
throw new Error('context object is mandatory');
|
|
11
11
|
}
|
|
12
12
|
this.context = context;
|
|
13
|
+
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
13
14
|
this.log = context.log;
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -35,15 +36,12 @@ class DirWhatsappByAttribute {
|
|
|
35
36
|
console.log("whatsapp by attributes action: ", JSON.stringify(action))
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
///////////
|
|
39
|
-
|
|
40
39
|
const whatsapp_api_url_pre = process.env.WHATSAPP_ENDPOINT;
|
|
41
|
-
const server_base_url = process.env.API_URL || process.env.API_ENDPOINT;
|
|
42
40
|
|
|
43
41
|
if (whatsapp_api_url_pre) {
|
|
44
42
|
whatsapp_api_url = whatsapp_api_url_pre;
|
|
45
43
|
} else {
|
|
46
|
-
whatsapp_api_url =
|
|
44
|
+
whatsapp_api_url = this.API_ENDPOINT + "/modules/whatsapp/api"
|
|
47
45
|
}
|
|
48
46
|
console.log("DirWhatsappByAttribute whatsapp_api_url: ", whatsapp_api_url);
|
|
49
47
|
|
|
@@ -94,62 +92,6 @@ class DirWhatsappByAttribute {
|
|
|
94
92
|
}, true);
|
|
95
93
|
})
|
|
96
94
|
|
|
97
|
-
|
|
98
|
-
// if (process.env.API_URL) {
|
|
99
|
-
// whatsapp_api_url = "https://tiledesk-whatsapp-connector.giovannitroisi3.repl.co/api";
|
|
100
|
-
// // whatsapp_api_url = process.env.API_URL + "/modules/whatsapp";
|
|
101
|
-
// console.log("(Tilebot) DirWhatsappByAttribute whatsapp_api_url: ", whatsapp_api_url);
|
|
102
|
-
// } else {
|
|
103
|
-
// console.error("(Tilebot) ERROR Missing whatsapp_api_url. Unable to use action WhatsApp By Attributes");
|
|
104
|
-
// callback();
|
|
105
|
-
// return;
|
|
106
|
-
// }
|
|
107
|
-
// if (action.attributeName) {
|
|
108
|
-
// if (this.log) { console.log("whatsapp attributeName:", action.attributeName); }
|
|
109
|
-
// let attribute_value = null;
|
|
110
|
-
// if (this.context.tdcache) {
|
|
111
|
-
|
|
112
|
-
// const attribute_value = await TiledeskChatbot.getParameterStatic(this.context.tdcache, this.context.requestId, action.attributeName)
|
|
113
|
-
// if (this.log) { console.log("attribute_value:", JSON.stringify(attribute_value)); }
|
|
114
|
-
|
|
115
|
-
// if (attribute_value == null) {
|
|
116
|
-
// console.error("(Tilebot) attribute_value is undefined");
|
|
117
|
-
// callback();
|
|
118
|
-
// return;
|
|
119
|
-
// }
|
|
120
|
-
|
|
121
|
-
// const URL = whatsapp_api_url + '/tiledesk/broadcast';
|
|
122
|
-
// const HTTPREQUEST = {
|
|
123
|
-
// url: URL,
|
|
124
|
-
// headers: {
|
|
125
|
-
// 'Content-Type': 'application/json',
|
|
126
|
-
|
|
127
|
-
// },
|
|
128
|
-
// json: attribute_value,
|
|
129
|
-
// method: 'POST'
|
|
130
|
-
// };
|
|
131
|
-
// let promise = new Promise((resolve, reject) => {
|
|
132
|
-
// DirWhatsappByAttribute.myrequest(
|
|
133
|
-
// HTTPREQUEST,
|
|
134
|
-
// function (err, resbody) {
|
|
135
|
-
// if (err) {
|
|
136
|
-
// if (callback) {
|
|
137
|
-
// callback(err);
|
|
138
|
-
// }
|
|
139
|
-
// reject(err);
|
|
140
|
-
// }
|
|
141
|
-
// else {
|
|
142
|
-
// if (callback) {
|
|
143
|
-
// callback(null, resbody);
|
|
144
|
-
// }
|
|
145
|
-
// console.log("(tybot) broadcast sent: ", resbody);
|
|
146
|
-
// resolve(resbody);
|
|
147
|
-
// }
|
|
148
|
-
// }, true);
|
|
149
|
-
// })
|
|
150
|
-
// return promise;
|
|
151
|
-
// }
|
|
152
|
-
// }
|
|
153
95
|
}
|
|
154
96
|
|
|
155
97
|
// HTTP REQUEST
|