@tiledesk/tiledesk-tybot-connector 0.2.77 → 0.2.79

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,12 @@
5
5
  available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
+ # v0.2.79 - dev
9
+ - Fixed. Get DepartmentId for default department in test-mode in IfOnelineAgentsV2 with correct attribute get with chatbot.getParameter()
10
+
11
+ # v0.2.78 - dev
12
+ - Fixed? Get DepartmentId for default department in test-mode in IfOnelineAgentsV2
13
+
8
14
  # v0.2.77 - dev
9
15
  - Fix. get images and urls. image URL was Wrongly removed after the upload message
10
16
 
@@ -678,6 +678,10 @@ class TiledeskChatbotUtil {
678
678
  await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_ID_KEY, message.request.department._id);
679
679
  await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_NAME_KEY, message.request.department.name);
680
680
  }
681
+ else if (message.attributes && message.attributes.departmentId) {
682
+ await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_ID_KEY, message.attributes.departmentId);
683
+ await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_NAME_KEY, message.attributes.departmentName);
684
+ }
681
685
  if (message && message.request && message.request.attributes && message.request.attributes.payload) {
682
686
  if (!message.attributes) {
683
687
  message.attributes = {}
@@ -686,7 +690,6 @@ class TiledeskChatbotUtil {
686
690
  if (chatbot.log) {console.log("FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
687
691
  // if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > FORCED SET message.attributes.payload:", JSON.stringify(message.attributes.payload))}
688
692
  }
689
-
690
693
  if (message.attributes) {
691
694
  if (chatbot.log) {console.log("Ok message.attributes", JSON.stringify(message.attributes));}
692
695
  // if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > Ok message.attributes", JSON.stringify(message.attributes));}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.77",
3
+ "version": "0.2.79",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,6 +3,7 @@ const { rejects } = require('assert');
3
3
  const { DirIntent } = require('./DirIntent');
4
4
  const axios = require("axios").default;
5
5
  let https = require("https");
6
+ const { TiledeskChatbot } = require('../../models/TiledeskChatbot');
6
7
 
7
8
  class DirIfOnlineAgentsV2 {
8
9
 
@@ -57,17 +58,42 @@ class DirIfOnlineAgentsV2 {
57
58
 
58
59
  let agents;
59
60
  if (selectedOption === "currentDep") {
60
- let departmentId;
61
- // console.log("checking supportRequest:", this.context.supportRequest);
62
- if (this.context.departmentId) {
63
- departmentId = this.context.departmentId;
64
- }
65
- else {
66
- departmentId = this.context?.supportRequest?.attributes?.departmentId;
61
+ console.log("(DirIfOnlineAgents) currentDep");
62
+ // let departmentId;
63
+ let departmentId = await this.chatbot.getParameter("department_id");
64
+ console.log("this.context.departmentId:", departmentId);
65
+
66
+ // if (this.context.tdcache) {
67
+ // let attributes =
68
+ // await TiledeskChatbot.allParametersStatic(
69
+ // this.context.tdcache, this.context.requestId
70
+ // );
71
+ // if (this.log) {console.log("Attributes:::", JSON.stringify(attributes))}
72
+ // departmentId = attributes["department_id"];
73
+ // if (this.log) {console.log("Attributes.departmentId:::", departmentId)}
74
+ // }
75
+
76
+ if (departmentId) {
77
+ // departmentId = this.context.departmentId;
78
+ // if (this.log) {console.log("(DirIfOnlineAgents) selectedOption === currentDep. Current department:", departmentId, typeof(departmentId)); }
79
+ agents = await this.getDepartmentAvailableAgents(departmentId);
80
+ if (this.log) {console.log("(DirIfOnlineAgents) agents:", agents); }
81
+ } else {
82
+ console.error("(DirIfOnlineAgents) no departmentId found in attributes");
83
+ await this.chatbot.addParameter("flowError", "(If online Agents) No departmentId found in attributes.");
84
+ if (this.log) {console.log("(DirIfOnlineAgents) flowError added in attributes", await this.chatbot.getParameter("flowError") ); }
85
+ if (falseIntent) { // no agents available
86
+ let intentDirective = DirIntent.intentDirectiveFor(falseIntent, falseIntentAttributes);
87
+ this.intentDir.execute(intentDirective, () => {
88
+ callback(stopOnConditionMet);
89
+ });
90
+ return;
91
+ }
92
+ else {
93
+ callback(false);
94
+ return;
95
+ }
67
96
  }
68
- if (this.log) {console.log("(DirIfOnlineAgents) selectedOption === currentDep. Current department:", departmentId); }
69
- agents = await this.getDepartmentAvailableAgents(departmentId);
70
- if (this.log) {console.log("(DirIfOnlineAgents) agents:", agents); }
71
97
  }
72
98
  else if (selectedOption === "selectedDep") {
73
99
  if (this.log) {console.log("(DirIfOnlineAgents) selectedOption === selectedDep", action.selectedDepartmentId); }
@@ -80,6 +106,7 @@ class DirIfOnlineAgentsV2 {
80
106
  if (this.log) {console.log("(DirIfOnlineAgents) agents:", agents); }
81
107
  }
82
108
 
109
+ console.log("anyway qui...");
83
110
  if (agents && agents.length > 0) {
84
111
  if (trueIntent) {
85
112
  let intentDirective = DirIntent.intentDirectiveFor(trueIntent, trueIntentAttributes);