@tiledesk/tiledesk-tybot-connector 0.2.30 → 0.2.31
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 +3 -0
- package/TiledeskExpression.js +2 -2
- package/models/TiledeskChatbot.js +2 -2
- package/package.json +1 -1
- package/tiledeskChatbotPlugs/directives/DirMake.js +0 -2
- package/tiledeskChatbotPlugs/directives/DirReply.js +7 -83
- package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +14 -11
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.31
|
|
9
|
+
- Removed patch: Added support for removing empty text from replies: TiledeskChatbotUtil.removeEmptyReplyCommands()
|
|
10
|
+
|
|
8
11
|
### v0.2.30
|
|
9
12
|
- Updated WhatsappByAttribute action
|
|
10
13
|
- Fixed bug: WhatsappByAttribute action pointed to whatsapp pre
|
package/TiledeskExpression.js
CHANGED
|
@@ -234,8 +234,8 @@ class TiledeskExpression {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
evaluateJavascriptExpression(expression, context) {
|
|
237
|
-
console.log("(evaluateJavascriptExpression) evaluating:", expression)
|
|
238
|
-
console.log("context:", context)
|
|
237
|
+
// console.log("(evaluateJavascriptExpression) evaluating:", expression)
|
|
238
|
+
// console.log("context:", context)
|
|
239
239
|
let res = null;
|
|
240
240
|
try {
|
|
241
241
|
const vm = new VM({
|
|
@@ -80,7 +80,7 @@ class TiledeskChatbot {
|
|
|
80
80
|
if (this.log) {console.log("RESETTING LOCKED INTENT. Intent was explicitly invoked with an action:", message.attributes.action);}
|
|
81
81
|
await this.unlockIntent(this.requestId);
|
|
82
82
|
await this.unlockAction(this.requestId);
|
|
83
|
-
console.log("RESET LOCKED INTENT.");
|
|
83
|
+
// console.log("RESET LOCKED INTENT.");
|
|
84
84
|
if (this.log) {console.log("RESET LOCKED INTENT. Intent was explicitly invoked with an action:", message.attributes.action);}
|
|
85
85
|
}
|
|
86
86
|
} catch(error) {
|
|
@@ -296,7 +296,7 @@ class TiledeskChatbot {
|
|
|
296
296
|
}
|
|
297
297
|
if (this.log) {console.log("NLP intents found:", intents);}
|
|
298
298
|
if (intents && intents.length > 0) {
|
|
299
|
-
console.log("Matching intents found.");
|
|
299
|
+
// console.log("Matching intents found.");
|
|
300
300
|
// let faq = await this.botsDataSource.getByIntentDisplayName(this.botId, intents[0].intent_display_name);
|
|
301
301
|
let faq = await this.botsDataSource.getByIntentDisplayNameCache(this.botId, intents[0].intent_display_name, this.tdcache);
|
|
302
302
|
let reply;
|
package/package.json
CHANGED
|
@@ -74,14 +74,12 @@ class DirMake {
|
|
|
74
74
|
}
|
|
75
75
|
let url;
|
|
76
76
|
try {
|
|
77
|
-
console.log('CIAOkkkk',bodyParameters)
|
|
78
77
|
let make_base_url = process.env.MAKE_ENDPOINT;
|
|
79
78
|
if (make_base_url) {
|
|
80
79
|
url = make_base_url + "/make/";
|
|
81
80
|
} else {
|
|
82
81
|
url = action.url;
|
|
83
82
|
}
|
|
84
|
-
console.log('Make url: ', url);
|
|
85
83
|
const filler = new Filler();
|
|
86
84
|
|
|
87
85
|
|
|
@@ -97,11 +97,13 @@ class DirReply {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
// send!
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
let cleanMessage = message;
|
|
101
|
+
// cleanMessage = TiledeskChatbotUtil.removeEmptyReplyCommands(message);
|
|
102
|
+
// if (!TiledeskChatbotUtil.isValidReply(cleanMessage)) {
|
|
103
|
+
// console.log("invalid message", cleanMessage);
|
|
104
|
+
// callback(); // cancel reply operation
|
|
105
|
+
// return;
|
|
106
|
+
// }
|
|
105
107
|
// console.log("valid message!", cleanMessage);
|
|
106
108
|
cleanMessage.senderFullname = this.context.chatbot.bot.name;
|
|
107
109
|
if (this.log) {console.log("Reply:", JSON.stringify(cleanMessage))};
|
|
@@ -128,86 +130,8 @@ class DirReply {
|
|
|
128
130
|
}
|
|
129
131
|
});
|
|
130
132
|
|
|
131
|
-
// this.sendSupportMessage(
|
|
132
|
-
// this.requestId,
|
|
133
|
-
// message,
|
|
134
|
-
// (err) => {
|
|
135
|
-
// if (err) {
|
|
136
|
-
// console.error("Error sending reply:", err);
|
|
137
|
-
// }
|
|
138
|
-
// // if (this.log) {console.log("Reply message sent.");}
|
|
139
|
-
// console.log("Reply message sent.", JSON.stringify(message));
|
|
140
|
-
// callback();
|
|
141
|
-
// }
|
|
142
|
-
// );
|
|
143
133
|
}
|
|
144
134
|
|
|
145
|
-
// sendSupportMessage(requestId, message, callback) {
|
|
146
|
-
// const url = `${this.context.tdclient.APIURL}/${this.projectId}/requests/${requestId}/messages`
|
|
147
|
-
// const HTTPREQUEST = {
|
|
148
|
-
// url: url,
|
|
149
|
-
// headers: {
|
|
150
|
-
// 'Content-Type' : 'application/json',
|
|
151
|
-
// 'Authorization': "JWT " + this.token
|
|
152
|
-
// },
|
|
153
|
-
// json: message,
|
|
154
|
-
// method: 'POST'
|
|
155
|
-
// };
|
|
156
|
-
// this.myrequest(
|
|
157
|
-
// HTTPREQUEST,
|
|
158
|
-
// function(err, resbody) {
|
|
159
|
-
// if (err) {
|
|
160
|
-
// if (callback) {
|
|
161
|
-
// callback(err);
|
|
162
|
-
// }
|
|
163
|
-
// }
|
|
164
|
-
// else {
|
|
165
|
-
// if (callback) {
|
|
166
|
-
// callback(null, resbody);
|
|
167
|
-
// }
|
|
168
|
-
// }
|
|
169
|
-
// }, this.log
|
|
170
|
-
// );
|
|
171
|
-
// }
|
|
172
|
-
|
|
173
|
-
// myrequest(options, callback, log) {
|
|
174
|
-
// console.log("API URL:", options.url);
|
|
175
|
-
// console.log("** Options:", JSON.stringify(options));
|
|
176
|
-
// console.log("** Sending reply json:", JSON.stringify(options.json));
|
|
177
|
-
// axios(
|
|
178
|
-
// {
|
|
179
|
-
// url: options.url,
|
|
180
|
-
// method: options.method,
|
|
181
|
-
// data: options.json,
|
|
182
|
-
// params: options.params,
|
|
183
|
-
// headers: options.headers
|
|
184
|
-
// })
|
|
185
|
-
// .then((res) => {
|
|
186
|
-
// console.log("Reply: Response for url:", options.url);
|
|
187
|
-
// console.log("Reply: Response headers:\n", JSON.stringify(res.headers));
|
|
188
|
-
// console.log("Reply: Status:", res.status);
|
|
189
|
-
// console.log("Reply: Data:", JSON.stringify(res.data));
|
|
190
|
-
// if (res && res.status == 200 && res.data) {
|
|
191
|
-
// console.log("Status 200 OK");
|
|
192
|
-
// if (callback) {
|
|
193
|
-
// callback(null, res.data);
|
|
194
|
-
// }
|
|
195
|
-
// }
|
|
196
|
-
// else {
|
|
197
|
-
// console.error("Status ! 200");
|
|
198
|
-
// if (callback) {
|
|
199
|
-
// callback({ message: "Response status not 200" }, null);
|
|
200
|
-
// }
|
|
201
|
-
// }
|
|
202
|
-
// })
|
|
203
|
-
// .catch((error) => {
|
|
204
|
-
// console.error("Reply error:", error);
|
|
205
|
-
// if (callback) {
|
|
206
|
-
// callback(error, null);
|
|
207
|
-
// }
|
|
208
|
-
// });
|
|
209
|
-
// }
|
|
210
|
-
|
|
211
135
|
}
|
|
212
136
|
|
|
213
137
|
module.exports = { DirReply };
|
|
@@ -96,12 +96,12 @@ class DirSetAttributeV2 {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
async go(action, callback) {
|
|
99
|
-
console.log("(DirSetAttribute) action before filling:", JSON.stringify(action));
|
|
99
|
+
if (this.log) {console.log("(DirSetAttribute) action before filling:", JSON.stringify(action));}
|
|
100
100
|
if (action && action.operation && action.operation.operands) {
|
|
101
|
-
console.log("filling in setattribute...");
|
|
101
|
+
if (this.log) {console.log("filling in setattribute...");}
|
|
102
102
|
await this.fillValues(action.operation.operands);
|
|
103
103
|
}
|
|
104
|
-
console.log("filled in setattribute:", action.operation);
|
|
104
|
+
if (this.log) {console.log("filled in setattribute:", action.operation);}
|
|
105
105
|
// let res = validate(action, schema);
|
|
106
106
|
// if (res.errors) {
|
|
107
107
|
// console.log("(DirSetAttribute) failed validation action:", JSON.stringify(action));
|
|
@@ -126,14 +126,17 @@ class DirSetAttributeV2 {
|
|
|
126
126
|
// console.log("filling in setattribute...");
|
|
127
127
|
// await this.fillValues(action.operation.operands);
|
|
128
128
|
// }
|
|
129
|
-
console.log("dirsetattribute, action.operation.operands:", action.operation.operands);
|
|
129
|
+
// console.log("dirsetattribute, action.operation.operands:", action.operation.operands);
|
|
130
130
|
const expression = TiledeskExpression.JSONOperationToExpression(action.operation.operators, action.operation.operands);
|
|
131
131
|
const attributes = await TiledeskChatbot.allParametersStatic(this.context.tdcache, this.context.requestId);
|
|
132
|
-
console.log("dirsetattribute, attributes:", attributes);
|
|
132
|
+
// console.log("dirsetattribute, attributes:", attributes);
|
|
133
133
|
attributes.TiledeskMath = TiledeskMath;
|
|
134
134
|
attributes.TiledeskString = TiledeskString;
|
|
135
135
|
const result = new TiledeskExpression().evaluateJavascriptExpression(expression, attributes);
|
|
136
|
-
console.log("filling in setattribute, result:", result);
|
|
136
|
+
// console.log("filling in setattribute, result:", result);
|
|
137
|
+
// THE GOAL OF ATTRIBUTE-FILLING THE "DESTINATION" FIELD IS TO SUPPORT DYNAMIC ATTRIBUTES
|
|
138
|
+
// (ATTRS WHOSE NAME IS UNKNOWN AD DESIGN-TIME)
|
|
139
|
+
// STILL UNSUPPORTED IN UI
|
|
137
140
|
let destination = await this.fillDestination(action.destination);
|
|
138
141
|
await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, destination, result);
|
|
139
142
|
callback();
|
|
@@ -147,7 +150,7 @@ class DirSetAttributeV2 {
|
|
|
147
150
|
// console.log("requestAttributes in setattribute...", requestAttributes);
|
|
148
151
|
const filler = new Filler();
|
|
149
152
|
destination = filler.fill(destination, requestAttributes);
|
|
150
|
-
console.log("setattribute, final destination:", destination);
|
|
153
|
+
// console.log("setattribute, final destination:", destination);
|
|
151
154
|
}
|
|
152
155
|
return destination
|
|
153
156
|
}
|
|
@@ -186,11 +189,11 @@ class DirSetAttributeV2 {
|
|
|
186
189
|
// console.log("requestAttributes in setattribute...", requestAttributes);
|
|
187
190
|
const filler = new Filler();
|
|
188
191
|
operands.forEach(operand => {
|
|
189
|
-
if (!operand.isVariable) {
|
|
190
|
-
console.log("setattribute, liquid operand:", operand);
|
|
192
|
+
// if (!operand.isVariable) {
|
|
193
|
+
// console.log("setattribute, liquid operand:", operand);
|
|
191
194
|
operand.value = filler.fill(operand.value, requestAttributes);
|
|
192
|
-
console.log("setattribute, final operand:", operand);
|
|
193
|
-
}
|
|
195
|
+
// console.log("setattribute, final operand:", operand);
|
|
196
|
+
// }
|
|
194
197
|
});
|
|
195
198
|
}
|
|
196
199
|
}
|