@tiledesk/tiledesk-tybot-connector 3.0.0 → 3.0.2
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/TiledeskExpression.js +3 -1
- package/engine/TiledeskChatbot.js +23 -1
- package/index.js +5 -2
- package/logs/app1.log +6267 -0
- package/package.json +22 -21
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +8 -2
- package/tiledeskChatbotPlugs/directives/DirAiCondition.js +14 -10
- package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +5 -5
- package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +36 -11
- package/tiledeskChatbotPlugs/directives/DirDocparseExtract.js +166 -48
- package/tiledeskChatbotPlugs/directives/DirInviteHuman.js +259 -0
- package/tiledeskChatbotPlugs/directives/DirIteration.js +3 -3
- package/tiledeskChatbotPlugs/directives/DirJSONConditionMulti.js +171 -0
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +40 -2
- package/tiledeskChatbotPlugs/directives/DirRemoveHuman.js +129 -0
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +18 -3
- package/tiledeskChatbotPlugs/directives/Directives.js +3 -0
- package/utils/ConnectorsV3.js +3 -0
- package/utils/HttpUtils.js +15 -11
- package/utils/TiledeskChatbotUtil.js +4 -1
- package/utils/winston.js +80 -2
package/TiledeskExpression.js
CHANGED
|
@@ -140,7 +140,9 @@ class TiledeskExpression {
|
|
|
140
140
|
},
|
|
141
141
|
"endsWith": {
|
|
142
142
|
name: "endsWith",
|
|
143
|
-
|
|
143
|
+
// Case-insensitive (legacy behaviour kept). Null-safe: an undefined or null
|
|
144
|
+
// left operand is false, never the string "undefined".
|
|
145
|
+
applyPattern: "(#1)?.toString().toLowerCase().endsWith((#2)?.toString().toLowerCase()) ?? false"
|
|
144
146
|
},
|
|
145
147
|
"isEmpty": {
|
|
146
148
|
name: "isEmpty",
|
|
@@ -97,7 +97,7 @@ class TiledeskChatbot {
|
|
|
97
97
|
// Checking locked intent (for non-internal intents)
|
|
98
98
|
// internal intents always "skip" the locked intent
|
|
99
99
|
const locked_intent = await this.currentLockedIntent(this.requestId);
|
|
100
|
-
if (locked_intent) {
|
|
100
|
+
if (locked_intent && message.sender !== "_tdinternal") {
|
|
101
101
|
// const tdclient = new TiledeskClient({
|
|
102
102
|
// projectId: this.projectId,
|
|
103
103
|
// token: this.token,
|
|
@@ -180,6 +180,28 @@ class TiledeskChatbot {
|
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
+
else if (message.text === '/start' && intent.name !== 'start') {
|
|
184
|
+
// A /start naming a missing start box falls back to the default start block
|
|
185
|
+
winston.warn("(TiledeskChatbot) Start box not found: " + explicit_intent_name + ", falling back to start");
|
|
186
|
+
const startFaq = await this.botsDataSource.getByIntentDisplayNameCache(this.botId, 'start', this.tdcache);
|
|
187
|
+
if (startFaq) {
|
|
188
|
+
try {
|
|
189
|
+
reply = await this.execIntent(startFaq, message, lead, { match_type: 'explicit' });
|
|
190
|
+
resolve(reply);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
catch(error) {
|
|
194
|
+
winston.error("(TiledeskChatbot) Error executing start fallback: ", error);
|
|
195
|
+
reject(error);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
winston.verbose("(TiledeskChatbot) Start box not found either");
|
|
201
|
+
resolve();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
183
205
|
else {
|
|
184
206
|
winston.info("(TiledeskChatbot) explicit intent not found, stop " + JSON.stringify({
|
|
185
207
|
botId: this.botId,
|
package/index.js
CHANGED
|
@@ -37,6 +37,7 @@ const { TiledeskChatbotUtil } = require('./utils/TiledeskChatbotUtil.js'); //req
|
|
|
37
37
|
|
|
38
38
|
const AiService = require('./services/AIService.js');
|
|
39
39
|
const tilebotService = require('./services/TilebotService.js');
|
|
40
|
+
const HttpUtils = require('./utils/HttpUtils').constructor; // module exports an instance; errorSummary is static
|
|
40
41
|
|
|
41
42
|
let API_ENDPOINT = null;
|
|
42
43
|
let TILEBOT_ENDPOINT = null;
|
|
@@ -627,8 +628,10 @@ router.post('/block/:project_id/:bot_id/:block_id', async (req, res) => {
|
|
|
627
628
|
winston.verbose("Async webhook");
|
|
628
629
|
tilebotService.sendMessageToBot(message, bot_id, (err, resbody) => {
|
|
629
630
|
if (err) {
|
|
630
|
-
|
|
631
|
-
|
|
631
|
+
// never log or return the raw error: it carries request headers/body (bot token)
|
|
632
|
+
const extUrl = `${process.env.TILEBOT_ENDPOINT || `${process.env.API_ENDPOINT}/modules/tilebot`}/ext/${bot_id}`;
|
|
633
|
+
winston.error("Async webhook err:", HttpUtils.errorSummary(err, extUrl));
|
|
634
|
+
return res.status(500).send({ success: false, error: (err && err.message) || 'Error sending the message to the chatbot' });
|
|
632
635
|
}
|
|
633
636
|
return res.status(200).send({ success: true });
|
|
634
637
|
})
|