@tiledesk/tiledesk-server 2.2.2 → 2.2.8

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
@@ -1,3 +1,20 @@
1
+ # 2.2.8
2
+ - Public trigger module
3
+
4
+ # 2.2.6
5
+ - Quota license fix
6
+
7
+ # 2.2.4
8
+ - email invitation fix
9
+
10
+ # 2.2.3
11
+ - Email inboud fix (others disabled and inboudDomain variable fix and token query string encode fix)
12
+
13
+ # 2.2.2
14
+ - log fix
15
+
16
+ # 2.2.1
17
+ - log fix
1
18
 
2
19
  # 2.2.0
3
20
  - Cache circleci fix
@@ -78,8 +95,10 @@
78
95
  - Added email notification for new message and new request for email and form channel (ticket)
79
96
  - Added microLanguageTransformationInterceptor enabled when message.attributes.microlanguage==true
80
97
 
98
+ # 2.1.40.35
99
+ - Quota license fix
81
100
 
82
- # 2.1.40.34 -> PROD
101
+ # 2.1.40.34
83
102
  - logfix
84
103
 
85
104
  # 2.1.40.33
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-server",
3
3
  "description": "The Tiledesk server module",
4
- "version": "2.2.2",
4
+ "version": "2.2.8",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -37,14 +37,14 @@
37
37
  "@tiledesk-ent/tiledesk-server-dialogflow": "^1.1.6",
38
38
  "@tiledesk-ent/tiledesk-server-groups": "^1.1.2",
39
39
  "@tiledesk-ent/tiledesk-server-jwthistory": "^1.1.9",
40
- "@tiledesk-ent/tiledesk-server-mt": "^1.1.6",
40
+ "@tiledesk-ent/tiledesk-server-mt": "^1.1.7",
41
41
  "@tiledesk-ent/tiledesk-server-payments": "^1.1.5",
42
42
  "@tiledesk-ent/tiledesk-server-queue": "^1.1.10",
43
43
  "@tiledesk-ent/tiledesk-server-request-history": "^1.1.5",
44
- "@tiledesk-ent/tiledesk-server-resthook": "^1.1.50",
44
+ "@tiledesk-ent/tiledesk-server-resthook": "^1.1.51",
45
45
  "@tiledesk-ent/tiledesk-server-routing-queue": "^1.1.11",
46
46
  "@tiledesk-ent/tiledesk-server-tags": "^1.1.1",
47
- "@tiledesk-ent/tiledesk-server-triggers": "^1.1.77",
47
+ "@tiledesk-ent/tiledesk-server-triggers": "^1.1.78",
48
48
  "@tiledesk-ent/tiledesk-server-visitorcounter": "^1.1.1"
49
49
  },
50
50
  "dependencies": {
@@ -261,6 +261,7 @@ sendToUserEmailChannelEmail(projectid, message) {
261
261
  jwtid: uuidv4()
262
262
  };
263
263
 
264
+
264
265
  var recipient = lead.lead_id;
265
266
  winston.debug("recipient:"+ recipient);
266
267
 
@@ -291,12 +292,13 @@ sendToUserEmailChannelEmail(projectid, message) {
291
292
  winston.debug("sourcePage "+sourcePage);
292
293
 
293
294
 
294
- var tokenQueryString;
295
- if(sourcePage && sourcePage.indexOf('?')>-1) { //controllo superfluo ma lascio per indipendenza
296
- tokenQueryString = "&tiledesk_jwt="+encodeURIComponent("JWT "+token)
295
+ var tokenQueryString;
296
+ if(sourcePage && sourcePage.indexOf('?')>-1) { //controllo superfluo visto che lo metto prima? ma lascio comunque per indipendenza
297
+ tokenQueryString = encodeURIComponent("&tiledesk_jwt=JWT "+token)
297
298
  }else {
298
- tokenQueryString = "?tiledesk_jwt="+encodeURIComponent("JWT "+token);
299
+ tokenQueryString = encodeURIComponent("?tiledesk_jwt=JWT "+token);
299
300
  }
301
+ winston.debug("tokenQueryString: "+tokenQueryString);
300
302
 
301
303
  emailService.sendEmailChannelNotification(message.request.lead.email, message, project, tokenQueryString, sourcePage);
302
304
 
@@ -610,11 +612,12 @@ sendUserEmail(projectid, message) {
610
612
 
611
613
  var tokenQueryString;
612
614
  if(sourcePage && sourcePage.indexOf('?')>-1) { //controllo superfluo visto che lo metto prima? ma lascio comunque per indipendenza
613
- tokenQueryString = "&tiledesk_jwt="+encodeURIComponent("JWT "+token)
615
+ tokenQueryString = encodeURIComponent("&tiledesk_jwt=JWT "+token)
614
616
  }else {
615
- tokenQueryString = "?tiledesk_jwt="+encodeURIComponent("JWT "+token);
617
+ tokenQueryString = encodeURIComponent("?tiledesk_jwt=JWT "+token);
616
618
  }
617
-
619
+ winston.debug("tokenQueryString: "+tokenQueryString);
620
+
618
621
  emailService.sendNewMessageNotification(lead.email, message, project, tokenQueryString, sourcePage);
619
622
  }
620
623
 
@@ -775,8 +778,27 @@ sendAgentEmail(projectid, savedRequest) {
775
778
  winston.warn("User not found", savedRequest.participants[0]);
776
779
  } else {
777
780
  winston.verbose("Sending sendNewAssignedRequestNotification to user with email", user.email);
778
- // if (user.emailverified) { enable it? send anyway to improve engagment for new account
779
- emailService.sendNewAssignedRequestNotification(user.email, savedRequest, project);
781
+ // if (user.emailverified) { enable it? send anyway to improve engagment for new account
782
+
783
+
784
+ // var signOptions = {
785
+ // issuer: 'https://tiledesk.com',
786
+ // subject: 'user',
787
+ // audience: 'https://tiledesk.com',
788
+ // jwtid: uuidv4()
789
+ // };
790
+
791
+ // let userObject = {_id: user._id, firstname: user.firstname, lastname: user.lastname, email: user.email, attributes: user.attributes};
792
+ // winston.debug("userObject ",userObject);
793
+
794
+
795
+ // var agentToken = jwt.sign(userObject, configSecret, signOptions);
796
+ // winston.debug("agentToken "+agentToken);
797
+
798
+
799
+
800
+
801
+ emailService.sendNewAssignedRequestNotification(user.email, savedRequest, project);
780
802
  // }
781
803
  }
782
804
  });
package/routes/urls.js CHANGED
@@ -4,7 +4,7 @@ var winston = require('../config/winston');
4
4
 
5
5
 
6
6
  router.get('/redirect', function (req, res) {
7
- winston.debug(req.body);
7
+ winston.debug("redirect: "+ req.query.path);
8
8
  res.redirect(req.query.path);
9
9
  });
10
10
 
@@ -74,15 +74,15 @@ class EmailService {
74
74
  }
75
75
  winston.info('EmailService replyEnabled : '+ this.replyEnabled);
76
76
 
77
- // unused? is empty why?
77
+ // this is used as fixed reply to url, but this is unused we always return support-group-dynamic
78
78
  this.replyTo = process.env.EMAIL_REPLY_TO || config.replyTo;
79
79
  winston.info('EmailService replyTo address: '+ this.replyTo);
80
80
 
81
- this.inboudDomain = process.env.EMAIL_INBOUND_DOMAIN || config.inboundDomain;
82
- winston.info('EmailService inboudDomain : '+ this.inboudDomain);
81
+ this.inboundDomain = process.env.EMAIL_INBOUND_DOMAIN || config.inboundDomain;
82
+ winston.info('EmailService inboundDomain : '+ this.inboundDomain);
83
83
 
84
- this.inboudDomainWithAt = "@"+this.inboudDomain;
85
- winston.verbose('EmailService inboudDomainWithAt : '+ this.inboudDomainWithAt);
84
+ this.inboundDomainDomainWithAt = "@"+this.inboundDomain;
85
+ winston.verbose('EmailService inboundDomainDomainWithAt : '+ this.inboundDomainDomainWithAt);
86
86
 
87
87
  this.pass = process.env.EMAIL_PASSWORD;
88
88
 
@@ -346,7 +346,11 @@ class EmailService {
346
346
 
347
347
  let messageId = "notification" + "@" + MESSAGE_ID_DOMAIN;
348
348
 
349
- let replyTo = request.request_id + this.inboudDomainWithAt;
349
+ let replyTo;
350
+ if (this.replyEnabled) { //fai anche per gli altri
351
+ replyTo = request.request_id + this.inboundDomainDomainWithAt;
352
+ }
353
+
350
354
  let headers;
351
355
  if (request) {
352
356
 
@@ -356,7 +360,11 @@ class EmailService {
356
360
  replyTo = request.attributes.email_replyTo;
357
361
  }
358
362
 
359
- headers = {"X-TILEDESK-PROJECT-ID": project._id, "X-TILEDESK-REQUEST-ID": request.request_id, "X-TILEDESK-TICKET-ID":request.ticket_id };
363
+ headers = {
364
+ "X-TILEDESK-PROJECT-ID": project._id,
365
+ "X-TILEDESK-REQUEST-ID": request.request_id,
366
+ "X-TILEDESK-TICKET-ID":request.ticket_id,
367
+ };
360
368
 
361
369
  winston.verbose("messageId: " + messageId);
362
370
  winston.verbose("replyTo: " + replyTo);
@@ -488,7 +496,11 @@ class EmailService {
488
496
 
489
497
  let messageId = message._id + "@" + MESSAGE_ID_DOMAIN;
490
498
 
491
- let replyTo = message.request.request_id + this.inboudDomainWithAt;
499
+ let replyTo;
500
+ if (this.replyEnabled) {
501
+ replyTo = message.request.request_id + this.inboundDomainDomainWithAt;
502
+ }
503
+
492
504
  let headers;
493
505
  if (message.request) {
494
506
 
@@ -507,13 +519,13 @@ class EmailService {
507
519
 
508
520
  let inReplyTo;
509
521
  let references;
510
- if (message.attributes) {
511
- if (message.attributes.email_messageId) {
512
- inReplyTo = message.attributes.email_messageId;
513
- }
514
- if (message.attributes.email_references) {
515
- references = message.attributes.email_references;
516
- }
522
+ if (message.request.attributes) {
523
+ if (message.request.attributes.email_messageId) {
524
+ inReplyTo = message.request.attributes.email_messageId;
525
+ }
526
+ if (message.request.attributes.email_references) {
527
+ references = message.request.attributes.email_references;
528
+ }
517
529
  }
518
530
  winston.verbose("sendNewAssignedAgentMessageEmailNotification email inReplyTo: "+ inReplyTo);
519
531
  winston.verbose("sendNewAssignedAgentMessageEmailNotification email references: "+ references);
@@ -629,7 +641,11 @@ class EmailService {
629
641
 
630
642
  let messageId = "notification-pooled" + new Date().getTime() + "@" + MESSAGE_ID_DOMAIN;
631
643
 
632
- let replyTo = request.request_id + this.inboudDomainWithAt;
644
+ let replyTo;
645
+ if (this.replyEnabled) {
646
+ replyTo = request.request_id + this.inboundDomainDomainWithAt;
647
+ }
648
+
633
649
  let headers;
634
650
  if (request) {
635
651
 
@@ -765,7 +781,11 @@ class EmailService {
765
781
 
766
782
  let messageId = message._id + "@" + MESSAGE_ID_DOMAIN;
767
783
 
768
- let replyTo = message.request.request_id + this.inboudDomainWithAt;
784
+ let replyTo;
785
+ if (this.replyEnabled) {
786
+ replyTo = message.request.request_id + this.inboundDomainDomainWithAt;
787
+ }
788
+
769
789
  let headers;
770
790
  if (message.request) {
771
791
 
@@ -784,13 +804,13 @@ class EmailService {
784
804
 
785
805
  let inReplyTo;
786
806
  let references;
787
- if (message.attributes) {
788
- if (message.attributes.email_messageId) {
789
- inReplyTo = message.attributes.email_messageId;
790
- }
791
- if (message.attributes.email_references) {
792
- references = message.attributes.email_references;
793
- }
807
+ if (message.request.attributes) {
808
+ if (message.request.attributes.email_messageId) {
809
+ inReplyTo = message.request.attributes.email_messageId;
810
+ }
811
+ if (message.request.attributes.email_references) {
812
+ references = message.request.attributes.email_references;
813
+ }
794
814
  }
795
815
  winston.verbose("sendNewPooledMessageEmailNotification email inReplyTo: "+ inReplyTo);
796
816
  winston.verbose("sendNewPooledMessageEmailNotification email references: "+ references);
@@ -904,7 +924,11 @@ class EmailService {
904
924
 
905
925
  let messageId = message._id + "@" + MESSAGE_ID_DOMAIN;
906
926
 
907
- let replyTo = message.request.request_id + this.inboudDomainWithAt;
927
+ let replyTo;
928
+ if (this.replyEnabled) {
929
+ replyTo = message.request.request_id + this.inboundDomainDomainWithAt;
930
+ }
931
+
908
932
  let headers;
909
933
  if (message.request) {
910
934
 
@@ -923,13 +947,13 @@ class EmailService {
923
947
 
924
948
  let inReplyTo;
925
949
  let references;
926
- if (message.attributes) {
927
- if (message.attributes.email_messageId) {
928
- inReplyTo = message.attributes.email_messageId;
929
- }
930
- if (message.attributes.email_references) {
931
- references = message.attributes.email_references;
932
- }
950
+ if (message.request.attributes) {
951
+ if (message.request.attributes.email_messageId) {
952
+ inReplyTo = message.request.attributes.email_messageId;
953
+ }
954
+ if (message.attributes.email_references) {
955
+ references = message.request.attributes.email_references;
956
+ }
933
957
  }
934
958
  winston.verbose("email inReplyTo: "+ inReplyTo);
935
959
  winston.verbose("email references: "+ references);
@@ -1015,6 +1039,8 @@ class EmailService {
1015
1039
  }
1016
1040
 
1017
1041
  winston.debug("msgText: " + msgText);
1042
+ winston.debug("baseScope: " + JSON.stringify(baseScope));
1043
+
1018
1044
 
1019
1045
  var replacements = {
1020
1046
  message: message,
@@ -1033,7 +1059,11 @@ class EmailService {
1033
1059
 
1034
1060
  let messageId = message._id + "@" + MESSAGE_ID_DOMAIN;
1035
1061
 
1036
- let replyTo = message.request.request_id + this.inboudDomainWithAt;
1062
+ let replyTo;
1063
+ if (this.replyEnabled) {
1064
+ replyTo = message.request.request_id + this.inboundDomainDomainWithAt;
1065
+ }
1066
+
1037
1067
  let headers;
1038
1068
  if (message.request) {
1039
1069
 
@@ -1056,24 +1086,24 @@ class EmailService {
1056
1086
  let cc;
1057
1087
  let ccString;
1058
1088
 
1059
- if (message.attributes) {
1089
+ if (message.request && message.request.attributes) {
1090
+ winston.debug("email message.request.attributes: ", message.request.attributes);
1060
1091
 
1061
- winston.verbose("email message.attributes: ", message.attributes);
1062
- // per email touching manca
1063
- if (message.attributes.email_messageId) {
1064
- inReplyTo = message.attributes.email_messageId;
1065
- }
1066
- if (message.attributes.email_references) {
1067
- references = message.attributes.email_references;
1068
- }
1069
- if (message.attributes.email_cc) {
1070
- cc = message.attributes.email_cc;
1071
- }
1072
- winston.verbose("email message.attributes.email_ccStr: "+ message.attributes.email_ccStr);
1073
- if (message.attributes.email_ccStr!=undefined) {
1074
- ccString = message.attributes.email_ccStr;
1075
- winston.verbose("email set ccString");
1076
- }
1092
+ if (message.request.attributes.email_messageId) {
1093
+ inReplyTo = message.request.attributes.email_messageId;
1094
+ }
1095
+ if (message.request.attributes.email_references) {
1096
+ references = message.request.attributes.email_references;
1097
+ }
1098
+
1099
+ if (message.request.attributes.email_cc) {
1100
+ cc = message.request.attributes.email_cc;
1101
+ }
1102
+ winston.debug("email message.request.attributes.email_ccStr: "+ message.request.attributes.email_ccStr);
1103
+ if (message.request.attributes.email_ccStr!=undefined) {
1104
+ ccString = message.request.attributes.email_ccStr;
1105
+ winston.debug("email set ccString");
1106
+ }
1077
1107
  }
1078
1108
  winston.verbose("email inReplyTo: "+ inReplyTo);
1079
1109
  winston.verbose("email references: "+ references);
@@ -1187,7 +1217,7 @@ class EmailService {
1187
1217
 
1188
1218
  var that = this;
1189
1219
 
1190
- var html = await this.readTemplate('resetPassword.html', project.settings);
1220
+ var html = await this.readTemplate('resetPassword.html');
1191
1221
 
1192
1222
 
1193
1223
  var envTemplate = process.env.EMAIL_RESET_PASSWORD_HTML_TEMPLATE;
@@ -1269,7 +1299,7 @@ class EmailService {
1269
1299
 
1270
1300
  var that = this;
1271
1301
 
1272
- var html = await this.readTemplateFile('passwordChanged.html');
1302
+ var html = await this.readTemplateFile('beenInvitedExistingUser.html');
1273
1303
 
1274
1304
  var envTemplate = process.env.EMAIL_EXUSER_INVITED_HTML_TEMPLATE;
1275
1305
  winston.debug("envTemplate: " + envTemplate);
@@ -1315,7 +1345,7 @@ class EmailService {
1315
1345
 
1316
1346
  var that = this;
1317
1347
 
1318
- var html = await this.readTemplateFile('passwordChanged.html');
1348
+ var html = await this.readTemplateFile('beenInvitedNewUser.html');
1319
1349
 
1320
1350
  var envTemplate = process.env.EMAIL_NEWUSER_INVITED_HTML_TEMPLATE;
1321
1351
  winston.debug("envTemplate: " + envTemplate);
@@ -62,13 +62,12 @@ class FaqService {
62
62
  { 'question': '👨🏻‍🦰 I want an agent', 'answer': 'We are looking for an operator.. '+ActionsConstants.CHAT_ACTION_MESSAGE.AGENT, 'intent_display_name': 'agent_handoff', 'topic': 'internal' },
63
63
  { 'question': 'Close\nResolved', 'answer': ActionsConstants.CHAT_ACTION_MESSAGE.CLOSE, 'topic': 'internal' },
64
64
  { 'question': '\\start', 'answer': 'Hello 👋. I\'m a bot 🤖.\n\nChoose one of the options below or write a message to reach our staff.\n* Who are you?\n* Where are you?\n* What can you do?\n* 👨🏻‍🦰 I want an agent', 'intent_display_name': 'start', 'topic': 'internal' },
65
- // { 'question': 'Menu', 'answer': 'Choose one of the options below or write a message to reach our staff.\n* Who are you?\n* Where are you?\n* What can you do?\n* 👨🏻‍🦰 I want an agent','topic': 'internal' },
66
65
  { 'question': 'defaultFallback', 'answer': 'I can not provide an adequate answer. Write a new question or talk to a human agent.\n* Back to start tdAction:start\n* See the docs https://docs.tiledesk.com/\n* 👨🏻‍🦰 I want an agent', 'topic': 'internal' }, //TODO se metto spazio n * nn va
67
66
  { 'question': 'What can you do?', 'answer': 'Using natural language processing, I\'m able to find the best answer for your users. I also support images, videos etc.. Let\'s try:\n* Sample Image\n* Sample Video\n* Sample Action tdAction:action1\n* Sample Frame\n* Back to start tdAction:start', 'topic': 'sample' },
68
67
  { 'question': 'Sample Image', 'answer': 'tdImage:https://tiledesk.com/tiledesk-logo-x1.png\n* What can you do?\n* Back to start tdAction:start', 'topic': 'sample' },
69
68
  { 'question': 'Sample Frame', 'answer': 'tdFrame:https://www.emanueleferonato.com/wp-content/uploads/2019/02/runner/\n* What can you do?\n* Back to start tdAction:start', 'topic': 'sample' },
70
69
  { 'question': 'Sample Video', 'answer': 'tdVideo:https://www.youtube.com/embed/EngW7tLk6R8\n* What can you do?\n* Back to start tdAction:start', 'topic': 'sample' },
71
- { 'question': 'Where are you', 'answer': 'We are here ❤️\ntdFrame:https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d6087916.923447935!2d8.234804542117423!3d41.836572992140624!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x12d4fe82448dd203%3A0xe22cf55c24635e6f!2sItaly!5e0!3m2!1sen!2sit!4v1613657475377!5m2!1sen!2sit\n* Back to start tdAction:start', 'topic': 'sample' },
70
+ { 'question': 'Where are you?', 'answer': 'We are here ❤️\ntdFrame:https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d6087916.923447935!2d8.234804542117423!3d41.836572992140624!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x12d4fe82448dd203%3A0xe22cf55c24635e6f!2sItaly!5e0!3m2!1sen!2sit!4v1613657475377!5m2!1sen!2sit\n* Back to start tdAction:start', 'topic': 'sample' },
72
71
 
73
72
  // { 'question': 'Sample Webhook', 'answer': 'tdWebhook:https://tiledesk-bot-webhook.tiledesk.repl.co', 'topic': 'sample' },
74
73
  { 'question': 'Sample Action', 'answer': 'Hello 👋 Would you like to take a closer look at our offer?\n* Yes, please tdAction:yes_action\n* No tdAction:no_action','intent_display_name': 'action1', 'topic': 'sample' },
@@ -132,8 +132,7 @@
132
132
  {{#ifEquals this.type "url"}}
133
133
  <li><a href="{{this.link}}" class="dynamic_button">{{this.value}}</a></li>
134
134
  {{else}}
135
- <li><a href="mailto:{{../message.request.request_id}}@{{baseScope.inboundDomain}}?subject=Re:%20{{../message.request.subject}}&body={{this.value}}" class="dynamic_button">{{this.value}}</a></li>
136
- <!-- <li><a href="https://api.tiledesk.com/v2/{{project.id}}/link?secret_token={{tokenQueryString}}" class="dynamic_button">{{this.value}}</a></li> -->
135
+ <li><a href="mailto:{{../message.request.request_id}}@{{../baseScope.inboundDomain}}?subject=Re:%20{{../message.request.subject}}&body={{this.value}}" class="dynamic_button">{{this.value}}</a></li>
137
136
  {{/ifEquals}}
138
137
  {{/each}}
139
138
 
@@ -142,14 +141,14 @@
142
141
  {{/if}}
143
142
  {{/if}}
144
143
 
145
- {{#if message.attributes.intent_info}}
144
+ <!-- {{#if message.attributes.intent_info}}
146
145
  {{#if message.attributes.intent_info.others}}
147
146
  Others:
148
147
  {{#each message.attributes.intent_info.others}}
149
148
  <li><span>{{this.answer}}</span></li>
150
149
  {{/each}}
151
150
  {{/if}}
152
- {{/if}}
151
+ {{/if}} -->
153
152
 
154
153
 
155
154
 
@@ -205,7 +205,6 @@ it('createUpperCaseEmail', function (done) {
205
205
  });
206
206
  // mocha test/requestRoute.js --grep 'getbyidWithPartecipatingBots'
207
207
 
208
-
209
208
  it('getbyidWithPartecipatingBots', function (done) {
210
209
  // this.timeout(10000);
211
210