@tiledesk/tiledesk-tybot-connector 0.5.0 → 0.5.1-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.
Files changed (102) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/ExtApi.js +4 -83
  3. package/ExtUtil.js +0 -1
  4. package/Logger.js +113 -0
  5. package/TdCache.js +5 -3
  6. package/TiledeskClientTest.js +5 -28
  7. package/TiledeskExpression.js +6 -47
  8. package/{models → engine}/IntentForm.js +30 -44
  9. package/{models → engine}/IntentsMachineFactory.js +5 -4
  10. package/{models → engine}/MongodbBotsDataSource.js +31 -55
  11. package/{models → engine}/MongodbIntentsMachine.js +6 -5
  12. package/{models → engine}/TiledeskChatbot.js +82 -259
  13. package/{models → engine}/TiledeskChatbotConst.js +9 -0
  14. package/{models → engine}/TiledeskIntentsMachine.js +5 -15
  15. package/{models → engine/mock}/MockBotsDataSource.js +2 -19
  16. package/{models → engine/mock}/MockTdCache.js +0 -9
  17. package/index.js +106 -380
  18. package/logs/app.log +11557 -277
  19. package/logs/app1.log +62258 -0
  20. package/logs/app2.log +46280 -0
  21. package/logs/app3.log +31686 -0
  22. package/logs/app4.log +46163 -0
  23. package/logs/app5.log +33173 -0
  24. package/models/faq.js +2 -5
  25. package/package.json +5 -2
  26. package/{TiledeskServices → services}/AIService.js +4 -3
  27. package/{models/faqKbService.js → services/FaqKbService.js} +1 -2
  28. package/{models/faqService.js → services/FaqService.js} +4 -3
  29. package/services/IntegrationService.js +43 -0
  30. package/services/TilebotService.js +47 -0
  31. package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +68 -142
  32. package/tiledeskChatbotPlugs/FillParamsChatbotPlug.js +8 -14
  33. package/tiledeskChatbotPlugs/Filler.js +0 -1
  34. package/tiledeskChatbotPlugs/MarkbotChatbotPlug.js +12 -20
  35. package/tiledeskChatbotPlugs/MessagePipeline.js +5 -15
  36. package/tiledeskChatbotPlugs/SplitsChatbotPlug.js +4 -13
  37. package/tiledeskChatbotPlugs/TiledeskRequestVariables.js +1 -1
  38. package/tiledeskChatbotPlugs/WebhookChatbotPlug.js +21 -89
  39. package/tiledeskChatbotPlugs/directives/DEPRECATED_DirSetAttribute.js +1 -1
  40. package/tiledeskChatbotPlugs/directives/DirAddTags.js +23 -140
  41. package/tiledeskChatbotPlugs/directives/DirAiPrompt.js +42 -128
  42. package/tiledeskChatbotPlugs/directives/DirAskGPT.js +37 -127
  43. package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +52 -145
  44. package/tiledeskChatbotPlugs/directives/DirAssign.js +12 -23
  45. package/tiledeskChatbotPlugs/directives/DirAssignFromFunction.js +16 -12
  46. package/tiledeskChatbotPlugs/directives/DirAssistant.js +56 -198
  47. package/tiledeskChatbotPlugs/directives/DirBrevo.js +41 -101
  48. package/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js +9 -19
  49. package/tiledeskChatbotPlugs/directives/DirClearTranscript.js +1 -1
  50. package/tiledeskChatbotPlugs/directives/DirClose.js +4 -2
  51. package/tiledeskChatbotPlugs/directives/DirCode.js +16 -23
  52. package/tiledeskChatbotPlugs/directives/DirCondition.js +19 -25
  53. package/tiledeskChatbotPlugs/directives/DirConnectBlock.js +9 -82
  54. package/tiledeskChatbotPlugs/directives/DirContactUpdate.js +10 -22
  55. package/tiledeskChatbotPlugs/directives/DirCustomerio.js +34 -89
  56. package/tiledeskChatbotPlugs/directives/DirDeflectToHelpCenter.js +17 -22
  57. package/tiledeskChatbotPlugs/directives/DirDeleteVariable.js +8 -8
  58. package/tiledeskChatbotPlugs/directives/DirDepartment.js +13 -12
  59. package/tiledeskChatbotPlugs/directives/DirDisableInputText.js +2 -6
  60. package/tiledeskChatbotPlugs/directives/DirFireTiledeskEvent.js +4 -4
  61. package/tiledeskChatbotPlugs/directives/DirForm.js +17 -24
  62. package/tiledeskChatbotPlugs/directives/DirGptTask.js +49 -139
  63. package/tiledeskChatbotPlugs/directives/DirGptTask_OLD.js +8 -53
  64. package/tiledeskChatbotPlugs/directives/DirHubspot.js +31 -91
  65. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgents.js +19 -26
  66. package/tiledeskChatbotPlugs/directives/DirIfOnlineAgentsV2.js +24 -78
  67. package/tiledeskChatbotPlugs/directives/DirIfOpenHours.js +17 -68
  68. package/tiledeskChatbotPlugs/directives/DirIntent.js +12 -104
  69. package/tiledeskChatbotPlugs/directives/DirJSONCondition.js +15 -14
  70. package/tiledeskChatbotPlugs/directives/DirLockIntent.js +7 -12
  71. package/tiledeskChatbotPlugs/directives/DirMake.js +21 -53
  72. package/tiledeskChatbotPlugs/directives/DirMessage.js +35 -28
  73. package/tiledeskChatbotPlugs/directives/DirMessageToBot.js +8 -87
  74. package/tiledeskChatbotPlugs/directives/DirMoveToAgent.js +6 -4
  75. package/tiledeskChatbotPlugs/directives/DirMoveToUnassigned.js +6 -4
  76. package/tiledeskChatbotPlugs/directives/DirQapla.js +26 -120
  77. package/tiledeskChatbotPlugs/directives/DirRandomReply.js +11 -19
  78. package/tiledeskChatbotPlugs/directives/DirRemoveCurrentBot.js +4 -0
  79. package/tiledeskChatbotPlugs/directives/DirReplaceBot.js +5 -2
  80. package/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +12 -58
  81. package/tiledeskChatbotPlugs/directives/DirReplaceBotV3.js +11 -57
  82. package/tiledeskChatbotPlugs/directives/DirReply.js +34 -37
  83. package/tiledeskChatbotPlugs/directives/DirReplyV2.js +30 -72
  84. package/tiledeskChatbotPlugs/directives/DirSendEmail.js +9 -10
  85. package/tiledeskChatbotPlugs/directives/DirSendWhatsapp.js +15 -40
  86. package/tiledeskChatbotPlugs/directives/DirSetAttribute.js +8 -5
  87. package/tiledeskChatbotPlugs/directives/DirSetAttributeV2.js +25 -113
  88. package/tiledeskChatbotPlugs/directives/DirSetConversationTags.js +14 -13
  89. package/tiledeskChatbotPlugs/directives/DirUnlockIntent.js +3 -3
  90. package/tiledeskChatbotPlugs/directives/DirWait.js +5 -6
  91. package/tiledeskChatbotPlugs/directives/DirWebRequest.js +14 -49
  92. package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +22 -77
  93. package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +1 -1
  94. package/tiledeskChatbotPlugs/directives/DirWebResponse.js +23 -64
  95. package/tiledeskChatbotPlugs/directives/DirWhatsappByAttribute.js +13 -42
  96. package/tiledeskChatbotPlugs/directives/Directives.js +1 -3
  97. package/utils/HttpUtils.js +128 -0
  98. package/{models → utils}/TiledeskChatbotUtil.js +140 -234
  99. package/utils/winston.js +42 -0
  100. package/TdCache copy.js +0 -242
  101. package/TiledeskServices/utils.js +0 -99
  102. /package/{models → engine/mock}/MockIntentsMachine.js +0 -0
@@ -58,6 +58,7 @@ class Directives {
58
58
  static MOVE_TO_UNASSIGNED = "move_to_unassigned";
59
59
  static CONNECT_BLOCK = "connect_block";
60
60
  static ADD_TAGS = 'add_tags'
61
+ static WEBHOOK = 'webhook';
61
62
  static WEB_RESPONSE = "web_response";
62
63
 
63
64
  // static WHEN_ONLINE_MOVE_TO_AGENT = "whenonlinemovetoagent"; // DEPRECATED?
@@ -74,13 +75,10 @@ class Directives {
74
75
  // static CONDITION = "condition"; // DEPRECATED
75
76
 
76
77
  static actionToDirective(action) {
77
- // console.log("actionToDirective:", action);
78
78
  let directive = {
79
79
  name: action["_tdActionType"],
80
80
  action: action
81
81
  }
82
- // delete directive.action["_tdActionType"];
83
- // console.log("Directive out:", directive);
84
82
  return directive;
85
83
  }
86
84
  }
@@ -0,0 +1,128 @@
1
+ let axios = require('axios');
2
+ let https = require("https");
3
+ const winston = require('./winston');
4
+
5
+ class HttpUtils {
6
+
7
+ constructor() { }
8
+
9
+ request(options, callback) {
10
+ let axios_options = {
11
+ url: options.url,
12
+ method: options.method,
13
+ params: options.params,
14
+ headers: options.headers
15
+ }
16
+ if (options.json !== null) {
17
+ axios_options.data = options.json
18
+ }
19
+ if (options.url.startsWith("https:")) {
20
+ const httpsAgent = new https.Agent({
21
+ rejectUnauthorized: false,
22
+ });
23
+ axios_options.httpsAgent = httpsAgent;
24
+ }
25
+ axios(axios_options)
26
+ .then((res) => {
27
+ if (res && res.status == 200 && res.data) {
28
+ if (callback) {
29
+ callback(null, res.data);
30
+ }
31
+ }
32
+ else {
33
+ if (callback) {
34
+ callback(new Error("Response status is not 200"), null);
35
+ }
36
+ }
37
+ })
38
+ .catch((error) => {
39
+ if (error.response.data) {
40
+ if (typeof error.response.data === 'string') {
41
+ winston.error("Axios error response data: " + error.response.data);
42
+ } else {
43
+ winston.error("Axios error response data: ", error.response.data);
44
+ }
45
+ } else if (error.response) {
46
+ winston.error("Axios error response: ", error.response);
47
+ } else {
48
+ winston.error("Axios error: ", error);
49
+ }
50
+ if (callback) {
51
+ callback(error, null);
52
+ }
53
+ });
54
+ }
55
+
56
+ // static myrequest(options, callback, log) {
57
+ // winston.verbose("** API URL: " + options.url);
58
+ // winston.debug("** Options: ", options);
59
+ // let axios_settings = {
60
+ // url: options.url,
61
+ // method: options.method,
62
+ // data: options.json,
63
+ // params: options.params,
64
+ // headers: options.headers
65
+ // }
66
+
67
+ // if (options.url.startsWith("https:") && options.httpsOptions) {
68
+ // const httpsAgent = new https.Agent(options.httpsOptions);
69
+ // axios_settings.httpsAgent = httpsAgent;
70
+ // }
71
+ // else if (options.url.startsWith("https:") && !options.httpsOptions) {
72
+ // // HTTPS default is rejectUnauthorized: false
73
+ // const httpsAgent = new https.Agent({
74
+ // rejectUnauthorized: false,
75
+ // });
76
+ // axios_settings.httpsAgent = httpsAgent;
77
+ // }
78
+
79
+ // axios(axios_settings)
80
+ // .then(function (res) {
81
+ // winston.debug("Response for url: " + options.url);
82
+ // winston.debug("Response headers: ", res.headers);
83
+
84
+ // if (res && res.status == 200 && res.data) {
85
+ // if (callback) {
86
+ // callback(null, res.data);
87
+ // }
88
+ // }
89
+ // else {
90
+
91
+ // if (callback) {
92
+ // callback(Utils.getErr({message: "Response status not 200"}, options, res), null, null);
93
+ // }
94
+ // }
95
+ // })
96
+ // .catch(function (error) {
97
+ // winston.error("Request Error: ", error);
98
+ // if (callback) {
99
+ // callback(error, null, null);
100
+ // }
101
+ // });
102
+ // }
103
+
104
+ static getErr(err, request, response) {
105
+ let res_err = {}
106
+ res_err.http_err = err;
107
+ res_err.http_request = request;
108
+ res_err.http_response = response;
109
+ return res_err;
110
+ }
111
+
112
+ fixToken(token) {
113
+ if (token.startsWith('JWT ')) {
114
+ return token;
115
+ }
116
+ else {
117
+ return 'JWT ' + token;
118
+ }
119
+ }
120
+
121
+
122
+
123
+
124
+ }
125
+
126
+ const httpUtils = new HttpUtils();
127
+
128
+ module.exports = httpUtils;