@tiledesk/tiledesk-tybot-connector 0.2.131-rc4 → 0.2.131-rc5
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/package.json +1 -1
- package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirClose.js +2 -1
- package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirDepartment.js +3 -3
- package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirForm.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirIfOpenHours_OLD.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirRandomReply.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +2 -3
- package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +2 -2
- package/tiledeskChatbotPlugs/directives/DirReply.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirSendEmail.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +3 -3
package/package.json
CHANGED
|
@@ -67,7 +67,7 @@ class DirAssignFromFunction {
|
|
|
67
67
|
async invoke(functionName, callback) {
|
|
68
68
|
switch (functionName) {
|
|
69
69
|
case "openNow":
|
|
70
|
-
this.
|
|
70
|
+
this.tdClient.openNow((err, result) => {
|
|
71
71
|
if (this.log) {console.log("openNow():", result);}
|
|
72
72
|
if (err) {
|
|
73
73
|
callback(err);
|
|
@@ -81,7 +81,7 @@ class DirAssignFromFunction {
|
|
|
81
81
|
});
|
|
82
82
|
break;
|
|
83
83
|
case "availableAgents":
|
|
84
|
-
this.
|
|
84
|
+
this.tdClient.getProjectAvailableAgents((err, agents) => {
|
|
85
85
|
if (this.log) {console.log("Agents on 'open'", agents);}
|
|
86
86
|
if (err || !agents) {
|
|
87
87
|
console.error("Error getting available agents in DirWhenAvailableAgents", err);
|
|
@@ -14,6 +14,7 @@ class DirClose {
|
|
|
14
14
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
15
15
|
this.log = context.log;
|
|
16
16
|
|
|
17
|
+
console.log("this.context.projectId: ", context)
|
|
17
18
|
this.tdClient = new TiledeskClient({
|
|
18
19
|
projectId: this.context.projectId,
|
|
19
20
|
token: this.context.token,
|
|
@@ -24,7 +25,7 @@ class DirClose {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
execute(directive, callback) {
|
|
27
|
-
this.
|
|
28
|
+
this.tdClient.closeRequest(this.requestId, async (err) => {
|
|
28
29
|
if (err) {
|
|
29
30
|
console.error("Error in 'close directive':", err);
|
|
30
31
|
}
|
|
@@ -81,7 +81,7 @@ class DirContactUpdate {
|
|
|
81
81
|
if (this.log) {console.log("(DirContactUpdate) updating property:", key, "value:", filled_value); }
|
|
82
82
|
}
|
|
83
83
|
const leadId = requestAttributes[TiledeskChatbotConst.REQ_USER_LEAD_ID_KEY];
|
|
84
|
-
this.
|
|
84
|
+
this.tdClient.updateLead(leadId, updateProperties, null, null, () => {
|
|
85
85
|
if (this.log) {console.log("(DirContactUpdate) Lead updated.", updateProperties);}
|
|
86
86
|
// send hidden info to update widget lead fullname only if it is a conversation!
|
|
87
87
|
if (this.log) {console.log("(DirContactUpdate) requestId:", this.requestId); }
|
|
@@ -100,7 +100,7 @@ class DirContactUpdate {
|
|
|
100
100
|
// }
|
|
101
101
|
// };
|
|
102
102
|
// if (this.log) {console.log("(DirContactUpdate) sending updateLeadDataOnWidgetMessage:", updateLeadDataOnWidgetMessage); }
|
|
103
|
-
// this.
|
|
103
|
+
// this.tdClient.sendSupportMessage(
|
|
104
104
|
// this.requestId,
|
|
105
105
|
// updateLeadDataOnWidgetMessage,
|
|
106
106
|
// (err) => {
|
|
@@ -89,7 +89,7 @@ class DirDepartment {
|
|
|
89
89
|
subtype: "info"
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
this.
|
|
92
|
+
this.tdClient.sendSupportMessage(
|
|
93
93
|
this.requestId,
|
|
94
94
|
message, (err) => {
|
|
95
95
|
if (err) {
|
|
@@ -108,7 +108,7 @@ class DirDepartment {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
moveToDepartment(requestId, depName, callback) {
|
|
111
|
-
this.
|
|
111
|
+
this.tdClient.getAllDepartments((err, deps) => {
|
|
112
112
|
if (this.log) {console.log("deps:", JSON.stringify(deps));}
|
|
113
113
|
if (err) {
|
|
114
114
|
console.error("getAllDepartments() error:", err);
|
|
@@ -125,7 +125,7 @@ class DirDepartment {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
if (dep) {
|
|
128
|
-
this.
|
|
128
|
+
this.tdClient.updateRequestDepartment(requestId, dep._id, null, (err, res) => {
|
|
129
129
|
if (err) {
|
|
130
130
|
console.error("DirDepartment error:", err);
|
|
131
131
|
callback();
|
|
@@ -29,7 +29,7 @@ class DirFireTiledeskEvent {
|
|
|
29
29
|
name: event_name,
|
|
30
30
|
attributes: params.payload
|
|
31
31
|
}
|
|
32
|
-
this.
|
|
32
|
+
this.tdClient.fireEvent(event, function(err, result) {
|
|
33
33
|
if (err) {
|
|
34
34
|
console.error("An error occurred invoking an event:", err);
|
|
35
35
|
}
|
|
@@ -70,7 +70,7 @@ class DirIfOnlineAgents {
|
|
|
70
70
|
const trueIntentAttributes = action.trueIntentAttributes;
|
|
71
71
|
const falseIntentAttributes = action.falseIntentAttributes;
|
|
72
72
|
let stopOnConditionMet = action.stopOnConditionMet;
|
|
73
|
-
this.
|
|
73
|
+
this.tdClient.openNow((err, result) => {
|
|
74
74
|
if (this.log) {console.log("openNow():", result);}
|
|
75
75
|
if (err) {
|
|
76
76
|
console.error("IfOnlineAgents:tdclient.openNow Error:", err);
|
|
@@ -79,7 +79,7 @@ class DirIfOnlineAgents {
|
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
81
|
if (result && result.isopen) {
|
|
82
|
-
this.
|
|
82
|
+
this.tdClient.getProjectAvailableAgents((err, agents) => {
|
|
83
83
|
if (this.log) {console.log("Agents", agents);}
|
|
84
84
|
if (err) {
|
|
85
85
|
console.error("IfOnlineAgents:Error getting available agents:", err);
|
|
@@ -171,7 +171,7 @@ class DirIfOnlineAgentsV2 {
|
|
|
171
171
|
|
|
172
172
|
async openNow() {
|
|
173
173
|
return new Promise( (resolve, reject) => {
|
|
174
|
-
this.
|
|
174
|
+
this.tdClient.openNow(async (err, result) => {
|
|
175
175
|
if (this.log) {console.log("(DirIfOnlineAgents) openNow():", result);}
|
|
176
176
|
if (err) {
|
|
177
177
|
reject(err);
|
|
@@ -130,7 +130,7 @@ class DirIfOpenHours {
|
|
|
130
130
|
}
|
|
131
131
|
)
|
|
132
132
|
|
|
133
|
-
// this.
|
|
133
|
+
// this.tdClient.openNow(action.slot_id, (err, result) => {
|
|
134
134
|
// console.log("openNow():", result);
|
|
135
135
|
// if (this.log) {console.log("openNow():", result);}
|
|
136
136
|
// if (err) {
|
|
@@ -72,7 +72,7 @@ class DirIfOpenHours {
|
|
|
72
72
|
callback();
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
this.
|
|
75
|
+
this.tdClient.openNow((err, result) => {
|
|
76
76
|
if (this.log) {console.log("openNow():", result);}
|
|
77
77
|
if (err) {
|
|
78
78
|
console.error("*** DirIfOpenHours Error:", err);
|
|
@@ -45,7 +45,7 @@ class DirMoveToUnassigned {
|
|
|
45
45
|
|
|
46
46
|
async moveToUnassigned(requestId, callback) {
|
|
47
47
|
const empty_participants = [] // STATUS WILL MOVE AUTOMATICALLY TO UNASSIGNED (100)
|
|
48
|
-
this.
|
|
48
|
+
this.tdClient.updateRequestParticipants(requestId, empty_participants, (err) => {
|
|
49
49
|
if (callback) {
|
|
50
50
|
callback(err);
|
|
51
51
|
}
|
|
@@ -8,10 +8,9 @@ class DirRemoveCurrentBot {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
this.context = context;
|
|
11
|
-
this.tdclient = context.tdclient;
|
|
12
11
|
this.requestId = context.requestId;
|
|
13
|
-
|
|
14
12
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
13
|
+
|
|
15
14
|
this.tdClient = new TiledeskClient({
|
|
16
15
|
projectId: this.context.projectId,
|
|
17
16
|
token: this.context.token,
|
|
@@ -38,7 +37,7 @@ class DirRemoveCurrentBot {
|
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
go(action, callback) {
|
|
41
|
-
this.
|
|
40
|
+
this.tdClient.removeCurrentBot(this.requestId, (err) => {
|
|
42
41
|
callback();
|
|
43
42
|
});
|
|
44
43
|
}
|
|
@@ -51,7 +51,7 @@ class DirReplaceBot {
|
|
|
51
51
|
);
|
|
52
52
|
const filler = new Filler();
|
|
53
53
|
botName = filler.fill(botName, variables);
|
|
54
|
-
this.
|
|
54
|
+
this.tdClient.replaceBotByName(this.requestId, botName, () => {
|
|
55
55
|
callback();
|
|
56
56
|
});
|
|
57
57
|
}
|
|
@@ -52,7 +52,7 @@ class DirReplaceBotV2 {
|
|
|
52
52
|
);
|
|
53
53
|
const filler = new Filler();
|
|
54
54
|
botName = filler.fill(botName, variables);
|
|
55
|
-
this.
|
|
55
|
+
this.tdClient.replaceBotByName(this.requestId, botName, () => {
|
|
56
56
|
if (blockName) {
|
|
57
57
|
if (this.log) {console.log("Sending hidden /start message to bot in dept");}
|
|
58
58
|
const message = {
|
|
@@ -62,7 +62,7 @@ class DirReplaceBotV2 {
|
|
|
62
62
|
subtype: "info"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
this.
|
|
65
|
+
this.tdClient.sendSupportMessage(
|
|
66
66
|
this.requestId,
|
|
67
67
|
message, (err) => {
|
|
68
68
|
if (err) {
|
|
@@ -140,7 +140,7 @@ class DirReply {
|
|
|
140
140
|
if (this.log) {console.log("Reply:", JSON.stringify(cleanMessage))};
|
|
141
141
|
await TiledeskChatbotUtil.updateConversationTranscript(this.context.chatbot, cleanMessage);
|
|
142
142
|
// console.log("sending message!", cleanMessage);
|
|
143
|
-
this.
|
|
143
|
+
this.tdClient.sendSupportMessage(
|
|
144
144
|
this.requestId,
|
|
145
145
|
cleanMessage,
|
|
146
146
|
(err) => {
|
|
@@ -273,7 +273,7 @@ class DirReplyV2 {
|
|
|
273
273
|
cleanMessage.senderFullname = this.context.chatbot.bot.name;
|
|
274
274
|
if (this.log) {console.log("Reply:", JSON.stringify(cleanMessage))};
|
|
275
275
|
await TiledeskChatbotUtil.updateConversationTranscript(this.context.chatbot, cleanMessage);
|
|
276
|
-
this.
|
|
276
|
+
this.tdClient.sendSupportMessage(
|
|
277
277
|
this.requestId,
|
|
278
278
|
cleanMessage,
|
|
279
279
|
(err) => {
|
|
@@ -73,7 +73,7 @@ class DirSendEmail {
|
|
|
73
73
|
replyto: reply_to
|
|
74
74
|
}
|
|
75
75
|
// console.log("email message:", JSON.stringify(message));
|
|
76
|
-
const message_echo = await this.
|
|
76
|
+
const message_echo = await this.tdClient.sendEmail(message);
|
|
77
77
|
if (this.log) {console.log("email sent. filled_subject:", filled_subject);}
|
|
78
78
|
if (this.log) {console.log("email sent. filled_text:", filled_text);}
|
|
79
79
|
if (this.log) {console.log("email sent. filled_to:", filled_to);}
|
|
@@ -81,7 +81,7 @@ class DirSetConversationTags {
|
|
|
81
81
|
subtype: "info"
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
this.
|
|
84
|
+
this.tdClient.sendSupportMessage(
|
|
85
85
|
this.requestId,
|
|
86
86
|
message, (err) => {
|
|
87
87
|
if (err) {
|
|
@@ -100,7 +100,7 @@ class DirSetConversationTags {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
moveToDepartment(requestId, depName, callback) {
|
|
103
|
-
this.
|
|
103
|
+
this.tdClient.getAllDepartments((err, deps) => {
|
|
104
104
|
if (this.log) {console.log("deps:", JSON.stringify(deps));}
|
|
105
105
|
if (err) {
|
|
106
106
|
console.error("getAllDepartments() error:", err);
|
|
@@ -117,7 +117,7 @@ class DirSetConversationTags {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
if (dep) {
|
|
120
|
-
this.
|
|
120
|
+
this.tdClient.updateRequestDepartment(requestId, dep._id, null, (err, res) => {
|
|
121
121
|
if (err) {
|
|
122
122
|
console.error("DirDepartment error:", err);
|
|
123
123
|
callback();
|