@tiledesk/tiledesk-tybot-connector 0.5.0 → 2.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/ExtApi.js +4 -83
- package/ExtUtil.js +0 -1
- package/Logger.js +105 -0
- package/TdCache.js +5 -3
- package/TiledeskClientTest.js +5 -28
- package/TiledeskExpression.js +6 -47
- package/{models → engine}/IntentForm.js +30 -44
- package/{models → engine}/IntentsMachineFactory.js +5 -4
- package/{models → engine}/MongodbBotsDataSource.js +31 -55
- package/{models → engine}/MongodbIntentsMachine.js +6 -5
- package/{models → engine}/TiledeskChatbot.js +82 -259
- package/{models → engine}/TiledeskChatbotConst.js +9 -0
- package/{models → engine}/TiledeskIntentsMachine.js +5 -15
- package/{models → engine/mock}/MockBotsDataSource.js +3 -19
- package/{models → engine/mock}/MockTdCache.js +0 -9
- package/index.js +103 -380
- package/logs/app.log +12723 -277
- package/logs/app1.log +62258 -0
- package/logs/app2.log +46280 -0
- package/logs/app3.log +31686 -0
- package/logs/app4.log +46163 -0
- package/logs/app5.log +33173 -0
- package/models/faq.js +2 -5
- package/package.json +5 -2
- package/{TiledeskServices → services}/AIService.js +4 -3
- package/{models/faqKbService.js → services/FaqKbService.js} +1 -2
- package/{models/faqService.js → services/FaqService.js} +4 -3
- package/services/IntegrationService.js +43 -0
- package/services/TilebotService.js +47 -0
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +49 -135
- package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +8 -14
- package/tiledeskChatbotPlugs/Filler.js +0 -1
- package/tiledeskChatbotPlugs/MarkbotChatbotPlug.js +12 -20
- package/tiledeskChatbotPlugs/MessagePipeline.js +5 -15
- package/tiledeskChatbotPlugs/SplitsChatbotPlug.js +4 -13
- package/tiledeskChatbotPlugs/TiledeskRequestVariables.js +1 -1
- package/tiledeskChatbotPlugs/WebhookChatbotPlug.js +21 -89
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirSetAttribute.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +23 -140
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +42 -128
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +37 -127
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +52 -145
- package/tiledeskChatbotPlugs/directives/DirAssign.js +12 -23
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +16 -12
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +56 -198
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +41 -101
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +9 -19
- package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirClose.js +4 -2
- package/tiledeskChatbotPlugs/directives/DirCode.js +16 -23
- package/tiledeskChatbotPlugs/directives/DirCondition.js +19 -25
- package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +9 -82
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +10 -22
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +34 -89
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +17 -22
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +8 -8
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +13 -12
- package/tiledeskChatbotPlugs/directives/DirDisableInputText.js +2 -6
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +4 -4
- package/tiledeskChatbotPlugs/directives/DirForm.js +17 -24
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +49 -139
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +8 -53
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +31 -91
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +19 -26
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +24 -78
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +17 -68
- package/tiledeskChatbotPlugs/directives/DirIntent.js +6 -100
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +15 -14
- package/tiledeskChatbotPlugs/directives/DirLockIntent.js +7 -12
- package/tiledeskChatbotPlugs/directives/DirMake.js +21 -53
- package/tiledeskChatbotPlugs/directives/DirMessage.js +35 -28
- package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +8 -87
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +6 -4
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +6 -4
- package/tiledeskChatbotPlugs/directives/DirQapla.js +26 -120
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +11 -19
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +4 -0
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +5 -2
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +12 -58
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +11 -57
- package/tiledeskChatbotPlugs/directives/DirReply.js +36 -30
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +30 -72
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +9 -10
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +15 -40
- package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +8 -5
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +25 -113
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +14 -13
- package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +3 -3
- package/tiledeskChatbotPlugs/directives/DirWait.js +5 -6
- package/tiledeskChatbotPlugs/directives/DirWebRequest.js +14 -49
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +22 -77
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +11 -14
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +13 -42
- package/tiledeskChatbotPlugs/directives/Directives.js +0 -3
- package/utils/HttpUtils.js +128 -0
- package/{models → utils}/TiledeskChatbotUtil.js +164 -234
- package/utils/winston.js +42 -0
- package/TiledeskServices/utils.js +0 -99
- /package/{models → engine/mock}/MockIntentsMachine.js +0 -0
|
@@ -34,6 +34,15 @@ class TiledeskChatbotConst {
|
|
|
34
34
|
static REQ_CHATBOT_TOKEN = "chatbotToken";
|
|
35
35
|
static REQ_CHATBOT_TOKEN_v2 = "chatbot_jwt_token";
|
|
36
36
|
static API_BASE_URL = "api_base_url";
|
|
37
|
+
static REQ_LAST_USER_IMAGE_URL = 'lastUserImageURL';
|
|
38
|
+
static REQ_LAST_USER_IMAGE_NAME = 'lastUserImageName';
|
|
39
|
+
static REQ_LAST_USER_IMAGE_WIDTH = 'lastUserImageWidth';
|
|
40
|
+
static REQ_LAST_USER_IMAGE_HEIGHT = 'lastUserImageHeight';
|
|
41
|
+
static REQ_LAST_USER_IMAGE_TYPE = 'lastUserImageType';
|
|
42
|
+
static REQ_LAST_USER_DOCUMENT_URL = 'lastUserDocumentURL';
|
|
43
|
+
static REQ_LAST_USER_DOCUMENT_NAME = 'lastUserDocumentName';
|
|
44
|
+
static REQ_LAST_USER_DOCUMENT_TYPE = 'lastUserDocumentType';
|
|
45
|
+
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
module.exports = { TiledeskChatbotConst };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
let axios = require('axios');
|
|
3
|
+
const winston = require('../utils/winston');
|
|
3
4
|
|
|
4
5
|
class TiledeskIntentsMachine {
|
|
5
6
|
|
|
@@ -21,9 +22,9 @@ class TiledeskIntentsMachine {
|
|
|
21
22
|
*/
|
|
22
23
|
async decode(botId, text) {
|
|
23
24
|
return new Promise( (resolve, reject) => {
|
|
24
|
-
|
|
25
|
+
winston.verbose("(TiledeskIntentsMachine) NLP AI...");
|
|
25
26
|
const url = `${this.API_ENDPOINT}/model/parse`;
|
|
26
|
-
|
|
27
|
+
winston.verbose("(TiledeskIntentsMachine) AI URL " + url);
|
|
27
28
|
const HTTPREQUEST = {
|
|
28
29
|
url: url,
|
|
29
30
|
headers: {
|
|
@@ -39,11 +40,10 @@ class TiledeskIntentsMachine {
|
|
|
39
40
|
HTTPREQUEST,
|
|
40
41
|
(err, resbody) => {
|
|
41
42
|
if (err) {
|
|
42
|
-
// console.error("An error occurred on /model/parse:", err)
|
|
43
43
|
reject(err);
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
|
|
46
|
+
winston.debug("(TiledeskIntentsMachine) Tiledesk AI replied: ", resbody)
|
|
47
47
|
resolve(this.translateForTiledesk(resbody));
|
|
48
48
|
}
|
|
49
49
|
}, false
|
|
@@ -94,10 +94,6 @@ class TiledeskIntentsMachine {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
myrequest(options, callback, log) {
|
|
97
|
-
if (this.log) {
|
|
98
|
-
console.log("API URL:", options.url);
|
|
99
|
-
console.log("** Options:", JSON.stringify(options));
|
|
100
|
-
}
|
|
101
97
|
axios(
|
|
102
98
|
{
|
|
103
99
|
url: options.url,
|
|
@@ -107,11 +103,6 @@ class TiledeskIntentsMachine {
|
|
|
107
103
|
headers: options.headers
|
|
108
104
|
})
|
|
109
105
|
.then((res) => {
|
|
110
|
-
if (this.log) {
|
|
111
|
-
console.log("Response for url:", options.url);
|
|
112
|
-
console.log("Response headers:\n", JSON.stringify(res.headers));
|
|
113
|
-
//console.log("******** Response for url:", res);
|
|
114
|
-
}
|
|
115
106
|
if (res && res.status == 200 && res.data) {
|
|
116
107
|
if (callback) {
|
|
117
108
|
callback(null, res.data);
|
|
@@ -123,8 +114,7 @@ class TiledeskIntentsMachine {
|
|
|
123
114
|
}
|
|
124
115
|
}
|
|
125
116
|
})
|
|
126
|
-
.catch(
|
|
127
|
-
console.error("(TiledeskIntentsMachine) Axios error: ", JSON.stringify(error));
|
|
117
|
+
.catch((error) => {
|
|
128
118
|
if (callback) {
|
|
129
119
|
callback(error, null, null);
|
|
130
120
|
}
|
|
@@ -25,7 +25,7 @@ class MockBotsDataSource {
|
|
|
25
25
|
reject(err);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
})
|
|
28
|
+
})
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
async getBotByIdCache(botId, tdcache) {
|
|
@@ -38,12 +38,8 @@ class MockBotsDataSource {
|
|
|
38
38
|
* @returns an Array of matches
|
|
39
39
|
*/
|
|
40
40
|
async getByExactMatch(botId, text) {
|
|
41
|
-
// console.log("text is:", text);
|
|
42
|
-
// console.log("this.data.bots[botId]:", this.data.bots[botId]);
|
|
43
41
|
const intent_display_name = this.data.bots[botId].questions_intent[text];
|
|
44
|
-
// console.log("intent_display_name:", intent_display_name);
|
|
45
42
|
if (intent_display_name) {
|
|
46
|
-
// console.log("intent by display name:", this.data.bots[botId].intents[intent_display_name]);
|
|
47
43
|
return [this.data.bots[botId].intents[intent_display_name]];
|
|
48
44
|
}
|
|
49
45
|
return null;
|
|
@@ -55,26 +51,20 @@ class MockBotsDataSource {
|
|
|
55
51
|
* @returns a single Intent
|
|
56
52
|
*/
|
|
57
53
|
async getByIntentDisplayName(botId, intentName) {
|
|
58
|
-
// console.log("this.data_", JSON.stringify(this.data.bots[botId]))
|
|
59
|
-
// const intent = this.data.bots[botId].intents[intentName];
|
|
60
|
-
// console.log("got intent:", intent);
|
|
61
54
|
let intent;
|
|
62
55
|
try {
|
|
63
56
|
let key = intentName.trim();
|
|
64
|
-
// console.log("key is:", key);
|
|
65
57
|
if (key.startsWith("#")) {
|
|
66
58
|
let intent_id = key.substring(key.indexOf("#") + 1);
|
|
67
59
|
intent = this.data.bots[botId].intents_by_intent_id[intent_id];
|
|
68
60
|
}
|
|
69
61
|
else {
|
|
70
|
-
// console.log("key is intent name:", key);
|
|
71
62
|
let intent_id = key;
|
|
72
63
|
intent = this.data.bots[botId].intents[intent_id];
|
|
73
|
-
// console.log("Intent found", intent);
|
|
74
64
|
}
|
|
75
65
|
}
|
|
76
66
|
catch(err) {
|
|
77
|
-
|
|
67
|
+
winston.error("(MockBotsDataSource) Error getByIntentDisplayName: ", err);
|
|
78
68
|
}
|
|
79
69
|
return intent;
|
|
80
70
|
}
|
|
@@ -82,23 +72,17 @@ class MockBotsDataSource {
|
|
|
82
72
|
async getByIntentDisplayNameCache(botId, key, tdcache) {
|
|
83
73
|
let faq = null;
|
|
84
74
|
if (tdcache) {
|
|
85
|
-
// console.log("mock cache. anyway in mock getting faq from datasource...");
|
|
86
75
|
faq = await this.getByIntentDisplayName(botId, key);
|
|
87
|
-
// console.log("faq found in datasource.:", JSON.stringify(faq));
|
|
88
76
|
}
|
|
89
77
|
else {
|
|
90
|
-
// console.log("mock no chache. getting faq from datasource...");
|
|
91
78
|
faq = await this.getByIntentDisplayName(botId, key);
|
|
92
|
-
// console.log("faq found in datasource..:", JSON.stringify(faq));
|
|
93
79
|
}
|
|
80
|
+
|
|
94
81
|
// clones the faq to avoid modifying original object
|
|
95
|
-
// console.log("faq is:", faq)
|
|
96
82
|
let json_faq;
|
|
97
83
|
if (faq !== null && faq !== undefined) {
|
|
98
84
|
let string_faq = JSON.stringify(faq)
|
|
99
|
-
// console.log("string faq is:", string_faq)
|
|
100
85
|
json_faq = JSON.parse(string_faq);
|
|
101
|
-
// console.log("json faq is:", json_faq)
|
|
102
86
|
}
|
|
103
87
|
return json_faq;
|
|
104
88
|
}
|
|
@@ -15,11 +15,7 @@ class MockTdCache {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
async incr(k) {
|
|
18
|
-
// console.log("incr...", k)
|
|
19
|
-
// return new Promise( (resolve, reject) => {
|
|
20
|
-
// console.log("Promise incr...", k)
|
|
21
18
|
let value = await this.get(k);
|
|
22
|
-
// console.log("value.............", value)
|
|
23
19
|
if (value == undefined || value == null) {
|
|
24
20
|
value = 0;
|
|
25
21
|
}
|
|
@@ -27,15 +23,10 @@ class MockTdCache {
|
|
|
27
23
|
value = Number(value);
|
|
28
24
|
}
|
|
29
25
|
catch(error) {
|
|
30
|
-
// console.error("Error on value = Number(value);", error);
|
|
31
26
|
value = 0
|
|
32
27
|
}
|
|
33
|
-
// console.log("got", k, value)
|
|
34
28
|
let v_incr = Number(value) + 1;
|
|
35
29
|
this.db.set(k, "" + v_incr) // saves as string
|
|
36
|
-
// resolve();
|
|
37
|
-
|
|
38
|
-
// });
|
|
39
30
|
}
|
|
40
31
|
|
|
41
32
|
async get(k) {
|