@tiledesk/tiledesk-tybot-connector 0.2.136 → 0.2.137-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 +6 -0
- package/models/TiledeskChatbotUtil.js +17 -15
- package/package.json +1 -1
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMessage.js +12 -5
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,12 @@ available on:
|
|
|
17
17
|
- Added flowError on JSONCondition when result = null
|
|
18
18
|
- Added fix on Filler -->
|
|
19
19
|
|
|
20
|
+
# v0.2.137-rc2
|
|
21
|
+
- Added debug logs
|
|
22
|
+
|
|
23
|
+
# v0.2.137-rc1
|
|
24
|
+
- Updated: hidden message is enabled only in dev mode for dratf requests
|
|
25
|
+
|
|
20
26
|
# v0.2.136
|
|
21
27
|
- TdCache rollback
|
|
22
28
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { TiledeskExpression } = require('../TiledeskExpression');
|
|
2
2
|
const { Filler } = require('../tiledeskChatbotPlugs/Filler');
|
|
3
3
|
const { TiledeskChatbotConst } = require('./TiledeskChatbotConst');
|
|
4
|
+
const { TiledeskChatbot } = require('./TiledeskChatbot.js');
|
|
4
5
|
let parser = require('accept-language-parser');
|
|
5
6
|
const { Directives } = require('../tiledeskChatbotPlugs/directives/Directives.js');
|
|
6
7
|
require('dotenv').config();
|
|
@@ -516,13 +517,10 @@ class TiledeskChatbotUtil {
|
|
|
516
517
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN, chatbotToken); // DEPRECATED
|
|
517
518
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN_v2, "JWT " + chatbotToken);
|
|
518
519
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
// await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN, chatbotToken); // DEPRECATED
|
|
524
|
-
// await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN_v2, "JWT " + chatbotToken);
|
|
525
|
-
// }
|
|
520
|
+
if (process.env.TILEDESK_API) {
|
|
521
|
+
await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN, chatbotToken); // DEPRECATED
|
|
522
|
+
await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN_v2, "JWT " + chatbotToken);
|
|
523
|
+
}
|
|
526
524
|
|
|
527
525
|
if (process.env.API_URL) {
|
|
528
526
|
await chatbot.addParameter(TiledeskChatbotConst.API_BASE_URL, process.env.API_URL);
|
|
@@ -701,14 +699,7 @@ class TiledeskChatbotUtil {
|
|
|
701
699
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_ID_KEY, message.attributes.departmentId);
|
|
702
700
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_NAME_KEY, message.attributes.departmentName);
|
|
703
701
|
}
|
|
704
|
-
|
|
705
|
-
if (!message.attributes) {
|
|
706
|
-
message.attributes = {}
|
|
707
|
-
}
|
|
708
|
-
message.attributes.payload = message.request.attributes.payload
|
|
709
|
-
if (chatbot.log) {console.log("FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
|
|
710
|
-
// if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
|
|
711
|
-
}
|
|
702
|
+
|
|
712
703
|
if (message.attributes) {
|
|
713
704
|
if (chatbot.log) {console.log("Ok message.attributes", JSON.stringify(message.attributes));}
|
|
714
705
|
// if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > Ok message.attributes", JSON.stringify(message.attributes));}
|
|
@@ -743,6 +734,17 @@ class TiledeskChatbotUtil {
|
|
|
743
734
|
await chatbot.addParameter("ani", message.attributes.ani);
|
|
744
735
|
}
|
|
745
736
|
}
|
|
737
|
+
|
|
738
|
+
/** DEPRECATED */
|
|
739
|
+
if (message && message.request && message.request.attributes && message.request.attributes.payload) {
|
|
740
|
+
if (!message.attributes) {
|
|
741
|
+
message.attributes = {}
|
|
742
|
+
}
|
|
743
|
+
message.attributes.payload = message.request.attributes.payload
|
|
744
|
+
if (chatbot.log) {console.log("FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
|
|
745
|
+
// if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
|
|
746
|
+
}
|
|
747
|
+
|
|
746
748
|
|
|
747
749
|
const _bot = chatbot.bot; // aka FaqKB
|
|
748
750
|
if (chatbot.log) {
|
package/package.json
CHANGED
|
@@ -6,7 +6,6 @@ const { DirIntent } = require("./DirIntent");
|
|
|
6
6
|
const { TiledeskChatbotConst } = require("../../models/TiledeskChatbotConst");
|
|
7
7
|
const { TiledeskChatbotUtil } = require("../../models/TiledeskChatbotUtil");
|
|
8
8
|
const req = require("express/lib/request");
|
|
9
|
-
const { rejects } = require("assert");
|
|
10
9
|
const { update } = require("../../models/faq");
|
|
11
10
|
const { TiledeskClient } = require("@tiledesk/tiledesk-client");
|
|
12
11
|
require('dotenv').config();
|
|
@@ -274,7 +273,7 @@ class DirAddTags {
|
|
|
274
273
|
}
|
|
275
274
|
|
|
276
275
|
async addNewTag(tag){
|
|
277
|
-
return new Promise((resolve,
|
|
276
|
+
return new Promise((resolve, reject)=> {
|
|
278
277
|
const HTTPREQUEST = {
|
|
279
278
|
url: this.API_ENDPOINT + "/" + this.context.projectId + "/tags",
|
|
280
279
|
headers: {
|
|
@@ -507,7 +507,7 @@ class DirAskGPTV2 {
|
|
|
507
507
|
}
|
|
508
508
|
|
|
509
509
|
async updateQuote(tokens_usage) {
|
|
510
|
-
return new Promise((resolve) => {
|
|
510
|
+
return new Promise((resolve, reject) => {
|
|
511
511
|
|
|
512
512
|
const HTTPREQUEST = {
|
|
513
513
|
url: this.API_ENDPOINT + "/" + this.context.projectId + "/quotes/incr/tokens",
|
|
@@ -524,7 +524,7 @@ class DirAskGPTV2 {
|
|
|
524
524
|
HTTPREQUEST, async (err, resbody) => {
|
|
525
525
|
if (err) {
|
|
526
526
|
console.error("(httprequest) DirAskGPT Increment tokens quote err: ", err);
|
|
527
|
-
|
|
527
|
+
reject(false)
|
|
528
528
|
} else {
|
|
529
529
|
// console.log("(httprequest) DirAskGPT Increment token quote resbody: ", resbody);
|
|
530
530
|
resolve(true);
|
|
@@ -458,7 +458,7 @@ class DirGptTask {
|
|
|
458
458
|
}
|
|
459
459
|
|
|
460
460
|
async updateQuote(tokens_usage) {
|
|
461
|
-
return new Promise((resolve) => {
|
|
461
|
+
return new Promise((resolve, reject) => {
|
|
462
462
|
|
|
463
463
|
const HTTPREQUEST = {
|
|
464
464
|
url: this.API_ENDPOINT + "/" + this.context.projectId + "/quotes/incr/tokens",
|
|
@@ -475,7 +475,7 @@ class DirGptTask {
|
|
|
475
475
|
HTTPREQUEST, async (err, resbody) => {
|
|
476
476
|
if (err) {
|
|
477
477
|
console.error("(httprequest) DirGptTask Increment tokens quote err: ", err);
|
|
478
|
-
|
|
478
|
+
reject(false)
|
|
479
479
|
} else {
|
|
480
480
|
if (this.log) { console.log("(httprequest) DirGptTask Increment token quote resbody: ", resbody); }
|
|
481
481
|
resolve(true);
|
|
@@ -25,6 +25,7 @@ class DirMessage {
|
|
|
25
25
|
this.requestId = context.requestId;
|
|
26
26
|
this.token = context.token;
|
|
27
27
|
this.log = this.context.log;
|
|
28
|
+
this.supportRequest = this.context.supportRequest
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
execute(directive, callback) {
|
|
@@ -94,12 +95,18 @@ class DirMessage {
|
|
|
94
95
|
const message = action;
|
|
95
96
|
if (this.log) {console.log("Message to extEndpoint:", JSON.stringify(message))};
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
console.log("(DirMessage) supportRequest:", JSON.stringify(this.supportRequest))
|
|
99
|
+
if(this.supportRequest && !this.supportRequest.draft){
|
|
100
|
+
console.log("(DirMessage) draft request:", message.text)
|
|
101
|
+
callback();
|
|
102
|
+
return;
|
|
102
103
|
}
|
|
104
|
+
// if (this.projectId === "656054000410fa00132e5dcc") {
|
|
105
|
+
// if (!message.text.startsWith('/')) {
|
|
106
|
+
// callback();
|
|
107
|
+
// return;
|
|
108
|
+
// }
|
|
109
|
+
// }
|
|
103
110
|
|
|
104
111
|
let extEndpoint = `${this.API_ENDPOINT}/modules/tilebot`;
|
|
105
112
|
if (this.TILEBOT_ENDPOINT) {
|