@tiledesk/tiledesk-tybot-connector 0.2.15 → 0.2.16
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/index.js +6 -0
- package/models/IntentForm.js +9 -2
- package/package.json +1 -1
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +11 -3
- package/tiledeskChatbotPlugs/directives/DirIntent.js +3 -3
- package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +1 -2
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -248,6 +248,7 @@ async function updateRequestVariables(chatbot, message, projectId, requestId) {
|
|
|
248
248
|
const chat_url = `https://panel.tiledesk.com/v3/dashboard/#/project/${projectId}/wsrequest/${requestId}/messages`
|
|
249
249
|
// await chatbot.addParameter("chatbot", chatbot);
|
|
250
250
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_CHAT_URL, chat_url);
|
|
251
|
+
console.log("Adding proj_", projectId);
|
|
251
252
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_PROJECT_ID_KEY, projectId);
|
|
252
253
|
// TODO add projectName too
|
|
253
254
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_REQUEST_ID_KEY, requestId);
|
|
@@ -324,6 +325,11 @@ async function updateRequestVariables(chatbot, message, projectId, requestId) {
|
|
|
324
325
|
}
|
|
325
326
|
}
|
|
326
327
|
if (chatbot.log) {
|
|
328
|
+
console.log("tdcache:", chatbot.tdcache);
|
|
329
|
+
console.log("requestId:", requestId);
|
|
330
|
+
console.log("KEY:", TiledeskChatbotConst.REQ_PROJECT_ID_KEY);
|
|
331
|
+
let proj_ = await TiledeskChatbot.getParameterStatic(chatbot.tdcache, requestId, TiledeskChatbotConst.REQ_PROJECT_ID_KEY);
|
|
332
|
+
console.log("request parameter proj_:", proj_);
|
|
327
333
|
const all_parameters = await TiledeskChatbot.allParametersStatic(chatbot.tdcache, requestId);
|
|
328
334
|
for (const [key, value] of Object.entries(all_parameters)) {
|
|
329
335
|
// const value = all_parameters[key];
|
package/models/IntentForm.js
CHANGED
|
@@ -216,8 +216,15 @@ class IntentForm {
|
|
|
216
216
|
_regex = regex.substring(1, regex.length-1);
|
|
217
217
|
}
|
|
218
218
|
if (this.log) {console.log("Validating using regex:", _regex);}
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
try {
|
|
220
|
+
const rg = new RegExp(_regex, "g");
|
|
221
|
+
return rg.test(text);
|
|
222
|
+
}
|
|
223
|
+
catch(error) {
|
|
224
|
+
console.error("Error, invalid regex:", _regex);
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
|
|
221
228
|
}
|
|
222
229
|
|
|
223
230
|
static isValidForm(form) {
|
package/package.json
CHANGED
|
@@ -252,9 +252,17 @@ class DirectivesChatbotPlug {
|
|
|
252
252
|
}
|
|
253
253
|
else if (directive_name === Directives.INTENT) {
|
|
254
254
|
// console.log(".....DirIntent")
|
|
255
|
-
new DirIntent(context).execute(directive, async () => {
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
new DirIntent(context).execute(directive, async (stop) => {
|
|
256
|
+
if (stop) {
|
|
257
|
+
if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
|
|
258
|
+
this.theend();
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
let next_dir = await this.nextDirective(this.directives);
|
|
262
|
+
this.process(next_dir);
|
|
263
|
+
}
|
|
264
|
+
// let next_dir = await this.nextDirective(this.directives);
|
|
265
|
+
// this.process(next_dir);
|
|
258
266
|
});
|
|
259
267
|
}
|
|
260
268
|
else if (directive_name === Directives.MESSAGE) {
|
|
@@ -57,8 +57,8 @@ class DirIntent {
|
|
|
57
57
|
callback();
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
this.go(action, () => {
|
|
61
|
-
callback();
|
|
60
|
+
this.go(action, (stop) => {
|
|
61
|
+
callback(stop);
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -111,7 +111,7 @@ class DirIntent {
|
|
|
111
111
|
}
|
|
112
112
|
this.sendMessageToBot(TILEBOT_ENDPOINT, intent_command_request, botId, () => {
|
|
113
113
|
// console.log("sendMessageToBot() req_body sent:", intent_command_request);
|
|
114
|
-
callback();
|
|
114
|
+
callback(true);
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
// }
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const axios = require("axios").default;
|
|
2
2
|
const { TiledeskChatbot } = require('../../models/TiledeskChatbot');
|
|
3
3
|
|
|
4
|
-
// const whatsapp_api_url = "https://tiledesk-whatsapp-app-pre.giovannitroisi3.repl.co/ext"
|
|
5
4
|
let whatsapp_api_url;
|
|
6
5
|
|
|
7
6
|
class DirWhatsappByAttribute {
|
|
@@ -36,7 +35,7 @@ class DirWhatsappByAttribute {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
if (process.env.API_URL) {
|
|
39
|
-
whatsapp_api_url = "https://tiledesk-whatsapp-
|
|
38
|
+
whatsapp_api_url = "https://tiledesk-whatsapp-connector.giovannitroisi3.repl.co/api";
|
|
40
39
|
// whatsapp_api_url = process.env.API_URL + "/modules/whatsapp";
|
|
41
40
|
console.log("(Tilebot) DirWhatsappByAttribute whatsapp_api_url: ", whatsapp_api_url);
|
|
42
41
|
} else {
|