@tiledesk/tiledesk-tybot-connector 0.2.77 → 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,9 @@
|
|
|
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
|
+
|
|
8
11
|
# v0.2.77 - dev
|
|
9
12
|
- Fix. get images and urls. image URL was Wrongly removed after the upload message
|
|
10
13
|
|
|
@@ -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);
|