@tiledesk/tiledesk-tybot-connector 0.2.128 → 0.2.130-rc1

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
@@ -17,13 +17,23 @@ available on:
17
17
  - Added flowError on JSONCondition when result = null
18
18
  - Added fix on Filler -->
19
19
 
20
- # v0.2.127 -> test
20
+ # v0.2.130-rc1
21
+ - index.js /block => added "token": "NO-TOKEN"
22
+
23
+ # v0.2.129 -> test
24
+ - (TiledeskChatbot) sending as "info": "An error occurred while getting locked intent:'" + locked_intent + "'"
25
+ - (DirectivesChatbotPlug) added try catch on new TiledeskClient() => try {tdclient = new TiledeskClient({...})}
26
+ - index.js /block => added "token": "NO-TOKEN"
27
+
28
+ # v0.2.128 -> test
21
29
  - Updated axios from 0.27.2 to 1.7.7
30
+ - fixes tdcache .set() with callback
31
+
22
32
  # v0.2.127 -> test
23
33
  - TiledeskChatbot =>
24
34
  - static MAX_STEPS = 1000;
25
35
  - static MAX_EXECUTION_TIME = 1000 * 3600 * 8;
26
-
36
+
27
37
  # v0.2.126 -> test
28
38
  - TdCache async del(key, callback) FIXED (await unsupported problem)
29
39
 
package/TdCache.js CHANGED
@@ -47,10 +47,19 @@ class TdCache {
47
47
  if (options && options.EX) {
48
48
  //console.log("expires:", options.EX)
49
49
  try {
50
- await this.client.set(
50
+ this.client.set(
51
51
  key,
52
52
  value,
53
- 'EX', options.EX);
53
+ 'EX', options.EX,
54
+ (err) => {
55
+ if (err) {
56
+ reject(err);
57
+ }
58
+ else {
59
+ return resolve();
60
+ }
61
+ }
62
+ );
54
63
  }
55
64
  catch(error) {
56
65
  reject(error)
@@ -61,18 +70,27 @@ class TdCache {
61
70
  //console.log("setting here...key", key, value)
62
71
  await this.client.set(
63
72
  key,
64
- value);
73
+ value,
74
+ (err) => {
75
+ if (err) {
76
+ reject(err);
77
+ }
78
+ else {
79
+ return resolve();
80
+ }
81
+ }
82
+ );
65
83
  }
66
84
  catch(error) {
67
- console.error("Error", error);
85
+ console.error("TdCache Error:", error);
68
86
  reject(error)
69
87
  }
70
88
  }
71
- if (options && options.callback) {
72
- options.callback();
73
- }
89
+ // if (options && options.callback) {
90
+ // options.callback();
91
+ // }
74
92
  //console.log("resolving...", key);
75
- return resolve();
93
+ // return resolve();
76
94
  });
77
95
  }
78
96
 
package/index.js CHANGED
@@ -588,7 +588,8 @@ router.post('/block/:project_id/:bot_id/:block_id', async (req, res) => {
588
588
  "attributes": {
589
589
  "payload": body
590
590
  }
591
- }
591
+ },
592
+ "token": "NO-TOKEN"
592
593
  }
593
594
  console.log("sendMessageToBot()...");
594
595
  sendMessageToBot(process.env.TYBOT_ENDPOINT, request, bot_id, async () => {
@@ -143,21 +143,24 @@ class TiledeskChatbot {
143
143
  let reply;
144
144
  if (faq) {
145
145
  reply = await this.execIntent(faq, message, lead);//, bot);
146
- resolve(reply);
147
- return;
146
+ // resolve(reply);
147
+ // return;
148
148
  }
149
149
  else {
150
- // reply = {
151
- // "text": "An error occurred while getting locked intent:'" + locked_intent + "'"
152
- // }
150
+ reply = {
151
+ "text": "An error occurred while getting locked intent:'" + locked_intent + "'",
152
+ "attributes": {
153
+ "subtype": "info"
154
+ }
155
+ }
153
156
  // because of some race condition, during a mixed ReplyV2 Action button + Replace bot an
154
157
  // intent can be found locked outside of the original chatbot scope.
155
158
  // The temp solution is to immediatly unlock the intent and let the flow continue.
156
159
  await this.unlockIntent(this.requestId);
157
160
  await this.unlockAction(this.requestId);
158
161
  }
159
- // resolve(reply);
160
- // return;
162
+ resolve(reply);
163
+ return;
161
164
  }
162
165
  // }
163
166
  // else if (message.text.startsWith("/")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.128",
3
+ "version": "0.2.130-rc1",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -136,13 +136,19 @@ class DirectivesChatbotPlug {
136
136
  }
137
137
  const projectId = supportRequest.id_project;
138
138
  const tdcache = this.tdcache;
139
- const tdclient = new TiledeskClient({
140
- projectId: projectId,
141
- token: token,
142
- APIURL: API_URL,
143
- APIKEY: "___",
144
- log: this.log
145
- });
139
+ let tdclient = null;
140
+ try {
141
+ tdclient = new TiledeskClient({
142
+ projectId: projectId,
143
+ token: token,
144
+ APIURL: API_URL,
145
+ APIKEY: "___",
146
+ log: this.log
147
+ });
148
+ }
149
+ catch(err) {
150
+ console.log("An error occurred while creating TiledeskClient in DirectivesChatbotPlug:", err);
151
+ }
146
152
 
147
153
  this.context = {
148
154
  projectId: projectId,