@tiledesk/tiledesk-tybot-connector 0.2.136 → 0.2.137-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,6 +17,9 @@ available on:
17
17
  - Added flowError on JSONCondition when result = null
18
18
  - Added fix on Filler -->
19
19
 
20
+ # v0.2.137-rc1
21
+ - Updated: hidden message is enabled only in dev mode for dratf requests
22
+
20
23
  # v0.2.136
21
24
  - TdCache rollback
22
25
 
@@ -1,6 +1,7 @@
1
1
  const { TiledeskExpression } = require('../TiledeskExpression');
2
2
  const { Filler } = require('../tiledeskChatbotPlugs/Filler');
3
3
  const { TiledeskChatbotConst } = require('./TiledeskChatbotConst');
4
+ const { TiledeskChatbot } = require('./TiledeskChatbot.js');
4
5
  let parser = require('accept-language-parser');
5
6
  const { Directives } = require('../tiledeskChatbotPlugs/directives/Directives.js');
6
7
  require('dotenv').config();
@@ -516,13 +517,10 @@ class TiledeskChatbotUtil {
516
517
  await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN, chatbotToken); // DEPRECATED
517
518
  await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN_v2, "JWT " + chatbotToken);
518
519
  }
519
- /**
520
- * RefactoringCheck: can this be deleted?
521
- */
522
- // if (process.env.TILEDESK_API) {
523
- // await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN, chatbotToken); // DEPRECATED
524
- // await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN_v2, "JWT " + chatbotToken);
525
- // }
520
+ if (process.env.TILEDESK_API) {
521
+ await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN, chatbotToken); // DEPRECATED
522
+ await chatbot.addParameter(TiledeskChatbotConst.REQ_CHATBOT_TOKEN_v2, "JWT " + chatbotToken);
523
+ }
526
524
 
527
525
  if (process.env.API_URL) {
528
526
  await chatbot.addParameter(TiledeskChatbotConst.API_BASE_URL, process.env.API_URL);
@@ -701,14 +699,7 @@ class TiledeskChatbotUtil {
701
699
  await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_ID_KEY, message.attributes.departmentId);
702
700
  await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_NAME_KEY, message.attributes.departmentName);
703
701
  }
704
- if (message && message.request && message.request.attributes && message.request.attributes.payload) {
705
- if (!message.attributes) {
706
- message.attributes = {}
707
- }
708
- message.attributes.payload = message.request.attributes.payload
709
- if (chatbot.log) {console.log("FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
710
- // if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
711
- }
702
+
712
703
  if (message.attributes) {
713
704
  if (chatbot.log) {console.log("Ok message.attributes", JSON.stringify(message.attributes));}
714
705
  // if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > Ok message.attributes", JSON.stringify(message.attributes));}
@@ -743,6 +734,17 @@ class TiledeskChatbotUtil {
743
734
  await chatbot.addParameter("ani", message.attributes.ani);
744
735
  }
745
736
  }
737
+
738
+ /** DEPRECATED */
739
+ if (message && message.request && message.request.attributes && message.request.attributes.payload) {
740
+ if (!message.attributes) {
741
+ message.attributes = {}
742
+ }
743
+ message.attributes.payload = message.request.attributes.payload
744
+ if (chatbot.log) {console.log("FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
745
+ // if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
746
+ }
747
+
746
748
 
747
749
  const _bot = chatbot.bot; // aka FaqKB
748
750
  if (chatbot.log) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.136",
3
+ "version": "0.2.137-rc1",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -6,7 +6,6 @@ const { DirIntent } = require("./DirIntent");
6
6
  const { TiledeskChatbotConst } = require("../../models/TiledeskChatbotConst");
7
7
  const { TiledeskChatbotUtil } = require("../../models/TiledeskChatbotUtil");
8
8
  const req = require("express/lib/request");
9
- const { rejects } = require("assert");
10
9
  const { update } = require("../../models/faq");
11
10
  const { TiledeskClient } = require("@tiledesk/tiledesk-client");
12
11
  require('dotenv').config();
@@ -274,7 +273,7 @@ class DirAddTags {
274
273
  }
275
274
 
276
275
  async addNewTag(tag){
277
- return new Promise((resolve, rejects)=> {
276
+ return new Promise((resolve, reject)=> {
278
277
  const HTTPREQUEST = {
279
278
  url: this.API_ENDPOINT + "/" + this.context.projectId + "/tags",
280
279
  headers: {
@@ -507,7 +507,7 @@ class DirAskGPTV2 {
507
507
  }
508
508
 
509
509
  async updateQuote(tokens_usage) {
510
- return new Promise((resolve) => {
510
+ return new Promise((resolve, reject) => {
511
511
 
512
512
  const HTTPREQUEST = {
513
513
  url: this.API_ENDPOINT + "/" + this.context.projectId + "/quotes/incr/tokens",
@@ -524,7 +524,7 @@ class DirAskGPTV2 {
524
524
  HTTPREQUEST, async (err, resbody) => {
525
525
  if (err) {
526
526
  console.error("(httprequest) DirAskGPT Increment tokens quote err: ", err);
527
- rejects(false)
527
+ reject(false)
528
528
  } else {
529
529
  // console.log("(httprequest) DirAskGPT Increment token quote resbody: ", resbody);
530
530
  resolve(true);
@@ -458,7 +458,7 @@ class DirGptTask {
458
458
  }
459
459
 
460
460
  async updateQuote(tokens_usage) {
461
- return new Promise((resolve) => {
461
+ return new Promise((resolve, reject) => {
462
462
 
463
463
  const HTTPREQUEST = {
464
464
  url: this.API_ENDPOINT + "/" + this.context.projectId + "/quotes/incr/tokens",
@@ -475,7 +475,7 @@ class DirGptTask {
475
475
  HTTPREQUEST, async (err, resbody) => {
476
476
  if (err) {
477
477
  console.error("(httprequest) DirGptTask Increment tokens quote err: ", err);
478
- rejects(false)
478
+ reject(false)
479
479
  } else {
480
480
  if (this.log) { console.log("(httprequest) DirGptTask Increment token quote resbody: ", resbody); }
481
481
  resolve(true);
@@ -1,5 +1,4 @@
1
1
  // const { TiledeskClient } = require('@tiledesk/tiledesk-client');
2
- const { rejects } = require('assert');
3
2
  const { DirIntent } = require('./DirIntent');
4
3
  const axios = require("axios").default;
5
4
  let https = require("https");
@@ -25,6 +25,7 @@ class DirMessage {
25
25
  this.requestId = context.requestId;
26
26
  this.token = context.token;
27
27
  this.log = this.context.log;
28
+ this.supportRequest = this.context.supportRequest
28
29
  }
29
30
 
30
31
  execute(directive, callback) {
@@ -94,12 +95,18 @@ class DirMessage {
94
95
  const message = action;
95
96
  if (this.log) {console.log("Message to extEndpoint:", JSON.stringify(message))};
96
97
 
97
- if (this.projectId === "656054000410fa00132e5dcc") {
98
+ if(this.supportRequest && this.supportRequest.draft){
98
99
  if (!message.text.startsWith('/')) {
99
100
  callback();
100
101
  return;
101
102
  }
102
103
  }
104
+ // if (this.projectId === "656054000410fa00132e5dcc") {
105
+ // if (!message.text.startsWith('/')) {
106
+ // callback();
107
+ // return;
108
+ // }
109
+ // }
103
110
 
104
111
  let extEndpoint = `${this.API_ENDPOINT}/modules/tilebot`;
105
112
  if (this.TILEBOT_ENDPOINT) {