@tiledesk/tiledesk-tybot-connector 0.2.76 → 0.2.78
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
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.78 - dev
|
|
9
|
+
- Fixed? Get DepartmentId for default department in test-mode in IfOnelineAgentsV2
|
|
10
|
+
|
|
11
|
+
# v0.2.77 - dev
|
|
12
|
+
- Fix. get images and urls. image URL was Wrongly removed after the upload message
|
|
13
|
+
|
|
8
14
|
# v0.2.76 - dev
|
|
9
15
|
- Added support to button alias
|
|
10
16
|
|
|
@@ -551,20 +551,20 @@ class TiledeskChatbotUtil {
|
|
|
551
551
|
// "width": 1724
|
|
552
552
|
// }
|
|
553
553
|
if (message.metadata.src) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
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);
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
|
-
else {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
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
|
+
// }
|
|
568
568
|
// get document
|
|
569
569
|
if (message.type && message.type === "file" && message.metadata) {
|
|
570
570
|
// "type": "file",
|
|
@@ -588,11 +588,11 @@ class TiledeskChatbotUtil {
|
|
|
588
588
|
await chatbot.addParameter("lastUserDocumentType", message.metadata.type);
|
|
589
589
|
}
|
|
590
590
|
}
|
|
591
|
-
else {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}
|
|
591
|
+
// else {
|
|
592
|
+
// await chatbot.addParameter("lastUserDocumentURL", null);
|
|
593
|
+
// await chatbot.addParameter("lastUserDocumentName", null);
|
|
594
|
+
// await chatbot.addParameter("lastUserDocumentType", null);
|
|
595
|
+
// }
|
|
596
596
|
if (message && message.request && message.request.lead) {
|
|
597
597
|
if (message.request.lead.email) {
|
|
598
598
|
await chatbot.addParameter("userEmail", message.request.lead.email);
|
|
@@ -678,6 +678,10 @@ class TiledeskChatbotUtil {
|
|
|
678
678
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_ID_KEY, message.request.department._id);
|
|
679
679
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_NAME_KEY, message.request.department.name);
|
|
680
680
|
}
|
|
681
|
+
else if (message.attributes && message.attributes.departmentId) {
|
|
682
|
+
await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_ID_KEY, message.attributes.departmentId);
|
|
683
|
+
await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_NAME_KEY, message.attributes.departmentName);
|
|
684
|
+
}
|
|
681
685
|
if (message && message.request && message.request.attributes && message.request.attributes.payload) {
|
|
682
686
|
if (!message.attributes) {
|
|
683
687
|
message.attributes = {}
|
|
@@ -686,7 +690,6 @@ class TiledeskChatbotUtil {
|
|
|
686
690
|
if (chatbot.log) {console.log("FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
|
|
687
691
|
// if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
|
|
688
692
|
}
|
|
689
|
-
|
|
690
693
|
if (message.attributes) {
|
|
691
694
|
if (chatbot.log) {console.log("Ok message.attributes", JSON.stringify(message.attributes));}
|
|
692
695
|
// if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > Ok message.attributes", JSON.stringify(message.attributes));}
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ const { rejects } = require('assert');
|
|
|
3
3
|
const { DirIntent } = require('./DirIntent');
|
|
4
4
|
const axios = require("axios").default;
|
|
5
5
|
let https = require("https");
|
|
6
|
+
const { TiledeskChatbot } = require('../../models/TiledeskChatbot');
|
|
6
7
|
|
|
7
8
|
class DirIfOnlineAgentsV2 {
|
|
8
9
|
|
|
@@ -57,17 +58,46 @@ class DirIfOnlineAgentsV2 {
|
|
|
57
58
|
|
|
58
59
|
let agents;
|
|
59
60
|
if (selectedOption === "currentDep") {
|
|
61
|
+
console.log("(DirIfOnlineAgents) currentDep");
|
|
60
62
|
let departmentId;
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
// let departmentId = await this.chatbot.getParameter("department_id");
|
|
64
|
+
// console.log("this.context.departmentId:", this.context.departmentId);
|
|
65
|
+
|
|
66
|
+
if (this.context.tdcache) {
|
|
67
|
+
let attributes =
|
|
68
|
+
await TiledeskChatbot.allParametersStatic(
|
|
69
|
+
this.context.tdcache, this.context.requestId
|
|
70
|
+
);
|
|
71
|
+
if (this.log) {console.log("Attributes:::", JSON.stringify(attributes))}
|
|
72
|
+
departmentId = attributes["department_id"];
|
|
73
|
+
if (this.log) {console.log("Attributes.departmentId:::", departmentId)}
|
|
64
74
|
}
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
|
|
76
|
+
// if (this.context.departmentId) {
|
|
77
|
+
// departmentId = this.context.departmentId;
|
|
78
|
+
// }
|
|
79
|
+
|
|
80
|
+
if (departmentId) {
|
|
81
|
+
// departmentId = this.context.departmentId;
|
|
82
|
+
// if (this.log) {console.log("(DirIfOnlineAgents) selectedOption === currentDep. Current department:", departmentId, typeof(departmentId)); }
|
|
83
|
+
agents = await this.getDepartmentAvailableAgents(departmentId);
|
|
84
|
+
if (this.log) {console.log("(DirIfOnlineAgents) agents:", agents); }
|
|
85
|
+
} else {
|
|
86
|
+
console.error("(DirIfOnlineAgents) no departmentId found in attributes");
|
|
87
|
+
await this.chatbot.addParameter("flowError", "(If online Agents) No departmentId found in attributes.");
|
|
88
|
+
if (this.log) {console.log("(DirIfOnlineAgents) flowError added in attributes", await this.chatbot.getParameter("flowError") ); }
|
|
89
|
+
if (falseIntent) { // no agents available
|
|
90
|
+
let intentDirective = DirIntent.intentDirectiveFor(falseIntent, falseIntentAttributes);
|
|
91
|
+
this.intentDir.execute(intentDirective, () => {
|
|
92
|
+
callback(stopOnConditionMet);
|
|
93
|
+
});
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
callback(false);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
67
100
|
}
|
|
68
|
-
if (this.log) {console.log("(DirIfOnlineAgents) selectedOption === currentDep. Current department:", departmentId); }
|
|
69
|
-
agents = await this.getDepartmentAvailableAgents(departmentId);
|
|
70
|
-
if (this.log) {console.log("(DirIfOnlineAgents) agents:", agents); }
|
|
71
101
|
}
|
|
72
102
|
else if (selectedOption === "selectedDep") {
|
|
73
103
|
if (this.log) {console.log("(DirIfOnlineAgents) selectedOption === selectedDep", action.selectedDepartmentId); }
|
|
@@ -80,6 +110,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
80
110
|
if (this.log) {console.log("(DirIfOnlineAgents) agents:", agents); }
|
|
81
111
|
}
|
|
82
112
|
|
|
113
|
+
console.log("anyway qui...");
|
|
83
114
|
if (agents && agents.length > 0) {
|
|
84
115
|
if (trueIntent) {
|
|
85
116
|
let intentDirective = DirIntent.intentDirectiveFor(trueIntent, trueIntentAttributes);
|