@tiledesk/tiledesk-server 2.5.2 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@
5
5
  🚀 IN PRODUCTION 🚀
6
6
  (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
7
7
 
8
+ # 2.6.0
9
+ - Lead update queued
10
+ - Updated tybot-connector to 0.2.57
11
+ - Updated kb route
12
+ - Added trainer job worker
13
+
14
+ # 2.5.3
15
+ - Updated whatsapp-connector to 0.1.64
16
+
8
17
  # 2.5.2
9
18
  - Updated messenger-connector to 0.1.18
10
19
  - Bug fix: kbs createdAt wrongly generated
package/README.md CHANGED
@@ -93,7 +93,7 @@ Deploy with button:
93
93
  [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Tiledesk/tiledesk-server)
94
94
 
95
95
  # Community? Questions? Support ?
96
- If you need help or just want to hang out, come, say hi on our [<img width="15" alt="Tiledesk discord" src="https://seeklogo.com/images/D/discord-color-logo-E5E6DFEF80-seeklogo.com.png"> Discord](https://discord.gg/nERZEZ7SmG) server.
96
+ If you need help or just want to hang out, come, say hi on our [<img width="15" alt="Tiledesk discord" src="https://seeklogo.com/images/D/discord-color-logo-E5E6DFEF80-seeklogo.com.png"> Discord](https://discord.gg/Q5A6Ewadmz) server.
97
97
 
98
98
  # REST API
99
99
 
package/app.js CHANGED
@@ -175,6 +175,8 @@ trainingService.start();
175
175
  var geoService = require('./services/geoService');
176
176
  // geoService.listen(); //queued
177
177
 
178
+ var updateLeadQueued = require('./services/updateLeadQueued');
179
+
178
180
  let JobsManager = require('./jobsManager');
179
181
 
180
182
  let jobWorkerEnabled = false;
@@ -183,7 +185,7 @@ if (process.env.JOB_WORKER_ENABLED=="true" || process.env.JOB_WORKER_ENABLED ==
183
185
  }
184
186
  winston.info("JobsManager jobWorkerEnabled: "+ jobWorkerEnabled);
185
187
 
186
- let jobsManager = new JobsManager(jobWorkerEnabled, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier);
188
+ let jobsManager = new JobsManager(jobWorkerEnabled, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier, updateLeadQueued);
187
189
 
188
190
  var faqBotHandler = require('./services/faqBotHandler');
189
191
  faqBotHandler.listen();
@@ -197,6 +199,10 @@ let whatsappQueue = require('@tiledesk/tiledesk-whatsapp-jobworker');
197
199
  winston.info("whatsappQueue");
198
200
  jobsManager.listenWhatsappQueue(whatsappQueue);
199
201
 
202
+ let trainingQueue = require('@tiledesk/tiledesk-train-jobworker');
203
+ winston.info("trainingQueue");
204
+ jobsManager.listenTrainingQueue(trainingQueue);
205
+
200
206
 
201
207
  var channelManager = require('./channels/channelManager');
202
208
  channelManager.listen();
package/deploy.sh CHANGED
@@ -1,5 +1,5 @@
1
1
  git pull
2
- npm version patch
2
+ npm version minor
3
3
  version=`node -e 'console.log(require("./package.json").version)'`
4
4
  echo "version $version"
5
5
 
package/event/botEvent.js CHANGED
@@ -33,9 +33,30 @@ class BotEvent extends EventEmitter {
33
33
  winston.debug("message", message);
34
34
 
35
35
  // TODO usa meglio se attributes.reply_always=true
36
- if (message.sender === "system" && message.text && message.text!="\\start") {
37
- winston.debug("it s a message sent from system, exit");
38
- return null;
36
+
37
+ // if (message.sender === "system" && message.text && message.text!="\\start") {
38
+ // winston.debug("it s a message sent from system, exit");
39
+ // return null;
40
+ // }
41
+
42
+
43
+ //sbagliato
44
+ // if (message.sender === "system" && message.text && (message.text=="\\start" || message.text=="/start") ) {
45
+ // winston.debug("it s a start message");
46
+ // } else {
47
+ // winston.debug("it s a message sent from system, exit");
48
+ // return null;
49
+ // }
50
+
51
+ if (message.sender === "system") {
52
+ if (message.text && (message.text=="\\start" || message.text=="/start") ) {
53
+ winston.debug("it s a start message");
54
+ } else {
55
+ winston.debug("it s a message sent from system, exit");
56
+ return null;
57
+ }
58
+ } else {
59
+ winston.debug("it s a message sent from other let s go");
39
60
  }
40
61
 
41
62
  if (message.text && ( message.text.indexOf("\\agent") > -1 || message.text.indexOf("\\close") > -1)) { //not reply to a message containing \\agent
package/jobs.js CHANGED
@@ -28,6 +28,9 @@ var botSubscriptionNotifier = require('./services/BotSubscriptionNotifier');
28
28
  const botEvent = require('./event/botEvent');
29
29
  var channelManager = require('./channels/channelManager');
30
30
 
31
+ var updateLeadQueued = require('./services/updateLeadQueued');
32
+
33
+
31
34
  require('./services/mongoose-cache-fn')(mongoose);
32
35
 
33
36
 
@@ -80,7 +83,7 @@ async function main()
80
83
 
81
84
 
82
85
 
83
- let jobsManager = new JobsManager(undefined, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier);
86
+ let jobsManager = new JobsManager(undefined, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier, updateLeadQueued);
84
87
 
85
88
  jobsManager.listen();
86
89
 
@@ -101,6 +104,11 @@ async function main()
101
104
  winston.info("whatsappQueue");
102
105
  jobsManager.listenWhatsappQueue(whatsappQueue);
103
106
 
107
+ let trainingQueue = require('@tiledesk/tiledesk-train-jobworker');
108
+ winston.info("trainingQueue");
109
+ jobsManager.listenTrainingQueue(trainingQueue);
110
+
111
+
104
112
  let scheduler = require('./pubmodules/scheduler');
105
113
  jobsManager.listenScheduler(scheduler);
106
114
 
package/jobsManager.js CHANGED
@@ -2,7 +2,7 @@
2
2
  var winston = require('./config/winston');
3
3
 
4
4
  class JobsManager {
5
- constructor(jobWorkerEnabled, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier) {
5
+ constructor(jobWorkerEnabled, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier, updateLeadQueued) {
6
6
  this.geoService = geoService;
7
7
  this.botEvent = botEvent;
8
8
  // this.subscriptionNotifier = subscriptionNotifier;
@@ -19,6 +19,8 @@ class JobsManager {
19
19
  // this.jobWorkerEnabled = true;
20
20
  // }
21
21
  // winston.info("JobsManager jobWorkerEnabled: "+ this.jobWorkerEnabled);
22
+
23
+ this.updateLeadQueued = updateLeadQueued;
22
24
  }
23
25
 
24
26
 
@@ -34,6 +36,8 @@ class JobsManager {
34
36
  // this.subscriptionNotifier.start();
35
37
  this.subscriptionNotifierQueued.start();
36
38
 
39
+ this.updateLeadQueued.listen();
40
+
37
41
  // this.botSubscriptionNotifier.start(); // disabled
38
42
  }
39
43
 
@@ -82,6 +86,14 @@ class JobsManager {
82
86
  // this.whatsappWorker = whatsappQueue;
83
87
  // this.whatsappQueue.listen(); // oppure codice
84
88
  }
89
+
90
+ listenTrainingQueue(trainingQueue) {
91
+ console.log("JobsManager listenTrainingQueue started");
92
+ console.log("trainingQueue is: ", trainingQueue)
93
+ if (this.jobWorkerEnabled == true) {
94
+ return winston.info("JobsManager jobWorkerEnabled is enabled. Skipping listener for Training Queue");
95
+ }
96
+ }
85
97
  }
86
98
 
87
99
 
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.5.2",
4
+ "version": "2.7.0",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -38,18 +38,19 @@
38
38
  "dependencies": {
39
39
  "@tiledesk/tiledesk-apps": "^1.0.17",
40
40
  "@tiledesk/tiledesk-chat21-app": "^1.1.8",
41
+ "@tiledesk/tiledesk-chatbot-templates": "^0.1.2",
41
42
  "@tiledesk/tiledesk-chatbot-util": "^0.8.33",
43
+ "@tiledesk/tiledesk-client": "^0.10.10",
42
44
  "@tiledesk/tiledesk-dialogflow-connector": "^1.8.4",
43
45
  "@tiledesk/tiledesk-json-rules-engine": "^4.0.3",
44
46
  "@tiledesk/tiledesk-kaleyra-proxy": "^0.1.7",
45
47
  "@tiledesk/tiledesk-messenger-connector": "^0.1.18",
46
48
  "@tiledesk/tiledesk-rasa-connector": "^1.0.10",
47
49
  "@tiledesk/tiledesk-telegram-connector": "^0.1.10",
48
- "@tiledesk/tiledesk-tybot-connector": "^0.2.56",
49
- "@tiledesk/tiledesk-whatsapp-connector": "^0.1.63",
50
+ "@tiledesk/tiledesk-train-jobworker": "^0.0.7",
51
+ "@tiledesk/tiledesk-tybot-connector": "^0.2.57",
52
+ "@tiledesk/tiledesk-whatsapp-connector": "^0.1.64",
50
53
  "@tiledesk/tiledesk-whatsapp-jobworker": "^0.0.7",
51
- "@tiledesk/tiledesk-chatbot-templates": "^0.1.2",
52
- "@tiledesk/tiledesk-client": "^0.10.10",
53
54
  "amqplib": "^0.5.5",
54
55
  "app-root-path": "^3.0.0",
55
56
  "bcrypt-nodejs": "0.0.3",
@@ -105,6 +106,7 @@
105
106
  "retry-request": "^4.2.2",
106
107
  "serve-favicon": "~2.5.0",
107
108
  "sharp": "^0.27.2",
109
+ "sitemapper": "^3.2.8",
108
110
  "stripe": "^7.2.0",
109
111
  "uniqid": "^5.4.0",
110
112
  "uuid": "^3.3.3",
@@ -194,6 +194,19 @@ function startWorker() {
194
194
  winston.info("Data queue", oka)
195
195
  });
196
196
 
197
+ ch.bindQueue(_ok.queue, exchange, "lead_update", {}, function(err3, oka) {
198
+ winston.info("Queue bind: "+_ok.queue+ " err: "+err3+ " key: lead_update");
199
+ winston.info("Data queue", oka)
200
+ });
201
+
202
+ ch.bindQueue(_ok.queue, exchange, "lead_fullname_email_update", {}, function(err3, oka) {
203
+ winston.info("Queue bind: "+_ok.queue+ " err: "+err3+ " key: lead_fullname_email_update");
204
+ winston.info("Data queue", oka)
205
+ });
206
+
207
+
208
+
209
+
197
210
 
198
211
 
199
212
  ch.consume(queueName, processMsg, { noAck: false });
@@ -295,6 +308,19 @@ function work(msg, cb) {
295
308
  leadEvent.emit('lead.create.queue', JSON.parse(message_string));
296
309
  }
297
310
 
311
+ if (topic === 'lead_update') {
312
+ winston.debug("reconnect here topic lead_update:" + topic);
313
+ // requestEvent.emit('request.update.queue', msg.content);
314
+ leadEvent.emit('lead.update.queue', JSON.parse(message_string));
315
+ }
316
+
317
+ if (topic === 'lead_fullname_email_update') {
318
+ winston.debug("reconnect here topic lead_fullname_email_update:" + topic);
319
+ // requestEvent.emit('request.update.queue', msg.content);
320
+ leadEvent.emit('lead.fullname.email.update.queue', JSON.parse(message_string));
321
+ }
322
+
323
+
298
324
 
299
325
  cb(true);
300
326
  // WebSocket.cb(true);
@@ -422,6 +448,27 @@ function listen() {
422
448
  });
423
449
  });
424
450
 
451
+
452
+ leadEvent.on('lead.update', function(lead) {
453
+ setImmediate(() => {
454
+ winston.debug("reconnect lead.update")
455
+ publish(exchange, "lead_update", Buffer.from(JSON.stringify(lead)));
456
+ winston.debug("reconnect: "+ Buffer.from(JSON.stringify(lead)))
457
+ });
458
+ });
459
+
460
+
461
+ leadEvent.on('lead.fullname.email.update', function(lead) {
462
+ setImmediate(() => {
463
+ winston.debug("reconnect lead.fullname.email.update")
464
+ publish(exchange, "lead_fullname_email_update", Buffer.from(JSON.stringify(lead)));
465
+ winston.debug("reconnect: "+ Buffer.from(JSON.stringify(lead)))
466
+ });
467
+ });
468
+
469
+
470
+
471
+
425
472
  }
426
473
 
427
474
  if (process.env.QUEUE_ENABLED === "true") {
@@ -121,7 +121,7 @@ var tInviteBotObj = {
121
121
  {key:'request.departmentHasBot',fact: 'json',path: 'department.hasBot', operator:'equal', value: true},
122
122
  {key:'request.first_text',fact: 'json',path: 'first_text', operator:'equal', value: 'welcome'}
123
123
  ]},
124
- actions: [{key:'request.department.bot.launch'}],
124
+ actions: [{key:'request.department.bot.launch', parameters: {text:"/start"}}],
125
125
  enabled:true,
126
126
  code: 's_invite_bot_01',
127
127
  type: 'internal',
@@ -196,7 +196,7 @@ var tInviteProactiveGreetingBotObj = {
196
196
  {key:'request.departmentHasBot',fact: 'json',path: 'department.hasBot', operator:'equal', value: true},
197
197
  {key:'request.first_text',fact: 'json',path: 'first_text', operator:'equal', value: 'callout'}
198
198
  ]},
199
- actions: [{key:'request.department.bot.launch'}],
199
+ actions: [{key:'request.department.bot.launch', parameters: {text:"/start"}}],
200
200
  enabled:true,
201
201
  code: 's_invite_proactive_greeting_bot_01',
202
202
  type: 'internal',
@@ -686,6 +686,9 @@ class RulesTrigger {
686
686
 
687
687
  try {
688
688
 
689
+ winston.debug('triggerEventEmitter eventTrigger:', eventTrigger);
690
+
691
+
689
692
  winston.debug('runAction eventTrigger.eventSuccess:', eventTrigger.eventSuccess);
690
693
  var trigger = eventTrigger.trigger;
691
694
  winston.debug('runAction trigger', trigger.toObject());
@@ -706,6 +709,15 @@ class RulesTrigger {
706
709
  var id_project = eventTrigger.event.id_project;
707
710
  winston.debug('runAction action id_project: ' + id_project);
708
711
 
712
+
713
+
714
+ var startText = "\\start";
715
+ if (action.parameters && action.parameters.text) {
716
+ startText = action.parameters.text;
717
+ }
718
+ winston.debug('runAction action startText: ' + startText);
719
+
720
+
709
721
  // reroute(request_id, id_project, nobot) {
710
722
  requestService.reroute(request_id, id_project).then(function(request) {
711
723
 
@@ -716,7 +728,7 @@ class RulesTrigger {
716
728
  'system',
717
729
  'Bot',
718
730
  request_id,
719
- '\\start',
731
+ startText, // /start controlla se chatbot nuovo manda /start altrimenti per i vecchi \start
720
732
  id_project,
721
733
  null,
722
734
  {subtype:'info', updateconversation : false}
@@ -775,7 +787,7 @@ class RulesTrigger {
775
787
  'system',
776
788
  'Bot',
777
789
  request_id,
778
- '\\start',
790
+ '\\start', // / start
779
791
  id_project,
780
792
  null,
781
793
  {subtype:'info', updateconversation : false}