@tiledesk/tiledesk-tybot-connector 0.2.98 → 0.2.100

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,6 +17,11 @@ available on:
17
17
  - Added flowError on JSONCondition when result = null
18
18
  - Added fix on Filler -->
19
19
 
20
+ # v0.2.100 -> test
21
+ - Added "chatbotToken" to RESERVED attributes
22
+ - Added UUID, UUIDv4 dynamic attributes
23
+ - Remove console.error from Filler liquidJS catch clause
24
+
20
25
  # v0.2.98
21
26
  - Support for MAX_EXECUTION_TIME (total execution time of a flow without user interaction)
22
27
  - MAX_STEPS = 1000
@@ -14,7 +14,7 @@ const { TiledeskChatbotConst } = require('./TiledeskChatbotConst.js');
14
14
  class TiledeskChatbot {
15
15
 
16
16
  static MAX_STEPS = 1000;
17
- static MAX_EXECUTION_TIME = 1000 * 60 * 60 * 12 // 12 hours = 43.200 secs;
17
+ static MAX_EXECUTION_TIME = 1000 * 60;// * 60 * 12 // 12 hours = 43.200 secs;
18
18
 
19
19
  constructor(config) {
20
20
  if (!config.botsDataSource) {
@@ -901,7 +901,8 @@ class TiledeskChatbotUtil {
901
901
  "userLeadId",
902
902
  "lastUserText",
903
903
  TiledeskChatbotConst.REQ_REQUESTER_IS_AUTHENTICATED_KEY,
904
- TiledeskChatbotConst.USER_INPUT
904
+ TiledeskChatbotConst.USER_INPUT,
905
+ TiledeskChatbotConst.REQ_CHATBOT_TOKEN
905
906
  ]
906
907
  let userParams = {};
907
908
  if (flowAttributes) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.98",
3
+ "version": "0.2.100",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,15 +1,20 @@
1
1
  var { Liquid } = require('liquidjs');
2
2
  var engine = new Liquid();
3
+ const { v4: uuidv4 } = require('uuid');
3
4
 
4
5
  class Filler {
5
6
 
6
7
  fill(text, parameters) {
7
8
  // create dynamic attributes
8
- if (parameters) {
9
- parameters["timestamp"] = Date.now(); // type number
10
- parameters["now"] = new Date(); // type Object
9
+ if (!parameters) {
10
+ parameters = {};
11
11
  }
12
12
 
13
+ parameters["timestamp"] = Date.now(); // type number
14
+ parameters["now"] = new Date(); // type Object
15
+ parameters["UUID"] = uuidv4().replace(/-/g, '');
16
+ parameters["UUIDv4"] = uuidv4();
17
+
13
18
  // legacy parser first
14
19
  if (text == null || text == undefined || typeof text !== 'string') {
15
20
  // console.log("Skip filling. 'text' is null or not a string");
@@ -22,13 +27,13 @@ class Filler {
22
27
  }
23
28
 
24
29
  // then post process with new LiquidJS!
25
- let result;
30
+ let result = text;
26
31
  try {
27
32
  result = engine
28
33
  .parseAndRenderSync(text, parameters, null);
29
34
  }
30
35
  catch(e) {
31
- console.error(e)
36
+ // console.error(e)
32
37
  }
33
38
  return result;
34
39
  }
@@ -240,11 +240,13 @@ class DirAskGPTV2 {
240
240
  console.log("DirAskGPT error: ", err);
241
241
  }
242
242
  if (this.log) { console.log("DirAskGPT resbody:", resbody); }
243
- let answer = resbody.answer;
244
- let source = resbody.source;
245
- await this.#assignAttributes(action, answer, source);
243
+
244
+ // let answer = resbody.answer;
245
+ // let source = resbody.source;
246
+ // await this.#assignAttributes(action, answer, source);
246
247
 
247
248
  if (err) {
249
+ await this.#assignAttributes(action, answer, source);
248
250
  if (callback) {
249
251
  if (falseIntent) {
250
252
  await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
@@ -257,6 +259,7 @@ class DirAskGPTV2 {
257
259
  }
258
260
  else if (resbody.success === true) {
259
261
 
262
+ await this.#assignAttributes(action, resbody.answer, resbody.source);
260
263
  if (publicKey === true) {
261
264
  let tokens_usage = {
262
265
  tokens: resbody.prompt_token_size,
@@ -273,6 +276,7 @@ class DirAskGPTV2 {
273
276
  callback();
274
277
  return;
275
278
  } else {
279
+ await this.#assignAttributes(action, answer, source);
276
280
  if (falseIntent) {
277
281
  await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
278
282
  callback(true);