@tiledesk/tiledesk-tybot-connector 0.2.75 → 0.2.76
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/models/TiledeskChatbotUtil.js +29 -4
- package/package.json +1 -1
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
|
+
# v0.2.76 - dev
|
|
9
|
+
- Added support to button alias
|
|
10
|
+
|
|
8
11
|
# v0.2.75 - dev
|
|
9
12
|
- Fix. get images and urls also without text
|
|
10
13
|
- "userLeadId" = message.request.lead._id (instead of the unuseful lead.lead_id)
|
|
@@ -252,13 +252,13 @@ class TiledeskChatbotUtil {
|
|
|
252
252
|
if (commands[i].message) {
|
|
253
253
|
if (commands[i].message.type === "text") { // check text commands
|
|
254
254
|
if (( commands[i].message.text && commands[i].message.text.trim() === "") || !commands[i].message.text) {
|
|
255
|
-
console.log("deleting command:", commands[i]);
|
|
255
|
+
// console.log("deleting command:", commands[i]);
|
|
256
256
|
commands.splice(i, 1);
|
|
257
257
|
if (commands[i-1]) {
|
|
258
258
|
if (commands[i-1].type === "wait") {
|
|
259
259
|
commands.splice(i-1, 1);
|
|
260
260
|
i--;
|
|
261
|
-
console.log("deleted wait");
|
|
261
|
+
// console.log("deleted wait");
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
}
|
|
@@ -369,17 +369,42 @@ class TiledeskChatbotUtil {
|
|
|
369
369
|
if (buttons === null || text === null) {
|
|
370
370
|
return null;
|
|
371
371
|
}
|
|
372
|
-
let search_text = text.toLowerCase();
|
|
372
|
+
let search_text = text.toLowerCase().trim();
|
|
373
373
|
let selected_button = null;
|
|
374
374
|
for (let i = 0; i < buttons.length; i++) {
|
|
375
375
|
const button = buttons[i];
|
|
376
376
|
if (button.value !== null && button.value.toLowerCase() === search_text) {
|
|
377
377
|
selected_button = button;
|
|
378
|
-
break;
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
else if (button.alias && button.alias.trim() !== "") { // search in button alias
|
|
381
|
+
let alias = button.alias.split(",");
|
|
382
|
+
// console.log("alias splitted:", alias);
|
|
383
|
+
if (alias.length > 0) {
|
|
384
|
+
for (let ii = 0; ii < alias.length; ii++) {
|
|
385
|
+
alias[ii] = alias[ii].toLowerCase().trim();
|
|
386
|
+
}
|
|
387
|
+
// console.log("alias proc:", alias);
|
|
388
|
+
if (alias.indexOf(search_text) > -1) {
|
|
389
|
+
selected_button = button;
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
379
393
|
}
|
|
380
394
|
}
|
|
395
|
+
|
|
381
396
|
return selected_button;
|
|
382
397
|
}
|
|
398
|
+
|
|
399
|
+
static stripEmoji(str) {
|
|
400
|
+
// console.log("checking:", str);
|
|
401
|
+
if (str === null) {
|
|
402
|
+
return str;
|
|
403
|
+
}
|
|
404
|
+
return str.replace(/\p{Emoji}/gu, '')
|
|
405
|
+
.replace(/\s+/g, ' ')
|
|
406
|
+
.trim();
|
|
407
|
+
}
|
|
383
408
|
|
|
384
409
|
static async updateConversationTranscript(chatbot, message) {
|
|
385
410
|
if (!message || !message.senderFullname) { // not a conversation, can it be an Automation invocation?
|