@tiledesk/tiledesk-tybot-connector 0.2.70 → 0.2.72

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,13 @@
5
5
  available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
+
9
+ # v0.2.72
10
+ - Fix. userParams not in /reserved...
11
+
12
+ # v0.2.71
13
+ - Fix. DirReplyV2 "NoInput" bug. Refactored with the introduction of "timeout_id", an ID specific for each noInput timeout: this.chatbot.addParameter(TiledeskChatbotConst.USER_INPUT, timeout_id)
14
+
8
15
  # v0.2.70
9
16
  - added DirIfOnlineAgentsV2
10
17
  - Fix. TiledeskChatbot: WRONG: await chatbot.addParameter("userInput", true); ====> FIXED: this.addParameter("userInput", true)
package/index.js CHANGED
@@ -414,7 +414,7 @@ router.get('/ext/reserved/parameters/requests/:requestid', async (req, res) => {
414
414
  // }
415
415
  // }
416
416
  // }
417
- TiledeskChatbotUtil.userFlowAttributes(parameters);
417
+ const userParams = TiledeskChatbotUtil.userFlowAttributes(parameters);
418
418
  res.send(userParams);
419
419
  }
420
420
  });
@@ -9,6 +9,7 @@ const { IntentForm } = require('./IntentForm.js');
9
9
  const { TiledeskChatbotUtil } = require('./TiledeskChatbotUtil.js');
10
10
  const { DirLockIntent } = require('../tiledeskChatbotPlugs/directives/DirLockIntent');
11
11
  const { DirUnlockIntent } = require('../tiledeskChatbotPlugs/directives/DirUnlockIntent');
12
+ const { TiledeskChatbotConst } = require('./TiledeskChatbotConst.js');
12
13
 
13
14
  class TiledeskChatbot {
14
15
 
@@ -83,7 +84,6 @@ class TiledeskChatbot {
83
84
  await this.unlockIntent(this.requestId);
84
85
  await this.unlockAction(this.requestId);
85
86
  // console.log("RESET LOCKED INTENT.");
86
- await this.addParameter("userInput", true); // set userInput
87
87
  if (this.log) {console.log("RESET LOCKED INTENT. Intent was explicitly invoked with an action:", message.attributes.action);}
88
88
  }
89
89
  } catch(error) {
@@ -91,6 +91,18 @@ class TiledeskChatbot {
91
91
  }
92
92
  }
93
93
 
94
+ // resetting any noInput timeout setting userInput = true
95
+ // if (message.sender != "_tdinternal") {
96
+ // if (this.log) {console.log("resetting any noInput timeout setting userInput = (false?)", await this.getParameter(TiledeskChatbotConst.USER_INPUT) );}
97
+ // try {
98
+ // // await this.addParameter(TiledeskChatbotConst.USER_INPUT, true); // set userInput
99
+ // await this.deleteParameter(TiledeskChatbotConst.USER_INPUT); // reset userInput
100
+ // if (this.log) {console.log("userInput?", await this.getParameter(TiledeskChatbotConst.USER_INPUT) );}
101
+ // } catch(error) {
102
+ // console.error("Error resetting userInput:", error);
103
+ // }
104
+ // }
105
+
94
106
  // any external invocation restarts the steps counter
95
107
  try {
96
108
  if (message.sender != "_tdinternal") {
@@ -22,6 +22,7 @@ class TiledeskChatbotConst {
22
22
  static REQ_CHAT_CHANNEL = "chatChannel";
23
23
  static REQ_DECODED_JWT_KEY = "decodedCustomJWT";
24
24
  static REQ_REQUESTER_IS_AUTHENTICATED_KEY = "strongAuthenticated";
25
+ static USER_INPUT = "_userInput";
25
26
 
26
27
  // static REQ_DEPARTMENT_ID_KEY = "tdDepartmentId";
27
28
  // static REQ_PROJECT_ID_KEY = "projectId";
@@ -496,7 +496,8 @@ class TiledeskChatbotUtil {
496
496
  }
497
497
 
498
498
  if (message.text && message.sender !== "_tdinternal") {
499
- await chatbot.addParameter("userInput", true); // set userInput
499
+ // await chatbot.addParameter(TiledeskChatbotConst.USER_INPUT, true); // set userInput
500
+ await chatbot.deleteParameter(TiledeskChatbotConst.USER_INPUT); // set userInput
500
501
  await chatbot.addParameter(TiledeskChatbotConst.REQ_LAST_USER_TEXT_KEY, message.text); // DEPRECATED
501
502
  await chatbot.addParameter(TiledeskChatbotConst.REQ_LAST_USER_TEXT_v2_KEY, message.text);
502
503
  if (message.channel) {
@@ -835,7 +836,7 @@ class TiledeskChatbotUtil {
835
836
  "userLeadId",
836
837
  "lastUserText",
837
838
  TiledeskChatbotConst.REQ_REQUESTER_IS_AUTHENTICATED_KEY,
838
- "userInput"
839
+ TiledeskChatbotConst.USER_INPUT
839
840
  ]
840
841
  let userParams = {};
841
842
  if (flowAttributes) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.70",
3
+ "version": "0.2.72",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -57,7 +57,7 @@ class DirIfOnlineAgentsV2 {
57
57
 
58
58
  let agents;
59
59
  if (selectedOption === "currentDep") {
60
- console.log("(DirIfOnlineAgents) selectedOption === currentDep");
60
+ console.log("(DirIfOnlineAgents) selectedOption === currentDep. Current department:", this.context.departmentId);
61
61
  agents = await this.getDepartmentAvailableAgents(this.context.departmentId);
62
62
  console.log("(DirIfOnlineAgents) agents:", agents);
63
63
  }
@@ -3,8 +3,9 @@ const { TiledeskChatbot } = require('../../models/TiledeskChatbot');
3
3
  const { TiledeskChatbotConst } = require('../../models/TiledeskChatbotConst');
4
4
  const { TiledeskChatbotUtil } = require('../../models/TiledeskChatbotUtil');
5
5
  const { DirIntent } = require("./DirIntent");
6
- const { defaultOptions } = require('liquidjs');
6
+ // const { defaultOptions } = require('liquidjs');
7
7
  const { DirMessageToBot } = require('./DirMessageToBot');
8
+ const { v4: uuidv4 } = require('uuid');
8
9
 
9
10
  class DirReplyV2 {
10
11
 
@@ -84,13 +85,15 @@ class DirReplyV2 {
84
85
  const noInputIntent = action.noInputIntent;
85
86
  const noInputTimeout = action.noInputTimeout;
86
87
  if (this.log) { console.log("noInputTimeout found:", noInputTimeout); }
87
- if (noInputTimeout > 0 && noInputTimeout < 300000) {
88
- await this.chatbot.addParameter("userInput", false); // control variable. On each user input is set to true
89
- if (this.log) { console.log("Set userInput: false, checking...", await this.chatbot.getParameter("userInput")); }
88
+ if (noInputTimeout > 0 && noInputTimeout < 7776000) {
89
+ const timeout_id = uuidv4();
90
+ await this.chatbot.addParameter(TiledeskChatbotConst.USER_INPUT, timeout_id); // control variable. On each user input is removed
91
+ if (this.log) { console.log("Set userInput: false, checking...", await this.chatbot.getParameter(TiledeskChatbotConst.USER_INPUT)); }
90
92
  setTimeout(async () => {
91
93
  if (this.log) { console.log("noinput timeout triggered!"); }
92
- let userInput = await this.chatbot.getParameter("userInput");
93
- if (!userInput) {
94
+ const userInput = await this.chatbot.getParameter(TiledeskChatbotConst.USER_INPUT);
95
+ if (this.log) { console.log("got 'userInput':", userInput); }
96
+ if (userInput && userInput === timeout_id) {
94
97
  if (this.log) { console.log("no 'userInput'. Executing noinput action:", noInputIntent); }
95
98
  await this.chatbot.unlockIntent(this.requestId);
96
99
  await this.chatbot.unlockAction(this.requestId);
@@ -100,6 +103,9 @@ class DirReplyV2 {
100
103
  if (this.log) { console.log("noinput action invoked", noinput_action); }
101
104
  });
102
105
  }
106
+ else {
107
+ if (this.log) { console.log("skipping noinput action because of userInput", userInput); }
108
+ }
103
109
  }, noInputTimeout);
104
110
  }
105
111
  }