@tiledesk/tiledesk-tybot-connector 0.2.75 → 0.2.77
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 +6 -0
- package/models/TiledeskChatbotUtil.js +46 -21
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
available on:
|
|
6
6
|
▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
|
|
7
7
|
|
|
8
|
+
# v0.2.77 - dev
|
|
9
|
+
- Fix. get images and urls. image URL was Wrongly removed after the upload message
|
|
10
|
+
|
|
11
|
+
# v0.2.76 - dev
|
|
12
|
+
- Added support to button alias
|
|
13
|
+
|
|
8
14
|
# v0.2.75 - dev
|
|
9
15
|
- Fix. get images and urls also without text
|
|
10
16
|
- "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?
|
|
@@ -526,20 +551,20 @@ class TiledeskChatbotUtil {
|
|
|
526
551
|
// "width": 1724
|
|
527
552
|
// }
|
|
528
553
|
if (message.metadata.src) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
554
|
+
await chatbot.addParameter("lastUserImageURL", message.metadata.src);
|
|
555
|
+
await chatbot.addParameter("lastUserImageName", message.metadata.name);
|
|
556
|
+
await chatbot.addParameter("lastUserImageWidth", message.metadata.width);
|
|
557
|
+
await chatbot.addParameter("lastUserImageHeight", message.metadata.height);
|
|
558
|
+
await chatbot.addParameter("lastUserImageType", message.metadata.type);
|
|
534
559
|
}
|
|
535
560
|
}
|
|
536
|
-
else {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
}
|
|
561
|
+
// else {
|
|
562
|
+
// await chatbot.addParameter("lastUserImageURL", null);
|
|
563
|
+
// await chatbot.addParameter("lastUserImageName", null);
|
|
564
|
+
// await chatbot.addParameter("lastUserImageWidth", null);
|
|
565
|
+
// await chatbot.addParameter("lastUserImageHeight", null);
|
|
566
|
+
// await chatbot.addParameter("lastUserImageType", null);
|
|
567
|
+
// }
|
|
543
568
|
// get document
|
|
544
569
|
if (message.type && message.type === "file" && message.metadata) {
|
|
545
570
|
// "type": "file",
|
|
@@ -563,11 +588,11 @@ class TiledeskChatbotUtil {
|
|
|
563
588
|
await chatbot.addParameter("lastUserDocumentType", message.metadata.type);
|
|
564
589
|
}
|
|
565
590
|
}
|
|
566
|
-
else {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
591
|
+
// else {
|
|
592
|
+
// await chatbot.addParameter("lastUserDocumentURL", null);
|
|
593
|
+
// await chatbot.addParameter("lastUserDocumentName", null);
|
|
594
|
+
// await chatbot.addParameter("lastUserDocumentType", null);
|
|
595
|
+
// }
|
|
571
596
|
if (message && message.request && message.request.lead) {
|
|
572
597
|
if (message.request.lead.email) {
|
|
573
598
|
await chatbot.addParameter("userEmail", message.request.lead.email);
|