@tiledesk/tiledesk-tybot-connector 2.0.36-rc12 → 2.0.37
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 +3 -0
- package/engine/TiledeskChatbot.js +21 -67
- package/engine/TiledeskChatbotConst.js +0 -2
- package/index.js +0 -26
- package/logs/app.log +13651 -12759
- package/logs/app1.log +13327 -13395
- package/logs/app2.log +7679 -10185
- package/logs/app8.log +4066 -0
- package/logs/app9.log +5452 -0
- package/package.json +4 -3
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +1 -22
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirOfflineHours.js +4 -3
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +12 -11
- package/tiledeskChatbotPlugs/directives/DirAssign.js +7 -5
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +0 -26
- package/tiledeskChatbotPlugs/directives/DirCondition.js +0 -35
- package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +0 -34
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirDisableInputText.js +0 -22
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +4 -2
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +0 -24
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +0 -30
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +0 -29
- package/tiledeskChatbotPlugs/directives/DirIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirLockIntent.js +1 -25
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +1 -32
- package/tiledeskChatbotPlugs/directives/DirWait.js +0 -8
- package/utils/TiledeskChatbotUtil.js +163 -139
- package/logs/app3.log +0 -161
- package/logs/app4.log +0 -46163
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiledesk/tiledesk-tybot-connector",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.37",
|
|
4
4
|
"description": "Tiledesk Tybot connector",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@tiledesk/tiledesk-chatbot-client": "^0.5.30",
|
|
16
16
|
"@tiledesk/tiledesk-chatbot-util": "^0.8.39",
|
|
17
17
|
"@tiledesk/tiledesk-client": "^0.10.13",
|
|
18
|
-
"@tiledesk/tiledesk-multi-worker": "^0.3.
|
|
18
|
+
"@tiledesk/tiledesk-multi-worker": "^0.3.5",
|
|
19
19
|
"accept-language-parser": "^1.5.0",
|
|
20
20
|
"app-root-path": "^3.1.0",
|
|
21
21
|
"axios": "^1.7.7",
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
"jsonschema": "^1.4.1",
|
|
28
28
|
"jsonwebtoken": "^8.5.1",
|
|
29
29
|
"liquidjs": "^10.8.4",
|
|
30
|
-
"minimist
|
|
30
|
+
"minimist": "^1.2.8",
|
|
31
31
|
"mongoose": "^6.3.5",
|
|
32
32
|
"mqtt": "^5.10.4",
|
|
33
33
|
"multer": "^1.4.5-lts.1",
|
|
34
34
|
"nanoid": "^3.1.25",
|
|
35
35
|
"redis": "^4.7.0",
|
|
36
|
+
"string-argv": "^0.3.2",
|
|
36
37
|
"uuid": "^3.3.3",
|
|
37
38
|
"vm2": "^3.9.13",
|
|
38
39
|
"winston": "^3.17.0"
|
|
@@ -117,7 +117,6 @@ class DirectivesChatbotPlug {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
async processDirectives(theend) {
|
|
120
|
-
console.log(`(GAB) DirectivesChatbotPlug 0--> after processDirectives at : ${new Date().getTime()}`)
|
|
121
120
|
this.theend = theend;
|
|
122
121
|
const directives = this.directives;
|
|
123
122
|
if (!directives || directives.length === 0) {
|
|
@@ -171,23 +170,15 @@ class DirectivesChatbotPlug {
|
|
|
171
170
|
this.curr_directive_index = -1;
|
|
172
171
|
winston.verbose("(DirectivesChatbotPlug) processing directives...");
|
|
173
172
|
|
|
174
|
-
let start1 = new Date()
|
|
175
173
|
const next_dir = await this.nextDirective(directives);
|
|
176
|
-
let end1 = new Date()
|
|
177
|
-
console.log(`(GAB) DirectivesChatbotPlug 1--> after processDirectives nextDirective at : ${end1.getTime()}, diff: ${end1-start1}[ms]`)
|
|
178
|
-
|
|
179
174
|
winston.debug("(DirectivesChatbotPlug) next_dir: ", next_dir);
|
|
180
175
|
await this.process(next_dir);
|
|
181
176
|
}
|
|
182
177
|
|
|
183
178
|
async nextDirective(directives) {
|
|
184
|
-
console.log(`(GAB) DirectivesChatbotPlug 0--> nextDirective at : ${new Date().getTime()}`)
|
|
185
|
-
let start1 = new Date()
|
|
186
179
|
winston.debug("(DirectivesChatbotPlug) ....nextDirective() checkStep()");
|
|
187
180
|
const go_on = await TiledeskChatbot.checkStep(this.context.tdcache, this.context.requestId, this.chatbot?.MAX_STEPS, this.chatbot?.MAX_EXECUTION_TIME);
|
|
188
|
-
|
|
189
|
-
console.log(`(GAB) DirectivesChatbotPlug 1--> nextDirective at : ${end1.getTime()}, diff: ${end1-start1}[ms]`)
|
|
190
|
-
|
|
181
|
+
|
|
191
182
|
if (go_on.error) {
|
|
192
183
|
winston.debug("(DirectivesChatbotPlug) go_on == false! nextDirective() Stopped!");
|
|
193
184
|
return this.errorMessage(go_on.error); //"Request error: anomaly detection. MAX ACTIONS exeeded.");
|
|
@@ -220,7 +211,6 @@ class DirectivesChatbotPlug {
|
|
|
220
211
|
}
|
|
221
212
|
|
|
222
213
|
async process(directive) {
|
|
223
|
-
console.log(`(GAB) DirectivesChatbotPlug process 0--> after process at : ${new Date().getTime()}`)
|
|
224
214
|
let context = this.context;
|
|
225
215
|
if (directive) {
|
|
226
216
|
winston.verbose("(DirectivesChatbotPlug) directive['name']: " + directive["name"]);
|
|
@@ -229,23 +219,16 @@ class DirectivesChatbotPlug {
|
|
|
229
219
|
if (directive && directive.name) {
|
|
230
220
|
directive_name = directive.name.toLowerCase();
|
|
231
221
|
}
|
|
232
|
-
let start1 = new Date();
|
|
233
222
|
if (directive && directive.action) {
|
|
234
223
|
const action_id = directive.action["_tdActionId"];
|
|
235
224
|
const locked_action_id = await this.chatbot.currentLockedAction(this.supportRequest.request_id);
|
|
236
|
-
let end1 = new Date()
|
|
237
|
-
console.log(`(GAB) DirectivesChatbotPlug process 1--> after chatbot.currentLockedAction at : ${end1.getTime()}, diff: ${end1-start1}[ms]`)
|
|
238
225
|
if ( locked_action_id && (locked_action_id !== action_id) ) {
|
|
239
|
-
let start2 = new Date();
|
|
240
226
|
let next_dir = await this.nextDirective(this.directives);
|
|
241
|
-
let end2 = new Date()
|
|
242
|
-
console.log(`(GAB) DirectivesChatbotPlug process 2--> after chatbot.currentLockedAction at : ${end2.getTime()}, diff: ${end2-start2}[ms]`)
|
|
243
227
|
this.process(next_dir);
|
|
244
228
|
return;
|
|
245
229
|
}
|
|
246
230
|
|
|
247
231
|
}
|
|
248
|
-
let start2 = new Date()
|
|
249
232
|
if (directive == null || (directive !== null && directive["name"] === undefined)) {
|
|
250
233
|
winston.debug("(DirectivesChatbotPlug) stop process(). directive is (null?): ", directive);
|
|
251
234
|
this.theend();
|
|
@@ -467,11 +450,7 @@ class DirectivesChatbotPlug {
|
|
|
467
450
|
});
|
|
468
451
|
}
|
|
469
452
|
else if (directive_name === Directives.WAIT) {
|
|
470
|
-
let end2 = new Date();
|
|
471
|
-
console.log(`(GAB) DirectivesChatbotPlug process 3--> before DirWait execute at : ${end2.getTime()}`)
|
|
472
453
|
new DirWait(context).execute(directive, async () => {
|
|
473
|
-
let endWait = new Date()
|
|
474
|
-
console.log(`(GAB) DirectivesChatbotPlug process 3--> after DirWait executed callback at : ${endWait.getTime()}, diff: ${endWait-end2}[ms]`)
|
|
475
454
|
let next_dir = await this.nextDirective(this.directives);
|
|
476
455
|
this.process(next_dir);
|
|
477
456
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const { parseArgsStringToArgv } = require('string-argv');
|
|
2
|
+
const minimist = require('minimist');
|
|
3
3
|
// DEPRECATED
|
|
4
4
|
class DirOfflineHours {
|
|
5
5
|
|
|
@@ -79,7 +79,8 @@ class DirOfflineHours {
|
|
|
79
79
|
let intentreply = null;
|
|
80
80
|
let message = null;
|
|
81
81
|
let replace = false;
|
|
82
|
-
const
|
|
82
|
+
const argv = parseArgsStringToArgv(directive_parameter); // trasforma in array come process.argv
|
|
83
|
+
const params = minimist(argv);
|
|
83
84
|
// console.log("params:", params)
|
|
84
85
|
|
|
85
86
|
if (params.m) {
|
|
@@ -85,17 +85,18 @@ class DirAskGPTV2 {
|
|
|
85
85
|
let skip_unanswered;
|
|
86
86
|
|
|
87
87
|
let contexts = {
|
|
88
|
-
"gpt-3.5-turbo": "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say: \"I don't know<NOANS>\"\n\n####{context}####",
|
|
89
|
-
"gpt-4": "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
|
|
90
|
-
"gpt-4-turbo-preview": "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
|
|
91
|
-
"gpt-4o": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
92
|
-
"gpt-4o-mini": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
93
|
-
"gpt-4.1": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
94
|
-
"gpt-4.1-mini": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
95
|
-
"gpt-4.1-nano": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
96
|
-
"gpt-5": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
97
|
-
"gpt-5-mini": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
98
|
-
"gpt-5-nano": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end=="
|
|
88
|
+
"gpt-3.5-turbo": process.env.GPT_3_5_CONTEXT || "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say: \"I don't know<NOANS>\"\n\n####{context}####",
|
|
89
|
+
"gpt-4": process.env.GPT_4_CONTEXT || "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
|
|
90
|
+
"gpt-4-turbo-preview": process.env.GPT_4T_CONTEXT || "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
|
|
91
|
+
"gpt-4o": process.env.GPT_4O_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
92
|
+
"gpt-4o-mini": process.env.GPT_4O_MINI_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
93
|
+
"gpt-4.1": process.env.GPT_4_1_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
94
|
+
"gpt-4.1-mini": process.env.GPT_4_1_MINI_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
95
|
+
"gpt-4.1-nano": process.env.GPT_4_1_NANO_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
96
|
+
"gpt-5": process.env.GPT_5_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
97
|
+
"gpt-5-mini": process.env.GPT_5_MINI_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
98
|
+
"gpt-5-nano": process.env.GPT_5_NANO_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
|
|
99
|
+
"general": process.env.GENERAL_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end=="
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
let source = null;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
2
2
|
const { TiledeskExpression } = require('../../TiledeskExpression');
|
|
3
|
-
const ms = require('minimist-string');
|
|
4
3
|
const { Filler } = require('../Filler');
|
|
4
|
+
const { parseArgsStringToArgv } = require('string-argv');
|
|
5
|
+
const minimist = require('minimist');
|
|
5
6
|
const winston = require('../../utils/winston')
|
|
6
7
|
|
|
7
8
|
class DirAssign {
|
|
@@ -80,7 +81,8 @@ class DirAssign {
|
|
|
80
81
|
parseParams(directive_parameter) {
|
|
81
82
|
let expression = null;
|
|
82
83
|
let assignTo = null;
|
|
83
|
-
const
|
|
84
|
+
const argv = parseArgsStringToArgv(directive_parameter); // trasforma in array come process.argv
|
|
85
|
+
const params = minimist(argv);
|
|
84
86
|
if (params.expression !== null) {
|
|
85
87
|
expression = params.expression
|
|
86
88
|
}
|
|
@@ -88,9 +90,9 @@ class DirAssign {
|
|
|
88
90
|
assignTo = params.assignTo;
|
|
89
91
|
}
|
|
90
92
|
return {
|
|
91
|
-
expression: expression,
|
|
92
|
-
assignTo: assignTo
|
|
93
|
-
}
|
|
93
|
+
expression: params.expression,
|
|
94
|
+
assignTo: params.assignTo
|
|
95
|
+
};
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
|
-
const ms = require('minimist-string');
|
|
3
2
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot.js');
|
|
4
3
|
const winston = require('../../utils/winston')
|
|
5
4
|
|
|
@@ -21,16 +20,6 @@ class DirAssignFromFunction {
|
|
|
21
20
|
let action;
|
|
22
21
|
if (directive.action) {
|
|
23
22
|
action = directive.action
|
|
24
|
-
}
|
|
25
|
-
else if (directive.parameter) {
|
|
26
|
-
let params;
|
|
27
|
-
if (directive.parameter) {
|
|
28
|
-
params = this.parseParams(directive.parameter);
|
|
29
|
-
}
|
|
30
|
-
action = {
|
|
31
|
-
functionName: params.functionName,
|
|
32
|
-
assignTo: params.assignTo
|
|
33
|
-
}
|
|
34
23
|
} else {
|
|
35
24
|
winston.warn("Incorrect directive: ", directive);
|
|
36
25
|
callback();
|
|
@@ -99,21 +88,6 @@ class DirAssignFromFunction {
|
|
|
99
88
|
|
|
100
89
|
}
|
|
101
90
|
}
|
|
102
|
-
parseParams(directive_parameter) {
|
|
103
|
-
let functionName = null;
|
|
104
|
-
let assignTo = null;
|
|
105
|
-
const params = ms(directive_parameter);
|
|
106
|
-
if (params.functionName) {
|
|
107
|
-
functionName = params.functionName
|
|
108
|
-
}
|
|
109
|
-
if (params.assignTo) {
|
|
110
|
-
assignTo = params.assignTo;
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
functionName: functionName,
|
|
114
|
-
assignTo: assignTo
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
91
|
|
|
118
92
|
}
|
|
119
93
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { DirIntent } = require('./DirIntent');
|
|
2
2
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
|
|
3
3
|
const { TiledeskExpression } = require('../../TiledeskExpression');
|
|
4
|
-
const ms = require('minimist-string');
|
|
5
4
|
const winston = require('../../utils/winston');
|
|
6
5
|
const { Logger } = require('../../Logger');
|
|
7
6
|
|
|
@@ -24,19 +23,6 @@ class DirCondition {
|
|
|
24
23
|
if (directive.action) {
|
|
25
24
|
action = directive.action
|
|
26
25
|
}
|
|
27
|
-
else if (directive.parameter) {
|
|
28
|
-
let params;
|
|
29
|
-
params = this.parseParams(directive.parameter);
|
|
30
|
-
if (!params.condition) {
|
|
31
|
-
callback();
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
action = {
|
|
35
|
-
scriptCondition: params.condition,
|
|
36
|
-
trueIntent: params.trueIntent,
|
|
37
|
-
falseIntent: params.falseIntent
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
26
|
else {
|
|
41
27
|
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
42
28
|
winston.warn("DirCondition Incorrect directive: ", directive);
|
|
@@ -157,27 +143,6 @@ class DirCondition {
|
|
|
157
143
|
// return result;
|
|
158
144
|
// }
|
|
159
145
|
|
|
160
|
-
parseParams(directive_parameter) {
|
|
161
|
-
let condition = null;
|
|
162
|
-
let trueIntent = null;
|
|
163
|
-
let falseIntent = null;
|
|
164
|
-
const params = ms(directive_parameter);
|
|
165
|
-
if (params.condition) {
|
|
166
|
-
condition = params.condition
|
|
167
|
-
}
|
|
168
|
-
if (params.trueIntent) {
|
|
169
|
-
trueIntent = params.trueIntent;
|
|
170
|
-
}
|
|
171
|
-
if (params.falseIntent) {
|
|
172
|
-
falseIntent = params.falseIntent;
|
|
173
|
-
}
|
|
174
|
-
return {
|
|
175
|
-
condition: condition,
|
|
176
|
-
trueIntent: trueIntent,
|
|
177
|
-
falseIntent: falseIntent
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
146
|
}
|
|
182
147
|
|
|
183
148
|
module.exports = { DirCondition };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { HelpCenterQuery } = require('@tiledesk/helpcenter-query-client');
|
|
2
2
|
const { TiledeskChatbot } = require('../../engine/TiledeskChatbot.js');
|
|
3
3
|
const { TiledeskChatbotConst } = require('../../engine/TiledeskChatbotConst.js');
|
|
4
|
-
const ms = require('minimist-string');
|
|
5
4
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
6
5
|
const winston = require('../../utils/winston');
|
|
7
6
|
|
|
@@ -23,13 +22,6 @@ class DirDeflectToHelpCenter {
|
|
|
23
22
|
if (directive.action) {
|
|
24
23
|
action = directive.action
|
|
25
24
|
}
|
|
26
|
-
else if (directive.parameter) {
|
|
27
|
-
const params = this.parseParams(directive.parameter);
|
|
28
|
-
workspace_id = params.workspace_id;
|
|
29
|
-
if (params.hc_reply) {
|
|
30
|
-
hc_reply = params.hc_reply;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
25
|
this.go(action, (stop) => {
|
|
34
26
|
callback(stop);
|
|
35
27
|
});
|
|
@@ -160,32 +152,6 @@ class DirDeflectToHelpCenter {
|
|
|
160
152
|
callback(false);
|
|
161
153
|
}
|
|
162
154
|
}
|
|
163
|
-
|
|
164
|
-
parseParams(directive_parameter) {
|
|
165
|
-
let workspace_id = null;
|
|
166
|
-
let hc_reply = null;
|
|
167
|
-
|
|
168
|
-
const params = ms(directive_parameter);
|
|
169
|
-
if (params.w) {
|
|
170
|
-
workspace_id = params.w
|
|
171
|
-
}
|
|
172
|
-
if (params.workspace) {
|
|
173
|
-
workspace_id = params.workspace
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (params.m) {
|
|
177
|
-
//hc_reply = params.m.replaceAll("\\n", "\n");
|
|
178
|
-
hc_reply = params.m.replace(/\\n/g, "\n");
|
|
179
|
-
}
|
|
180
|
-
if (params.message) {
|
|
181
|
-
//hc_reply = params.message.replaceAll("\\n", "\n");
|
|
182
|
-
hc_reply = params.message.replace(/\\n/g, "\n");
|
|
183
|
-
}
|
|
184
|
-
return {
|
|
185
|
-
workspace_id: workspace_id,
|
|
186
|
-
hc_reply: hc_reply
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
155
|
}
|
|
190
156
|
|
|
191
157
|
module.exports = { DirDeflectToHelpCenter };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const ms = require('minimist-string');
|
|
2
1
|
const winston = require('../../utils/winston');
|
|
3
2
|
|
|
4
3
|
// DEPRECATED
|
|
@@ -14,29 +13,8 @@ class DirDisableInputText {
|
|
|
14
13
|
message.attributes = {}
|
|
15
14
|
}
|
|
16
15
|
message.attributes.disableInputMessage = true;
|
|
17
|
-
if (directive.parameter) {
|
|
18
|
-
const options = this.parseParams(directive.parameter);
|
|
19
|
-
directive.options = options;
|
|
20
|
-
if (options.label) {
|
|
21
|
-
message.attributes.inputMessagePlaceholder = options.label;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
16
|
callback();
|
|
25
17
|
}
|
|
26
|
-
|
|
27
|
-
parseParams(directive_parameter) {
|
|
28
|
-
let label = null;
|
|
29
|
-
const params = ms(directive_parameter);
|
|
30
|
-
if (params.l) {
|
|
31
|
-
label = params.l;
|
|
32
|
-
}
|
|
33
|
-
if (params.label) {
|
|
34
|
-
label = params.label;
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
label: label
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
18
|
}
|
|
41
19
|
|
|
42
20
|
module.exports = { DirDisableInputText };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
|
-
const
|
|
2
|
+
const { parseArgsStringToArgv } = require('string-argv');
|
|
3
|
+
const minimist = require('minimist');
|
|
3
4
|
const winston = require('../../utils/winston');
|
|
4
5
|
|
|
5
6
|
class DirFireTiledeskEvent {
|
|
@@ -41,7 +42,8 @@ class DirFireTiledeskEvent {
|
|
|
41
42
|
parseParams(directive_parameter) {
|
|
42
43
|
let name = null;
|
|
43
44
|
let payload = null;
|
|
44
|
-
const
|
|
45
|
+
const argv = parseArgsStringToArgv(directive_parameter); // trasforma in array come process.argv
|
|
46
|
+
const params = minimist(argv);
|
|
45
47
|
if (params.n) {
|
|
46
48
|
name = params.n;
|
|
47
49
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
2
|
const { DirIntent } = require('./DirIntent');
|
|
3
|
-
const ms = require('minimist-string');
|
|
4
3
|
const winston = require('../../utils/winston');
|
|
5
4
|
|
|
6
5
|
class DirIfOnlineAgents {
|
|
@@ -24,14 +23,6 @@ class DirIfOnlineAgents {
|
|
|
24
23
|
if (directive.action) {
|
|
25
24
|
action = directive.action
|
|
26
25
|
}
|
|
27
|
-
else if (directive.parameter) {
|
|
28
|
-
let params;
|
|
29
|
-
params = this.parseParams(directive.parameter);
|
|
30
|
-
action = {
|
|
31
|
-
trueIntent: params.trueIntent,
|
|
32
|
-
falseIntent: params.falseIntent
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
26
|
else {
|
|
36
27
|
winston.warn("DirIfOnlineAgents Incorrect directive: ", directive);
|
|
37
28
|
callback();
|
|
@@ -122,21 +113,6 @@ class DirIfOnlineAgents {
|
|
|
122
113
|
});
|
|
123
114
|
}
|
|
124
115
|
|
|
125
|
-
parseParams(directive_parameter) {
|
|
126
|
-
let trueIntent = null;
|
|
127
|
-
let falseIntent = null;
|
|
128
|
-
const params = ms(directive_parameter);
|
|
129
|
-
if (params.trueIntent) {
|
|
130
|
-
trueIntent = params.trueIntent;
|
|
131
|
-
}
|
|
132
|
-
if (params.falseIntent) {
|
|
133
|
-
falseIntent = params.falseIntent;
|
|
134
|
-
}
|
|
135
|
-
return {
|
|
136
|
-
trueIntent: trueIntent,
|
|
137
|
-
falseIntent: falseIntent
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
116
|
}
|
|
141
117
|
|
|
142
118
|
module.exports = { DirIfOnlineAgents };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
let axios = require('axios');
|
|
2
2
|
const { DirIntent } = require('./DirIntent');
|
|
3
3
|
let https = require("https");
|
|
4
|
-
const ms = require('minimist-string');
|
|
5
4
|
const winston = require('../../utils/winston');
|
|
6
5
|
const httpUtils = require('../../utils/HttpUtils');
|
|
7
6
|
const { Logger } = require('../../Logger');
|
|
@@ -27,19 +26,6 @@ class DirIfOpenHours {
|
|
|
27
26
|
if (directive.action) {
|
|
28
27
|
action = directive.action
|
|
29
28
|
}
|
|
30
|
-
else if (directive.parameter) {
|
|
31
|
-
let params;
|
|
32
|
-
params = this.parseParams(directive.parameter);
|
|
33
|
-
if (!params.trueIntent && !params.falseIntent) {
|
|
34
|
-
winston.warn("DirIfOpenHours both params.trueIntent & params.falseIntent");
|
|
35
|
-
callback();
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
action = {
|
|
39
|
-
trueIntent: params.trueIntent,
|
|
40
|
-
falseIntent: params.falseIntent
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
29
|
else {
|
|
44
30
|
this.logger.error("Incorrect action for ", directive.name, directive)
|
|
45
31
|
winston.warn("DirIfOpenHours Incorrect directive: ", directive);
|
|
@@ -169,22 +155,6 @@ class DirIfOpenHours {
|
|
|
169
155
|
// });
|
|
170
156
|
}
|
|
171
157
|
|
|
172
|
-
parseParams(directive_parameter) {
|
|
173
|
-
let trueIntent = null;
|
|
174
|
-
let falseIntent = null;
|
|
175
|
-
const params = ms(directive_parameter);
|
|
176
|
-
if (params.trueIntent) {
|
|
177
|
-
trueIntent = params.trueIntent;
|
|
178
|
-
}
|
|
179
|
-
if (params.falseIntent) {
|
|
180
|
-
falseIntent = params.falseIntent;
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
trueIntent: trueIntent,
|
|
184
|
-
falseIntent: falseIntent
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
158
|
}
|
|
189
159
|
|
|
190
160
|
module.exports = { DirIfOpenHours };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
2
2
|
const { DirIntent } = require('./DirIntent');
|
|
3
|
-
const ms = require('minimist-string');
|
|
4
3
|
const winston = require('../../utils/winston');
|
|
5
4
|
|
|
6
5
|
class DirIfOpenHours {
|
|
@@ -23,18 +22,6 @@ class DirIfOpenHours {
|
|
|
23
22
|
if (directive.action) {
|
|
24
23
|
action = directive.action
|
|
25
24
|
}
|
|
26
|
-
else if (directive.parameter) {
|
|
27
|
-
let params;
|
|
28
|
-
params = this.parseParams(directive.parameter);
|
|
29
|
-
if (!params.trueIntent && !params.falseIntent) {
|
|
30
|
-
callback();
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
action = {
|
|
34
|
-
trueIntent: params.trueIntent,
|
|
35
|
-
falseIntent: params.falseIntent
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
25
|
else {
|
|
39
26
|
callback();
|
|
40
27
|
return;
|
|
@@ -96,22 +83,6 @@ class DirIfOpenHours {
|
|
|
96
83
|
});
|
|
97
84
|
}
|
|
98
85
|
|
|
99
|
-
parseParams(directive_parameter) {
|
|
100
|
-
let trueIntent = null;
|
|
101
|
-
let falseIntent = null;
|
|
102
|
-
const params = ms(directive_parameter);
|
|
103
|
-
if (params.trueIntent) {
|
|
104
|
-
trueIntent = params.trueIntent;
|
|
105
|
-
}
|
|
106
|
-
if (params.falseIntent) {
|
|
107
|
-
falseIntent = params.falseIntent;
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
trueIntent: trueIntent,
|
|
111
|
-
falseIntent: falseIntent
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
86
|
}
|
|
116
87
|
|
|
117
88
|
module.exports = { DirIfOpenHours };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const ms = require('minimist-string');
|
|
2
1
|
const winston = require('../../utils/winston');
|
|
3
2
|
|
|
4
3
|
class DirLockIntent {
|
|
@@ -19,14 +18,7 @@ class DirLockIntent {
|
|
|
19
18
|
let action;
|
|
20
19
|
if (directive.action) {
|
|
21
20
|
action = directive.action;
|
|
22
|
-
}
|
|
23
|
-
else if (directive.parameter && directive.parameter.trim() !== "") {
|
|
24
|
-
const params = this.parseParams(directive.parameter);
|
|
25
|
-
action = {
|
|
26
|
-
intentName: params.intentName
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
21
|
+
} else {
|
|
30
22
|
winston.warn("DirLockIntent Incorrect directive: ", directive);
|
|
31
23
|
callback();
|
|
32
24
|
return;
|
|
@@ -67,22 +59,6 @@ class DirLockIntent {
|
|
|
67
59
|
// await this.tdcache.set("tilebot:requests:" + requestId + ":lockedValue", variable_name);
|
|
68
60
|
// }
|
|
69
61
|
}
|
|
70
|
-
|
|
71
|
-
parseParams(directive_parameter) {
|
|
72
|
-
let intentName = null;
|
|
73
|
-
let variableName = null;
|
|
74
|
-
const params = ms(directive_parameter);
|
|
75
|
-
if (params.intentName) {
|
|
76
|
-
intentName = params.intentName
|
|
77
|
-
}
|
|
78
|
-
if (params.variableName) {
|
|
79
|
-
variableName = params.variableName.replace(/[$]/g, ""); // $ sign not permitted. Silently removing if present
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
intentName: intentName,
|
|
83
|
-
variableName: variableName
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
62
|
|
|
87
63
|
}
|
|
88
64
|
|