@tiledesk/tiledesk-tybot-connector 2.0.26-rc1 → 2.0.27-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 +8 -0
- package/logs/app1.log +1913 -0
- package/package.json +1 -1
- package/services/LLMService.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +14 -5
- package/tiledeskChatbotPlugs/directives/DirReply.js +1 -0
- package/utils/TiledeskChatbotUtil.js +6 -14
- package/utils/constants.js +17 -0
package/package.json
CHANGED
package/services/LLMService.js
CHANGED
|
@@ -522,10 +522,10 @@ class DirAskGPTV2 {
|
|
|
522
522
|
return new Promise((resolve) => {
|
|
523
523
|
let engine = {
|
|
524
524
|
name: "pinecone",
|
|
525
|
-
type: isHybrid ? "serverless" :
|
|
525
|
+
type: isHybrid ? "serverless" : process.env.PINECONE_TYPE,
|
|
526
526
|
apikey: "",
|
|
527
527
|
vector_size: 1536,
|
|
528
|
-
index_name: isHybrid ?
|
|
528
|
+
index_name: isHybrid ? process.env.PINECONE_INDEX_HYBRID : process.env.PINECONE_INDEX
|
|
529
529
|
}
|
|
530
530
|
resolve(engine);
|
|
531
531
|
})
|
|
@@ -61,15 +61,24 @@ class DirContactUpdate {
|
|
|
61
61
|
}
|
|
62
62
|
const filler = new Filler();
|
|
63
63
|
let updateProperties = {}
|
|
64
|
+
|
|
65
|
+
//map the key from the action to the chatbot const variable key
|
|
66
|
+
const keyToChatbotConstMap = {
|
|
67
|
+
fullname: TiledeskChatbotConst.REQ_LEAD_USERFULLNAME_KEY,
|
|
68
|
+
email: TiledeskChatbotConst.REQ_LEAD_EMAIL_KEY,
|
|
69
|
+
phone: TiledeskChatbotConst.REQ_USER_PHONE_KEY,
|
|
70
|
+
currentPhoneNumber: TiledeskChatbotConst.REQ_CURRENT_PHONE_NUMBER_KEY,
|
|
71
|
+
userLeadId: TiledeskChatbotConst.REQ_USER_LEAD_ID_KEY,
|
|
72
|
+
company: TiledeskChatbotConst.REQ_USER_COMPANY_KEY
|
|
73
|
+
};
|
|
74
|
+
|
|
64
75
|
for (const [key, value] of Object.entries(contactProperties)) {
|
|
65
76
|
let filled_value = filler.fill(value, requestAttributes);
|
|
66
77
|
updateProperties[key] = filled_value;
|
|
67
78
|
// it's important that all the lead's properties are immediatly updated in the current flow invocation so the updated values will be available in the next actions
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
else if ( key === "email") {
|
|
72
|
-
await this.context.chatbot.addParameter(TiledeskChatbotConst.REQ_LEAD_EMAIL_KEY, filled_value);
|
|
79
|
+
const chatbotKey = keyToChatbotConstMap[key];
|
|
80
|
+
if (chatbotKey) {
|
|
81
|
+
await this.context.chatbot.addParameter(chatbotKey, filled_value);
|
|
73
82
|
}
|
|
74
83
|
}
|
|
75
84
|
const leadId = requestAttributes[TiledeskChatbotConst.REQ_USER_LEAD_ID_KEY];
|
|
@@ -8,6 +8,8 @@ require('dotenv').config();
|
|
|
8
8
|
let axios = require('axios');
|
|
9
9
|
const winston = require('./winston');
|
|
10
10
|
|
|
11
|
+
const { CHANNEL_NAME } = require('./constants.js')
|
|
12
|
+
|
|
11
13
|
class TiledeskChatbotUtil {
|
|
12
14
|
|
|
13
15
|
static parseIntent(explicit_intent_name) {
|
|
@@ -305,9 +307,7 @@ class TiledeskChatbotUtil {
|
|
|
305
307
|
let command = commands[i];
|
|
306
308
|
if (command.type === 'message' && command.message) {
|
|
307
309
|
if (command.message.attributes && command.message.attributes.attachment && command.message.attributes.attachment.json_buttons){
|
|
308
|
-
// console.log("command with buttons ok:")
|
|
309
310
|
let json_buttons_string = command.message.attributes.attachment.json_buttons;
|
|
310
|
-
console.log("json_buttons_string:", json_buttons_string)
|
|
311
311
|
let final_buttons = this.renderJSONButtons(json_buttons_string, flow_attributes);
|
|
312
312
|
// let final_buttons = [];
|
|
313
313
|
// try {
|
|
@@ -430,36 +430,27 @@ class TiledeskChatbotUtil {
|
|
|
430
430
|
}
|
|
431
431
|
|
|
432
432
|
static replaceJSONGalleries(message, flow_attributes) {
|
|
433
|
-
console.log("replaceJSONGalleries...");
|
|
434
433
|
if (message.attributes && message.attributes.commands) {
|
|
435
|
-
console.log("message.attributes && message.attributes.commands...");
|
|
436
434
|
let commands = message.attributes.commands;
|
|
437
435
|
if (commands.length > 0) {
|
|
438
|
-
console.log("commands.length > 0");
|
|
439
436
|
for (let i = 0; i < commands.length; i++) {
|
|
440
437
|
let command = commands[i];
|
|
441
|
-
console.log("command:", JSON.stringify(command));
|
|
442
438
|
if (command.type === 'message' && command.message) {
|
|
443
|
-
console.log("command.type === 'message' && command.message");
|
|
444
439
|
if (command.message.attributes && command.message.attributes.attachment && command.message.attributes.attachment.json_gallery){
|
|
445
|
-
console.log("command with json_galley")
|
|
446
440
|
let final_gallery = [];
|
|
447
441
|
try {
|
|
448
442
|
// fill previews
|
|
449
443
|
const filler = new Filler();
|
|
450
444
|
let json_gallery_string = command.message.attributes.attachment.json_gallery;
|
|
451
|
-
console.log("gallerystring is:", json_gallery_string)
|
|
452
445
|
json_gallery_string = filler.fill(json_gallery_string, flow_attributes);
|
|
453
446
|
let json_gallery = JSON.parse(json_gallery_string);
|
|
454
447
|
if (Array.isArray(json_gallery)) {
|
|
455
|
-
console.log("is gallery")
|
|
456
448
|
json_gallery.forEach(el => {
|
|
457
449
|
if (el.buttons) {
|
|
458
450
|
el.buttons = TiledeskChatbotUtil.renderJSONButtons(JSON.stringify(el.buttons));
|
|
459
451
|
}
|
|
460
452
|
final_gallery.push(el);
|
|
461
453
|
});
|
|
462
|
-
console.log("final: ", final_gallery)
|
|
463
454
|
}
|
|
464
455
|
else {
|
|
465
456
|
winston.verbose("Invalid json_gallery.");
|
|
@@ -530,9 +521,7 @@ class TiledeskChatbotUtil {
|
|
|
530
521
|
catch(error) {
|
|
531
522
|
winston.warn("Error on JSON gallery parsing:", error);
|
|
532
523
|
}
|
|
533
|
-
console.log("final gallery...", final_gallery)
|
|
534
524
|
if (final_gallery && final_gallery.length > 0) {
|
|
535
|
-
console.log("updating with final gallery...", final_gallery)
|
|
536
525
|
command.message.attributes.attachment.gallery = final_gallery;
|
|
537
526
|
delete command.message.attributes.attachment.json_gallery;
|
|
538
527
|
}
|
|
@@ -792,7 +781,10 @@ class TiledeskChatbotUtil {
|
|
|
792
781
|
if (message.request.lead.phone) {
|
|
793
782
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_USER_PHONE_KEY, message.request.lead.phone);
|
|
794
783
|
}
|
|
795
|
-
if (message.request.lead.lead_id && message.request.lead.lead_id.startsWith("wab-")
|
|
784
|
+
if (message.request.lead.lead_id && (message.request.lead.lead_id.startsWith("wab-") ||
|
|
785
|
+
message.request.lead.lead_id.startsWith("vxml-") ||
|
|
786
|
+
message.request.lead.lead_id.startsWith(CHANNEL_NAME.VOICE_TWILIO) ||
|
|
787
|
+
message.request.lead.lead_id.startsWith(CHANNEL_NAME.SMS))) {
|
|
796
788
|
const splits = message.request.lead.lead_id.split("-");
|
|
797
789
|
if (splits && splits.length > 1) {
|
|
798
790
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_CURRENT_PHONE_NUMBER_KEY,splits[1]);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
CHANNEL_NAME: {
|
|
4
|
+
SUPPORT_GROUP: 'support-group',
|
|
5
|
+
GROUP: 'group',
|
|
6
|
+
DIRECT: 'direct',
|
|
7
|
+
CHAT21: 'chat21',
|
|
8
|
+
EMAIL: 'email',
|
|
9
|
+
FORM:'form',
|
|
10
|
+
MESSENGER: 'messenger',
|
|
11
|
+
WHATSAPP: 'whatsapp',
|
|
12
|
+
TELEGRAM: 'telegram',
|
|
13
|
+
VOICE: 'voice-vxml',
|
|
14
|
+
VOICE_TWILIO: 'voice-twilio',
|
|
15
|
+
SMS_TWILIO: 'sms-twilio',
|
|
16
|
+
}
|
|
17
|
+
}
|