@tiledesk/tiledesk-tybot-connector 0.2.131-rc1 → 0.2.131-rc3

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/index.js +11 -11
  3. package/models/TiledeskChatbotUtil.js +7 -4
  4. package/package.json +1 -1
  5. package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +6 -8
  6. package/tiledeskChatbotPlugs/directives/DirAddTags.js +11 -17
  7. package/tiledeskChatbotPlugs/directives/DirAskGPT.js +10 -13
  8. package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +18 -57
  9. package/tiledeskChatbotPlugs/directives/DirAssign.js +0 -11
  10. package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +0 -18
  11. package/tiledeskChatbotPlugs/directives/DirAssistant.js +4 -4
  12. package/tiledeskChatbotPlugs/directives/DirBrevo.js +5 -8
  13. package/tiledeskChatbotPlugs/directives/DirCondition.js +0 -26
  14. package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +1 -13
  15. package/tiledeskChatbotPlugs/directives/DirCustomerio.js +5 -8
  16. package/tiledeskChatbotPlugs/directives/DirGptTask.js +14 -18
  17. package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +4 -7
  18. package/tiledeskChatbotPlugs/directives/DirHubspot.js +5 -8
  19. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +0 -24
  20. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +2 -1
  21. package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +2 -29
  22. package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +0 -24
  23. package/tiledeskChatbotPlugs/directives/DirIntent.js +1 -23
  24. package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +0 -26
  25. package/tiledeskChatbotPlugs/directives/DirMessage.js +1 -1
  26. package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +1 -13
  27. package/tiledeskChatbotPlugs/directives/DirQapla.js +5 -8
  28. package/tiledeskChatbotPlugs/directives/DirSendEmail.js +1 -20
  29. package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +2 -2
  30. package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +2 -60
@@ -10,33 +10,7 @@ class DirCondition {
10
10
  throw new Error('context object is mandatory.');
11
11
  }
12
12
  this.context = context;
13
- // let context = {
14
- // projectId: projectId,
15
- // token: token,
16
- // supportRequest: supportRequest,
17
- // requestId: supportRequest.request_id,
18
- // TILEDESK_APIURL: API_URL,
19
- // TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
20
- // departmentId: depId,
21
- // tdcache: tdcache,
22
- // log: false
23
- // }
24
- // this.tdclient = new TiledeskClient({
25
- // projectId: context.projectId,
26
- // token: context.token,
27
- // APIURL: context.TILEDESK_APIURL,
28
- // APIKEY: "___",
29
- // log: context.log
30
- // });
31
13
  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
14
  this.log = context.log;
41
15
  }
42
16
 
@@ -10,23 +10,11 @@ class DirConnectBlock {
10
10
  throw new Error('context object is mandatory.');
11
11
  }
12
12
  this.context = context;
13
- this.API_ENDPOINT = context.TILEDESK_APIURL,
13
+ this.API_ENDPOINT = context.API_ENDPOINT,
14
14
  this.TILEBOT_ENDPOINT = context.TILEBOT_ENDPOINT;
15
15
  this.supportRequest = context.supportRequest;
16
16
  this.token = context.token;
17
17
  this.log = context.log;
18
- // let context = {
19
- // projectId: projectId,
20
- // token: token,
21
- // supportRequest: supportRequest,
22
- // requestId: supportRequest.request_id,
23
- // TILEDESK_APIURL: API_URL,
24
- // TILEBOT_ENDPOINT: TILEBOT_ENDPOINT,
25
- // departmentId: depId,
26
- // tdcache: tdcache,
27
- // tdclient: tdclient,
28
- // log: true
29
- // }
30
18
  }
31
19
 
32
20
  execute(directive, callback) {
@@ -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(server_base_url);
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(server_base_url) {
287
+ async getKeyFromIntegrations() {
291
288
  return new Promise((resolve) => {
292
289
 
293
290
  const INTEGRATIONS_HTTPREQUEST = {
294
- url: server_base_url + "/" + this.context.projectId + "/integration/name/customerio",
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(server_base_url);
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(server_base_url);
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(server_base_url);
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(server_base_url, tokens_usage);
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(server_base_url) {
367
+ async getKeyFromIntegrations() {
372
368
  return new Promise((resolve) => {
373
369
 
374
370
  const INTEGRATIONS_HTTPREQUEST = {
375
- url: server_base_url + "/" + this.context.projectId + "/integration/name/openai",
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(server_base_url) {
398
+ async getKeyFromKbSettings() {
403
399
  return new Promise((resolve) => {
404
400
 
405
401
  const KB_HTTPREQUEST = {
406
- url: server_base_url + "/" + this.context.projectId + "/kbsettings",
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(server_base_url) {
431
+ async checkQuoteAvailability() {
436
432
  return new Promise((resolve) => {
437
433
 
438
434
  const HTTPREQUEST = {
439
- url: server_base_url + "/" + this.context.projectId + "/quotes/tokens",
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(server_base_url, tokens_usage) {
460
+ async updateQuote(tokens_usage) {
465
461
  return new Promise((resolve) => {
466
462
 
467
463
  const HTTPREQUEST = {
468
- url: server_base_url + "/" + this.context.projectId + "/quotes/incr/tokens",
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: server_base_url + "/" + this.context.projectId + "/integration/name/openai",
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: server_base_url + "/" + this.context.projectId + "/kbsettings",
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(server_base_url);
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(server_base_url) {
289
+ async getKeyFromIntegrations() {
293
290
  return new Promise((resolve) => {
294
291
 
295
292
  const INTEGRATIONS_HTTPREQUEST = {
296
- url: server_base_url + "/" + this.context.projectId + "/integration/name/hubspot",
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
@@ -9,31 +9,7 @@ class DirIfOnlineAgents {
9
9
  throw new Error('context object is mandatory.');
10
10
  }
11
11
  this.tdclient = context.tdclient;
12
- // this.tdclient = new TiledeskClient({
13
- // projectId: context.projectId,
14
- // token: context.token,
15
- // APIURL: context.TILEDESK_APIURL,
16
- // APIKEY: "___",
17
- // log: context.log
18
- // });
19
- // let context = {
20
- // projectId: projectId,
21
- // token: token,
22
- // requestId: supportRequest,
23
- // APIURL: API_URL,
24
- // TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
25
- // departmentId: depId,
26
- // log: false
27
- // }
28
12
  this.intentDir = new DirIntent(context);
29
- // {
30
- // API_ENDPOINT: context.TILEDESK_APIURL,
31
- // TILEBOT_ENDPOINT: context.TILEBOT_ENDPOINT,
32
- // supportRequest: context.supportRequest,
33
- // token: context.token,
34
- // log: context.log
35
- // }
36
- // );
37
13
  this.log = context.log;
38
14
  }
39
15
 
@@ -15,6 +15,7 @@ class DirIfOnlineAgentsV2 {
15
15
  this.chatbot = context.chatbot;
16
16
  this.tdclient = context.tdclient;
17
17
  this.intentDir = new DirIntent(context);
18
+ this.API_ENDPOINT = context.API_ENDPOINT;
18
19
  this.log = context.log;
19
20
  }
20
21
 
@@ -175,7 +176,7 @@ class DirIfOnlineAgentsV2 {
175
176
 
176
177
  async getProjectAvailableAgents(departmentId, raw, callback) {
177
178
  return new Promise( (resolve, reject) => {
178
- let URL = `${this.context.TILEDESK_APIURL}/projects/${this.context.projectId}/users/availables?raw=${raw}`
179
+ let URL = `${this.API_ENDPOINT}/projects/${this.context.projectId}/users/availables?raw=${raw}`
179
180
  if (departmentId) {
180
181
  URL = URL + `&department=${departmentId}`
181
182
  }
@@ -12,32 +12,8 @@ class DirIfOpenHours {
12
12
  }
13
13
  this.tdclient = context.tdclient;
14
14
  this.context = context;
15
- // this.tdclient = new TiledeskClient({
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
- const server_base_url = process.env.API_ENDPOINT || process.env.API_URL;
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
  }
@@ -9,31 +9,7 @@ class DirIfOpenHours {
9
9
  throw new Error('context object is mandatory.');
10
10
  }
11
11
  this.tdclient = context.tdclient;
12
- // this.tdclient = new TiledeskClient({
13
- // projectId: context.projectId,
14
- // token: context.token,
15
- // APIURL: context.TILEDESK_APIURL,
16
- // APIKEY: "___",
17
- // log: context.log
18
- // });
19
- // let context = {
20
- // projectId: projectId,
21
- // token: token,
22
- // requestId: supportRequest,
23
- // APIURL: API_URL,
24
- // TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
25
- // departmentId: depId,
26
- // log: false
27
- // }
28
12
  this.intentDir = new DirIntent(context);
29
- // {
30
- // API_ENDPOINT: context.TILEDESK_APIURL,
31
- // TILEBOT_ENDPOINT: context.TILEBOT_ENDPOINT,
32
- // supportRequest: context.supportRequest,
33
- // token: context.token,
34
- // log: context.log
35
- // }
36
- // );
37
13
  this.log = context.log;
38
14
  }
39
15
 
@@ -6,38 +6,16 @@ const ms = require('minimist-string');
6
6
 
7
7
  class DirIntent {
8
8
 
9
- // constructor(settings) {
10
- // if (!settings.API_ENDPOINT) {
11
- // throw new Error("settings.API_ENDPOINT is mandatory!");
12
- // }
13
- // this.API_ENDPOINT = settings.API_ENDPOINT;
14
- // this.TILEBOT_ENDPOINT = settings.TILEBOT_ENDPOINT;
15
- // this.log = settings.log;
16
- // this.supportRequest = settings.supportRequest;
17
- // this.token = settings.token;
18
- // }
19
9
  constructor(context) {
20
10
  if (!context) {
21
11
  throw new Error('context object is mandatory.');
22
12
  }
23
13
  this.context = context;
24
- this.API_ENDPOINT = context.TILEDESK_APIURL,
14
+ this.API_ENDPOINT = context.API_ENDPOINT,
25
15
  this.TILEBOT_ENDPOINT = context.TILEBOT_ENDPOINT;
26
16
  this.supportRequest = context.supportRequest;
27
17
  this.token = context.token;
28
18
  this.log = context.log;
29
- // let context = {
30
- // projectId: projectId,
31
- // token: token,
32
- // supportRequest: supportRequest,
33
- // requestId: supportRequest.request_id,
34
- // TILEDESK_APIURL: API_URL,
35
- // TILEBOT_ENDPOINT: TILEBOT_ENDPOINT,
36
- // departmentId: depId,
37
- // tdcache: tdcache,
38
- // tdclient: tdclient,
39
- // log: true
40
- // }
41
19
  }
42
20
 
43
21
  execute(directive, callback) {
@@ -10,34 +10,8 @@ class DirJSONCondition {
10
10
  }
11
11
  this.context = context;
12
12
  this.chatbot = context.chatbot;
13
- // let context = {
14
- // projectId: projectId,
15
- // token: token,
16
- // supportRequest: supportRequest,
17
- // requestId: supportRequest.request_id,
18
- // TILEDESK_APIURL: API_URL,
19
- // TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
20
- // departmentId: depId,
21
- // tdcache: tdcache,
22
- // log: false
23
- // }
24
- // this.tdclient = new TiledeskClient({
25
- // projectId: context.projectId,
26
- // token: context.token,
27
- // APIURL: context.TILEDESK_APIURL,
28
- // APIKEY: "___",
29
- // log: context.log
30
- // });
31
13
  this.chatbot = context.chatbot;
32
14
  this.intentDir = new DirIntent(context);
33
- // {
34
- // API_ENDPOINT: context.TILEDESK_APIURL,
35
- // TILEBOT_ENDPOINT: context.TILEBOT_ENDPOINT,
36
- // supportRequest: context.supportRequest,
37
- // token: context.token,
38
- // log: context.log
39
- // }
40
- // );
41
15
  this.log = context.log;
42
16
  }
43
17
 
@@ -19,7 +19,7 @@ class DirMessage {
19
19
  throw new Error('context object is mandatory.');
20
20
  }
21
21
  this.context = context;
22
- this.API_ENDPOINT = context.TILEDESK_APIURL,
22
+ this.API_ENDPOINT = context.API_ENDPOINT,
23
23
  this.TILEBOT_ENDPOINT = context.TILEBOT_ENDPOINT;
24
24
  this.projectId = context.projectId;
25
25
  this.requestId = context.requestId;
@@ -9,23 +9,11 @@ class DirMessageToBot {
9
9
  throw new Error('context object is mandatory.');
10
10
  }
11
11
  this.context = context;
12
- this.API_ENDPOINT = context.TILEDESK_APIURL,
12
+ this.API_ENDPOINT = context.API_ENDPOINT,
13
13
  this.TILEBOT_ENDPOINT = context.TILEBOT_ENDPOINT;
14
14
  this.supportRequest = context.supportRequest;
15
15
  this.token = context.token;
16
16
  this.log = context.log;
17
- // let context = {
18
- // projectId: projectId,
19
- // token: token,
20
- // supportRequest: supportRequest,
21
- // requestId: supportRequest.request_id,
22
- // TILEDESK_APIURL: API_URL,
23
- // TILEBOT_ENDPOINT: TILEBOT_ENDPOINT,
24
- // departmentId: depId,
25
- // tdcache: tdcache,
26
- // tdclient: tdclient,
27
- // log: true
28
- // }
29
17
  }
30
18
 
31
19
  execute(directive, callback) {
@@ -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(server_base_url);
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(server_base_url) {
288
+ async getKeyFromIntegrations() {
292
289
  return new Promise((resolve) => {
293
290
 
294
291
  const INTEGRATIONS_HTTPREQUEST = {
295
- url: server_base_url + "/" + this.context.projectId + "/integration/name/qapla",
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
@@ -14,26 +14,7 @@ class DirSendEmail {
14
14
  this.tdclient = context.tdclient;
15
15
  this.tdcache = context.tdcache;
16
16
  this.requestId = context.requestId;
17
- this.log = context.log;
18
- // let context = {
19
- // projectId: projectId,
20
- // token: token,
21
- // supportRequest: supportRequest,
22
- // requestId: supportRequest.request_id,
23
- // TILEDESK_APIURL: API_URL,
24
- // TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
25
- // departmentId: depId,
26
- // tdcache: tdcache,
27
- // log: false
28
- // }
29
- // this.tdclient = new TiledeskClient({
30
- // projectId: context.projectId,
31
- // token: context.token,
32
- // APIURL: context.TILEDESK_APIURL,
33
- // APIKEY: "___",
34
- // log: context.log
35
- // });
36
-
17
+ this.log = context.log;
37
18
  }
38
19
 
39
20
  execute(directive, callback) {
@@ -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 = server_base_url + "/modules/whatsapp/api"
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