@tiledesk/tiledesk-tybot-connector 0.2.32 → 0.2.33

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,9 @@
5
5
  available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
+ # v0.2.33
9
+ - Added lead attributes (userEmail, userPhone, userFullname, userLeadId, userCompany)
10
+
8
11
  # v0.2.32
9
12
  - Added attributes filling to message.metadata.src
10
13
  - Added attributes filling to message.metadata.name
@@ -448,6 +448,23 @@ class TiledeskChatbotUtil {
448
448
  await chatbot.addParameter("lastUserDocumentName", null);
449
449
  await chatbot.addParameter("lastUserDocumentType", null);
450
450
  }
451
+ if (message && message.request && message.request.lead) {
452
+ if (message.request.lead.email) {
453
+ await chatbot.addParameter("userEmail", message.request.lead.email);
454
+ }
455
+ if (message.request.lead.fullname) {
456
+ await chatbot.addParameter("userFullname", message.request.lead.fullname);
457
+ }
458
+ if (message.request.lead.phone) {
459
+ await chatbot.addParameter("userPhone", message.request.lead.phone);
460
+ }
461
+ if (message.request.lead.lead_id) {
462
+ await chatbot.addParameter("userLeadId", message.request.lead.lead_id);
463
+ }
464
+ if (message.request.lead.company) {
465
+ await chatbot.addParameter("userCompany", message.request.lead.company);
466
+ }
467
+ }
451
468
  }
452
469
 
453
470
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.32",
3
+ "version": "0.2.33",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,7 +9,6 @@ require('dotenv').config();
9
9
  class DirMake {
10
10
 
11
11
  constructor(context) {
12
- console.log('context object LOG: ', context.log)
13
12
  if (!context) {
14
13
  throw new Error('context object is mandatory');
15
14
  }
@@ -18,6 +17,7 @@ class DirMake {
18
17
  this.requestId = this.context.requestId;
19
18
  this.log = context.log;
20
19
  this.intentDir = new DirIntent(context);
20
+ if (this.log) {console.log('LOG: ', this.log)};
21
21
  }
22
22
 
23
23
  execute(directive, callback) {
@@ -40,7 +40,7 @@ class DirMake {
40
40
  if (this.log) { console.log("DirMake action:", JSON.stringify(action)); }
41
41
  let trueIntent = action.trueIntent;
42
42
  let falseIntent = action.falseIntent;
43
- //console.log('DirMake trueIntent',trueIntent)
43
+ if (this.log) {console.log('DirMake trueIntent',trueIntent)}
44
44
  if (!this.tdcache) {
45
45
  console.error("Error: DirMake tdcache is mandatory");
46
46
  callback();
@@ -67,12 +67,12 @@ class DirMake {
67
67
  console.log("DirMake bodyParameters: ", bodyParameters);
68
68
  }
69
69
  if (!bodyParameters || bodyParameters === '') {
70
- console.error("DirMake ERROR - bodyParameters is undefined or null or empty string");
70
+ if (this.log) {console.error("DirMake ERROR - bodyParameters is undefined or null or empty string")};
71
71
  callback();
72
72
  return;
73
73
  }
74
74
  if (!webhook_url || webhook_url === '') {
75
- console.error("DirMake ERROR - webhook_url is undefined or null or empty string");
75
+ if (this.log) {console.error("DirMake ERROR - webhook_url is undefined or null or empty string:")};
76
76
  let status = 422;
77
77
  let error = 'Missing make webhook url';
78
78
  await this.#assignAttributes(action, status, error);
@@ -119,9 +119,9 @@ class DirMake {
119
119
  MAKE_HTTPREQUEST, async (err, resbody) => {
120
120
  if (err) {
121
121
  if (callback) {
122
- console.error("myrequest/(httprequest) DirMake make err:", err);
122
+ if (this.log) {console.error("myrequest/(httprequest) DirMake make err:", err)};
123
123
  let status = 404;
124
- let error = 'Not found';
124
+ let error = 'Make url not found';
125
125
  await this.#assignAttributes(action, status, error);
126
126
  this.#executeCondition(false, trueIntent, null, falseIntent, null, () => {
127
127
  callback(false); // continue the flow
@@ -212,7 +212,7 @@ class DirMake {
212
212
  }
213
213
  })
214
214
  .catch((error) => {
215
- // console.error("An error occurred:", JSON.stringify(error.data));
215
+ if (this.log) {console.error("An error occurred:", JSON.stringify(error.message))};
216
216
  if (callback) {
217
217
  callback(error, null);
218
218
  }