@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 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.16
9
+ - update whatsapp api url for pre environment
10
+
8
11
  ### v0.2.15
9
12
  - replyto in send email fix
10
13
 
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];
@@ -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
- const rg = new RegExp(_regex, "g");
220
- return rg.test(text);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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
- let next_dir = await this.nextDirective(this.directives);
257
- this.process(next_dir);
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-app-pre.giovannitroisi3.repl.co/api";
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 {