@tiledesk/tiledesk-tybot-connector 2.0.8 → 2.0.9-rc1
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 +30 -0
- package/ExtApi.js +1 -8
- package/ExtUtil.js +5 -6
- package/Logger.js +30 -13
- package/engine/IntentForm.js +0 -1
- package/engine/IntentsMachineFactory.js +4 -4
- package/engine/MongodbBotsDataSource.js +0 -1
- package/engine/MongodbIntentsMachine.js +0 -1
- package/engine/TiledeskChatbot.js +11 -16
- package/engine/TiledeskIntentsMachine.js +1 -2
- package/engine/mock/MockBotsDataSource.js +1 -2
- package/index.js +23 -39
- package/logs/app1.log +1400 -0
- package/package.json +3 -2
- package/services/AIService.js +1 -1
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +24 -18
- package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +1 -2
- package/tiledeskChatbotPlugs/MarkbotChatbotPlug.js +1 -3
- package/tiledeskChatbotPlugs/SplitsChatbotPlug.js +1 -3
- package/tiledeskChatbotPlugs/WebhookChatbotPlug.js +7 -9
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirIfNotOpenHours.js +3 -10
- package/tiledeskChatbotPlugs/directives/DEPRECATED_DirIfOpenHours.js +2 -9
- package/tiledeskChatbotPlugs/directives/DirAddTags.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirAskGPT.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirAssign.js +5 -8
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirAssistant.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirBrevo.js +4 -6
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirClose.js +0 -2
- package/tiledeskChatbotPlugs/directives/DirCode.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirCondition.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirCustomerio.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +2 -5
- package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirForm.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirGptTask.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +36 -55
- package/tiledeskChatbotPlugs/directives/DirHubspot.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +0 -2
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +8 -12
- package/tiledeskChatbotPlugs/directives/DirIntent.js +6 -5
- package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirLockIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMake.js +1 -16
- package/tiledeskChatbotPlugs/directives/DirMessage.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +0 -3
- package/tiledeskChatbotPlugs/directives/DirQapla.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +1 -2
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirReply.js +7 -18
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +8 -13
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +1 -4
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +1 -3
- package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWait.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequest.js +0 -1
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +1 -16
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +6 -40
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +0 -1
- package/tiledeskChatbotPlugs/directives/Directives.js +1 -0
- package/utils/TiledeskChatbotUtil.js +19 -57
- package/TdCache copy.js +0 -242
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +0 -417
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
available on:
|
|
6
6
|
▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
|
|
7
7
|
|
|
8
|
+
# 2.0.9-rc1
|
|
9
|
+
- removed: speech-to-text management
|
|
10
|
+
|
|
8
11
|
# 2.0.8
|
|
9
12
|
|
|
10
13
|
# 2.0.8-rc2
|
|
@@ -15,6 +18,8 @@ available on:
|
|
|
15
18
|
|
|
16
19
|
# v0.5.0
|
|
17
20
|
- added: AI_ENDPOINT env var
|
|
21
|
+
|
|
22
|
+
# v0.5.0-rc1
|
|
18
23
|
- added: ability to get 'none' as bodytype in webresponse
|
|
19
24
|
|
|
20
25
|
# v0.4.2
|
|
@@ -29,6 +34,19 @@ available on:
|
|
|
29
34
|
- changed: refactoring of DIrWebRequestv2
|
|
30
35
|
- bug-fixed: erro while parsing webrequestv2 body
|
|
31
36
|
|
|
37
|
+
# v0.3.5-rc4
|
|
38
|
+
- added: webhook action (same as intent one)
|
|
39
|
+
|
|
40
|
+
# v0.3.5-rc3
|
|
41
|
+
- bug-fixed: jsonBody parse error in web-request-v2
|
|
42
|
+
|
|
43
|
+
# v0.3.5-rc2
|
|
44
|
+
- bug-fixed: cannot set status of undefined reading res.status in DirAssistant
|
|
45
|
+
|
|
46
|
+
# v0.3.5-rc1
|
|
47
|
+
- changed: refactoring web-request-v2
|
|
48
|
+
- bug-fixed: jsonBody parse error in web-request-v2
|
|
49
|
+
|
|
32
50
|
# v0.3.4
|
|
33
51
|
-bug-fixed: slit is undefined in TiledeskChatbotUtils
|
|
34
52
|
|
|
@@ -38,6 +56,18 @@ available on:
|
|
|
38
56
|
# v0.3.2
|
|
39
57
|
- bug-fixed: minor improvement
|
|
40
58
|
|
|
59
|
+
# v0.2.153-rc9
|
|
60
|
+
- changed: updated tiledesk-multi-worker to 0.2.1-rc2
|
|
61
|
+
|
|
62
|
+
# v0.2.153-rc8
|
|
63
|
+
- added: fixToken function in TiledeskService utils class
|
|
64
|
+
|
|
65
|
+
# v0.2.153-rc4
|
|
66
|
+
- log added
|
|
67
|
+
|
|
68
|
+
# v0.2.153-rc3
|
|
69
|
+
- added: specchToText function to transcript audio file
|
|
70
|
+
|
|
41
71
|
# v0.2.153-rc1
|
|
42
72
|
- changed: context for gpt-40 and gpt-40-mini
|
|
43
73
|
|
package/ExtApi.js
CHANGED
|
@@ -10,12 +10,6 @@ class ExtApi {
|
|
|
10
10
|
throw new Error("options.TILEBOT_ENDPOINT is mandatory");
|
|
11
11
|
//this.extEndpoint = `${options.TILEBOT_ENDPOINT}/;
|
|
12
12
|
}
|
|
13
|
-
if (options.log) {
|
|
14
|
-
this.log = options.log;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
this.log = false;
|
|
18
|
-
}
|
|
19
13
|
this.TILEBOT_ENDPOINT = options.TILEBOT_ENDPOINT;
|
|
20
14
|
}
|
|
21
15
|
|
|
@@ -63,8 +57,7 @@ class ExtApi {
|
|
|
63
57
|
callback(null, resbody);
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
|
-
}
|
|
67
|
-
);
|
|
60
|
+
});
|
|
68
61
|
}
|
|
69
62
|
|
|
70
63
|
}
|
package/ExtUtil.js
CHANGED
|
@@ -8,20 +8,19 @@ const { FillParamsChatbotPlug } = require('./tiledeskChatbotPlugs/FillParamsChat
|
|
|
8
8
|
|
|
9
9
|
// PROD
|
|
10
10
|
/*const { MessagePipeline } = require('@tiledesk/tiledesk-chatbot-plugs/MessagePipeline');
|
|
11
|
-
const { DirectivesChatbotPlug } = require('@tiledesk/tiledesk-chatbot-plugs/DirectivesChatbotPlug');
|
|
12
11
|
const { SplitsChatbotPlug } = require('@tiledesk/tiledesk-chatbot-plugs/SplitsChatbotPlug');
|
|
13
12
|
const { MarkbotChatbotPlug } = require('@tiledesk/tiledesk-chatbot-plugs/MarkbotChatbotPlug');
|
|
14
13
|
const { WebhookChatbotPlug } = require('@tiledesk/tiledesk-chatbot-plugs/WebhookChatbotPlug');*/
|
|
15
14
|
|
|
16
15
|
class ExtUtil {
|
|
17
16
|
|
|
18
|
-
static async execPipelineExt(request, static_bot_answer, directivesPlug, tdcache
|
|
17
|
+
static async execPipelineExt(request, static_bot_answer, directivesPlug, tdcache) {
|
|
19
18
|
const messagePipeline = new MessagePipeline(static_bot_answer, null);
|
|
20
19
|
messagePipeline.addPlug(directivesPlug);
|
|
21
|
-
messagePipeline.addPlug(new FillParamsChatbotPlug(request, tdcache
|
|
22
|
-
messagePipeline.addPlug(new SplitsChatbotPlug(
|
|
23
|
-
messagePipeline.addPlug(new MarkbotChatbotPlug(
|
|
24
|
-
messagePipeline.addPlug(new FillParamsChatbotPlug(request, tdcache
|
|
20
|
+
messagePipeline.addPlug(new FillParamsChatbotPlug(request, tdcache)); // in original message
|
|
21
|
+
messagePipeline.addPlug(new SplitsChatbotPlug());
|
|
22
|
+
messagePipeline.addPlug(new MarkbotChatbotPlug());
|
|
23
|
+
messagePipeline.addPlug(new FillParamsChatbotPlug(request, tdcache)); // in splits
|
|
25
24
|
const bot_answer = await messagePipeline.exec();
|
|
26
25
|
return bot_answer;
|
|
27
26
|
}
|
package/Logger.js
CHANGED
|
@@ -2,13 +2,18 @@ let { Publisher } = require("@tiledesk/tiledesk-multi-worker");
|
|
|
2
2
|
|
|
3
3
|
const FLOW_LOGS_ENABLED = process.env.FLOW_LOGS_ENABLED;
|
|
4
4
|
const AMQP_MANAGER_URL = process.env.AMQP_MANAGER_URL;
|
|
5
|
+
const LOGS_BASE_ROUTING_KEY = process.env.LOGS_BASE_ROUTING_KEY || "apps.tilechat.logs";
|
|
6
|
+
|
|
7
|
+
const levels = { error: 0, warn: 1, info: 2, debug: 3 };
|
|
8
|
+
|
|
5
9
|
let publisher = new Publisher(AMQP_MANAGER_URL, {
|
|
6
10
|
debug: false,
|
|
7
11
|
queueName: "logs_queue",
|
|
8
|
-
exchange: "
|
|
9
|
-
topic: "logs",
|
|
12
|
+
exchange: "amq.topic"
|
|
10
13
|
})
|
|
11
14
|
|
|
15
|
+
console.log("LOGGER publisher: ", publisher);
|
|
16
|
+
|
|
12
17
|
class Logger {
|
|
13
18
|
|
|
14
19
|
constructor(config) {
|
|
@@ -33,10 +38,15 @@ class Logger {
|
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
this.request_id = config.request_id;
|
|
41
|
+
console.log("LOGGER for request ", this.request_id);
|
|
42
|
+
|
|
36
43
|
this.dev = false;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
console.log("LOGGER is dev conversation ? ", config.dev);
|
|
45
|
+
// if (config.dev && config.dev === true) {
|
|
46
|
+
// this.dev = true;
|
|
47
|
+
// } else {
|
|
48
|
+
// this._disableDebugMethods()
|
|
49
|
+
// }
|
|
40
50
|
|
|
41
51
|
// if (!AMQP_MANAGER_URL) {
|
|
42
52
|
// console.error('AMQP_MANAGER_URL is undefined. Logger not available...');
|
|
@@ -68,27 +78,29 @@ class Logger {
|
|
|
68
78
|
|
|
69
79
|
base(level, text) {
|
|
70
80
|
if (!this.request_id || !publisher) {
|
|
71
|
-
|
|
81
|
+
console.log("Return because request or publisher is undefined", this.request_id, publisher);
|
|
72
82
|
return;
|
|
73
83
|
}
|
|
74
84
|
|
|
75
85
|
let data = {
|
|
76
86
|
request_id: this.request_id,
|
|
87
|
+
id_project: this.request_id.split("-")[2],
|
|
77
88
|
text: text,
|
|
78
89
|
level: level,
|
|
90
|
+
nlevel: levels[level],
|
|
79
91
|
timestamp: new Date(),
|
|
80
92
|
dev: this.dev
|
|
81
93
|
}
|
|
82
94
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
95
|
+
let topic = LOGS_BASE_ROUTING_KEY + `.${this.request_id}`;
|
|
96
|
+
console.log("LOGGER publishing on topic ", topic)
|
|
97
|
+
publisher.publish(data, topic);
|
|
98
|
+
return;
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
formatLog(args) {
|
|
90
102
|
return args
|
|
91
|
-
.map(arg => (typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg
|
|
103
|
+
.map(arg => (typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg))
|
|
92
104
|
.join(" ")
|
|
93
105
|
}
|
|
94
106
|
|
|
@@ -96,9 +108,14 @@ class Logger {
|
|
|
96
108
|
_disableMethods() {
|
|
97
109
|
const methods = ['error', 'warn', 'info', 'debug'];
|
|
98
110
|
methods.forEach(method => {
|
|
99
|
-
|
|
111
|
+
this[method] = () => { };
|
|
100
112
|
});
|
|
101
|
-
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
_disableDebugMethods() {
|
|
116
|
+
const method = 'debug';
|
|
117
|
+
this[method] = () => { };
|
|
118
|
+
}
|
|
102
119
|
|
|
103
120
|
}
|
|
104
121
|
|
package/engine/IntentForm.js
CHANGED
|
@@ -11,7 +11,6 @@ class IntentForm {
|
|
|
11
11
|
this.form = options.form;
|
|
12
12
|
this.CURRENT_FIELD_INDEX_KEY = "tilebot:requests:" + this.requestId + ":currentFieldIndex"
|
|
13
13
|
this.CURRENT_FORM_KEY = "tilebot:requests:" + this.requestId + ":currentForm"
|
|
14
|
-
this.log = options.log;
|
|
15
14
|
this.requestParameters = options.requestParameters;
|
|
16
15
|
}
|
|
17
16
|
|
|
@@ -4,7 +4,7 @@ const winston = require('../utils/winston.js')
|
|
|
4
4
|
|
|
5
5
|
class IntentsMachineFactory {
|
|
6
6
|
|
|
7
|
-
static getMachine(bot, botId, projectId
|
|
7
|
+
static getMachine(bot, botId, projectId) {
|
|
8
8
|
let machine;
|
|
9
9
|
if (bot && bot.intentsEngine === "tiledesk-ai") {
|
|
10
10
|
winston.verbose("(IntentsMachineFactory) bot.intentsEngine is tiledesk-ai");
|
|
@@ -15,7 +15,7 @@ class IntentsMachineFactory {
|
|
|
15
15
|
}
|
|
16
16
|
else if (bot) {
|
|
17
17
|
winston.verbose("(IntentsMachineFactory) Setting MongodbIntentsMachine with bot:", JSON.stringify(bot));
|
|
18
|
-
machine = new MongodbIntentsMachine({projectId: projectId, language: bot.language
|
|
18
|
+
machine = new MongodbIntentsMachine({projectId: projectId, language: bot.language});
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
winston.error("bot is null for: " + botId + " on projectId: " + projectId);
|
|
@@ -23,10 +23,10 @@ class IntentsMachineFactory {
|
|
|
23
23
|
return machine;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
static getBackupMachine(bot, botId, projectId
|
|
26
|
+
static getBackupMachine(bot, botId, projectId) {
|
|
27
27
|
let machine;
|
|
28
28
|
winston.verbose("(IntentsMachineFactory) Setting MongodbIntentsMachine as Backup Intents Machine on bot:", JSON.stringify(bot));
|
|
29
|
-
machine = new MongodbIntentsMachine({projectId: projectId, language: bot.language
|
|
29
|
+
machine = new MongodbIntentsMachine({projectId: projectId, language: bot.language});
|
|
30
30
|
return machine;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// let Faq = require('./faq');
|
|
2
2
|
// let Faq_kb = require('./faq_kb');
|
|
3
|
-
// const { DirectivesChatbotPlug } = require('../tiledeskChatbotPlugs/DirectivesChatbotPlug');
|
|
4
3
|
const { MessagePipeline } = require('../tiledeskChatbotPlugs/MessagePipeline');
|
|
5
4
|
const { WebhookChatbotPlug } = require('../tiledeskChatbotPlugs/WebhookChatbotPlug');
|
|
6
5
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
@@ -41,7 +40,6 @@ class TiledeskChatbot {
|
|
|
41
40
|
this.projectId = config.projectId;
|
|
42
41
|
this.MAX_STEPS = config.MAX_STEPS;
|
|
43
42
|
this.MAX_EXECUTION_TIME = config.MAX_EXECUTION_TIME;
|
|
44
|
-
this.log = config.log;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
async replyToMessage(message, callback) {
|
|
@@ -72,13 +70,13 @@ class TiledeskChatbot {
|
|
|
72
70
|
winston.verbose("(TiledeskChatbot) Resetting current step by request message: " + message.text);
|
|
73
71
|
await TiledeskChatbot.resetStep(this.tdcache, this.requestId);
|
|
74
72
|
await TiledeskChatbot.resetStarted(this.tdcache, this.requestId);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
73
|
+
|
|
74
|
+
if (this.tdcache) {
|
|
75
|
+
let currentStep =
|
|
76
|
+
await TiledeskChatbot.currentStep(this.tdcache, this.requestId);
|
|
77
|
+
winston.verbose("(TiledeskChatbot) After reset currentStep:" + currentStep);
|
|
81
78
|
}
|
|
79
|
+
|
|
82
80
|
}
|
|
83
81
|
} catch(error) {
|
|
84
82
|
winston.error("(TiledeskChatbot) Error resetting locked intent: ", error);
|
|
@@ -93,8 +91,7 @@ class TiledeskChatbot {
|
|
|
93
91
|
// projectId: this.projectId,
|
|
94
92
|
// token: this.token,
|
|
95
93
|
// APIURL: this.APIURL,
|
|
96
|
-
// APIKEY: this.APIKEY
|
|
97
|
-
// log: false
|
|
94
|
+
// APIKEY: this.APIKEY
|
|
98
95
|
// });
|
|
99
96
|
// it only gets the locked_intent
|
|
100
97
|
// const faq = await this.botsDataSource.getByIntentDisplayName(this.botId, locked_intent);
|
|
@@ -506,7 +503,7 @@ class TiledeskChatbot {
|
|
|
506
503
|
TiledeskChatbot.requestCacheKey(requestId) + ":parameters", paramName);
|
|
507
504
|
}
|
|
508
505
|
|
|
509
|
-
static async checkStep(_tdcache, requestId, max_steps, max_execution_time
|
|
506
|
+
static async checkStep(_tdcache, requestId, max_steps, max_execution_time) {
|
|
510
507
|
winston.verbose("(TiledeskChatbot) Checking on MAX_STEPS: " + max_steps);
|
|
511
508
|
// let go_on = true; // continue
|
|
512
509
|
const parameter_key = TiledeskChatbot.requestCacheKey(requestId) + ":step";
|
|
@@ -579,7 +576,7 @@ class TiledeskChatbot {
|
|
|
579
576
|
}
|
|
580
577
|
const messagePipeline = new MessagePipeline(static_bot_answer, context);
|
|
581
578
|
const webhookurl = bot.webhook_url;
|
|
582
|
-
messagePipeline.addPlug(new WebhookChatbotPlug(userMessage.request, webhookurl, this.token
|
|
579
|
+
messagePipeline.addPlug(new WebhookChatbotPlug(userMessage.request, webhookurl, this.token));
|
|
583
580
|
const bot_answer = await messagePipeline.exec();
|
|
584
581
|
return bot_answer;
|
|
585
582
|
}
|
|
@@ -592,8 +589,7 @@ class TiledeskChatbot {
|
|
|
592
589
|
form: form,
|
|
593
590
|
requestId: this.requestId,
|
|
594
591
|
chatbot: this,
|
|
595
|
-
requestParameters: all_parameters
|
|
596
|
-
log: this.log
|
|
592
|
+
requestParameters: all_parameters
|
|
597
593
|
});
|
|
598
594
|
let message = await intentForm.getMessage(userInputReply);
|
|
599
595
|
return message;
|
|
@@ -610,8 +606,7 @@ class TiledeskChatbot {
|
|
|
610
606
|
projectId: this.projectId,
|
|
611
607
|
token: this.token,
|
|
612
608
|
APIURL: this.APIURL,
|
|
613
|
-
APIKEY: this.APIKEY
|
|
614
|
-
log: this.log
|
|
609
|
+
APIKEY: this.APIKEY
|
|
615
610
|
});
|
|
616
611
|
// const parameters_key = "tilebot:requests:" + requestId + ":parameters";
|
|
617
612
|
const all_parameters = await this.allParameters();//this.tdcache.hgetall(parameters_key);
|
|
@@ -12,7 +12,6 @@ class TiledeskIntentsMachine {
|
|
|
12
12
|
else {
|
|
13
13
|
this.API_ENDPOINT = config.API_ENDPOINT;
|
|
14
14
|
}
|
|
15
|
-
this.log = config.log;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
/**
|
|
@@ -93,7 +92,7 @@ class TiledeskIntentsMachine {
|
|
|
93
92
|
return tiledesk_intents;
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
myrequest(options, callback
|
|
95
|
+
myrequest(options, callback) {
|
|
97
96
|
axios(
|
|
98
97
|
{
|
|
99
98
|
url: options.url,
|
package/index.js
CHANGED
|
@@ -18,7 +18,6 @@ let axios = require('axios');
|
|
|
18
18
|
router.use(bodyParser.json({limit: '50mb'}));
|
|
19
19
|
router.use(bodyParser.urlencoded({ extended: true , limit: '50mb'}));
|
|
20
20
|
|
|
21
|
-
let log = false;
|
|
22
21
|
/** @type {TdCache} */
|
|
23
22
|
let tdcache = null;
|
|
24
23
|
let MAX_STEPS = 1000;
|
|
@@ -66,20 +65,7 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
66
65
|
message.request.id_project = projectId;
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
let aiService = new AiService({
|
|
71
|
-
API_ENDPOINT: API_ENDPOINT,
|
|
72
|
-
TOKEN: token,
|
|
73
|
-
PROJECT_ID: projectId
|
|
74
|
-
})
|
|
75
|
-
let isAudio = TiledeskChatbotUtil.isAudioMessage(message)
|
|
76
|
-
if(isAudio){
|
|
77
|
-
let responseText = await aiService.speechToText(message.metadata.src).catch(err => {
|
|
78
|
-
winston.error('(index.js) aiService.speechToText error: ', err)
|
|
79
|
-
})
|
|
80
|
-
if(responseText && responseText.text)
|
|
81
|
-
message.text = responseText.text
|
|
82
|
-
}
|
|
68
|
+
|
|
83
69
|
|
|
84
70
|
// validate reuqestId
|
|
85
71
|
let isValid = TiledeskChatbotUtil.validateRequestId(requestId, projectId);
|
|
@@ -100,7 +86,7 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
100
86
|
|
|
101
87
|
let botsDS;
|
|
102
88
|
if (!staticBots) {
|
|
103
|
-
botsDS = new MongodbBotsDataSource({projectId: projectId, botId: botId
|
|
89
|
+
botsDS = new MongodbBotsDataSource({projectId: projectId, botId: botId});
|
|
104
90
|
winston.verbose("(tybotRoute) botsDS created with Mongo");
|
|
105
91
|
}
|
|
106
92
|
else {
|
|
@@ -112,12 +98,15 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
112
98
|
Promise.reject(err);
|
|
113
99
|
return;
|
|
114
100
|
});
|
|
101
|
+
|
|
102
|
+
winston.debug("(tybotRoute) Bot found: ", bot)
|
|
103
|
+
|
|
115
104
|
|
|
116
105
|
let intentsMachine;
|
|
117
106
|
let backupMachine;
|
|
118
107
|
if (!staticBots) {
|
|
119
|
-
intentsMachine = IntentsMachineFactory.getMachine(bot, botId, projectId
|
|
120
|
-
backupMachine = IntentsMachineFactory.getBackupMachine(bot, botId, projectId
|
|
108
|
+
intentsMachine = IntentsMachineFactory.getMachine(bot, botId, projectId);
|
|
109
|
+
backupMachine = IntentsMachineFactory.getBackupMachine(bot, botId, projectId);
|
|
121
110
|
winston.debug("(tybotRoute) Created backupMachine:", backupMachine)
|
|
122
111
|
}
|
|
123
112
|
else {
|
|
@@ -137,8 +126,7 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
137
126
|
requestId: requestId,
|
|
138
127
|
projectId: projectId,
|
|
139
128
|
MAX_STEPS: MAX_STEPS,
|
|
140
|
-
MAX_EXECUTION_TIME: MAX_EXECUTION_TIME
|
|
141
|
-
log: log
|
|
129
|
+
MAX_EXECUTION_TIME: MAX_EXECUTION_TIME
|
|
142
130
|
});
|
|
143
131
|
winston.verbose("(tybotRoute) Message text: " + message.text)
|
|
144
132
|
|
|
@@ -175,7 +163,6 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
175
163
|
API_ENDPOINT: API_ENDPOINT,
|
|
176
164
|
TILEBOT_ENDPOINT:TILEBOT_ENDPOINT,
|
|
177
165
|
token: token,
|
|
178
|
-
log: log,
|
|
179
166
|
// HELP_CENTER_API_ENDPOINT: process.env.HELP_CENTER_API_ENDPOINT,
|
|
180
167
|
cache: tdcache
|
|
181
168
|
}
|
|
@@ -200,8 +187,7 @@ router.post('/ext/:botid', async (req, res) => {
|
|
|
200
187
|
reply.attributes.fillParams = true;
|
|
201
188
|
|
|
202
189
|
const apiext = new ExtApi({
|
|
203
|
-
TILEBOT_ENDPOINT: TILEBOT_ENDPOINT
|
|
204
|
-
log: false
|
|
190
|
+
TILEBOT_ENDPOINT: TILEBOT_ENDPOINT
|
|
205
191
|
});
|
|
206
192
|
apiext.sendSupportMessageExt(reply, projectId, requestId, token, () => {
|
|
207
193
|
winston.verbose("(tybotRoute) sendSupportMessageExt reply sent: ", reply)
|
|
@@ -228,8 +214,7 @@ router.post('/ext/:projectId/requests/:requestId/messages', async (req, res) =>
|
|
|
228
214
|
projectId: projectId,
|
|
229
215
|
token: token,
|
|
230
216
|
APIURL: API_ENDPOINT,
|
|
231
|
-
APIKEY: "___"
|
|
232
|
-
log: false
|
|
217
|
+
APIKEY: "___"
|
|
233
218
|
});
|
|
234
219
|
|
|
235
220
|
let request;
|
|
@@ -255,10 +240,10 @@ router.post('/ext/:projectId/requests/:requestId/messages', async (req, res) =>
|
|
|
255
240
|
winston.debug("(tybotRoute) API_ENDPOINT: " + API_ENDPOINT);
|
|
256
241
|
winston.debug("(tybotRoute) request: " + TILEBOT_ENDPOINT);
|
|
257
242
|
|
|
258
|
-
let directivesPlug = new DirectivesChatbotPlug({supportRequest: request, API_ENDPOINT: API_ENDPOINT, TILEBOT_ENDPOINT: TILEBOT_ENDPOINT, token: token,
|
|
243
|
+
let directivesPlug = new DirectivesChatbotPlug({supportRequest: request, API_ENDPOINT: API_ENDPOINT, TILEBOT_ENDPOINT: TILEBOT_ENDPOINT, token: token, HELP_CENTER_API_ENDPOINT: process.env.HELP_CENTER_API_ENDPOINT, cache: tdcache});
|
|
259
244
|
|
|
260
245
|
const original_answer_text = answer.text;
|
|
261
|
-
const bot_answer = await ExtUtil.execPipelineExt(request, answer, directivesPlug, tdcache
|
|
246
|
+
const bot_answer = await ExtUtil.execPipelineExt(request, answer, directivesPlug, tdcache);
|
|
262
247
|
winston.debug("(tybotRoute) bot_answer: ", bot_answer);
|
|
263
248
|
|
|
264
249
|
if (bot_answer) {
|
|
@@ -381,8 +366,7 @@ router.post('/echobot', (req, res) => {
|
|
|
381
366
|
projectId: projectId,
|
|
382
367
|
token: token,
|
|
383
368
|
APIURL: API_ENDPOINT,
|
|
384
|
-
APIKEY: "___"
|
|
385
|
-
log: false
|
|
369
|
+
APIKEY: "___"
|
|
386
370
|
});
|
|
387
371
|
|
|
388
372
|
// instantly reply "success" to TILEDESK
|
|
@@ -415,8 +399,14 @@ router.post('/block/:project_id/:bot_id/:block_id', async (req, res) => {
|
|
|
415
399
|
|
|
416
400
|
// invoke block
|
|
417
401
|
// unique ID for each execution
|
|
418
|
-
|
|
419
|
-
|
|
402
|
+
let request_id;
|
|
403
|
+
if (body.preloaded_request_id) {
|
|
404
|
+
request_id = body.preloaded_request_id;
|
|
405
|
+
} else {
|
|
406
|
+
const execution_id = uuidv4().replace(/-/g, '');
|
|
407
|
+
request_id = "automation-request-" + project_id + "-" + execution_id;
|
|
408
|
+
|
|
409
|
+
}
|
|
420
410
|
const command = "/#" + block_id;
|
|
421
411
|
let message = {
|
|
422
412
|
payload: {
|
|
@@ -510,13 +500,7 @@ async function startApp(settings, completionCallback) {
|
|
|
510
500
|
});
|
|
511
501
|
}
|
|
512
502
|
|
|
513
|
-
|
|
514
|
-
log = false;
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
log = true;
|
|
518
|
-
}
|
|
519
|
-
winston.info("(Tilebot) Log: " + log);
|
|
503
|
+
winston.info("(Tilebot) Log Level: " + process.env.LOG_LEVEL);
|
|
520
504
|
|
|
521
505
|
if (process.env.CHATBOT_MAX_STEPS) {
|
|
522
506
|
MAX_STEPS = Number(process.env.CHATBOT_MAX_STEPS);
|
|
@@ -595,7 +579,7 @@ async function checkRequest(request_id, id_project) {
|
|
|
595
579
|
// WARNING! Move this function in models/TiledeskChatbotUtil.js
|
|
596
580
|
}
|
|
597
581
|
|
|
598
|
-
function myrequest(options, callback
|
|
582
|
+
function myrequest(options, callback) {
|
|
599
583
|
winston.verbose("(tybotRoute) myrequest API URL:" + options.url);
|
|
600
584
|
winston.debug("(tybotRoute) myrequest Options:", options);
|
|
601
585
|
|