@tiledesk/tiledesk-server 2.10.40 → 2.10.42
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +6 -0
- package/app.js +3 -3
- package/models/analyticResult.js +1 -1
- package/models/channel.js +1 -1
- package/models/department.js +1 -1
- package/models/faq.js +9 -1
- package/models/faq_kb.js +24 -17
- package/models/lead.js +1 -1
- package/models/message.js +1 -1
- package/models/pending-invitation.js +1 -1
- package/models/profile.js +1 -1
- package/models/property.js +1 -1
- package/models/request.js +1 -1
- package/models/requester.js +1 -1
- package/models/segment.js +1 -1
- package/models/setting.js +1 -1
- package/models/subscription.js +1 -1
- package/models/user.js +1 -1
- package/package.json +2 -2
- package/routes/auth.js +1 -1
- package/routes/auth_newjwt.js +3 -3
- package/routes/campaigns.js +2 -2
- package/routes/faq.js +11 -0
- package/routes/faq_kb.js +10 -4
- package/routes/kb.js +1 -1
- package/routes/request.js +1 -1
- package/services/chatbotService.js +1 -1
- package/services/openaiService.js +2 -2
package/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@
|
|
5
5
|
🚀 IN PRODUCTION 🚀
|
6
6
|
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
|
7
7
|
|
8
|
+
# 2.10.42
|
9
|
+
- updated tybot-connector to 0.2.140
|
10
|
+
|
11
|
+
# 2.10.41
|
12
|
+
- added agents_available field in faq_kb and faq models
|
13
|
+
|
8
14
|
# 2.10.40
|
9
15
|
- bug fix: empty string for slug and index issue
|
10
16
|
|
package/app.js
CHANGED
@@ -451,7 +451,7 @@ var projectSetter = function (req, res, next) {
|
|
451
451
|
if (projectid) {
|
452
452
|
|
453
453
|
if (!mongoose.Types.ObjectId.isValid(projectid)) {
|
454
|
-
winston.warn(`Invalid ObjectId: ${projectid}`);
|
454
|
+
//winston.warn(`Invalid ObjectId: ${projectid}`);
|
455
455
|
return res.status(400).send({ error: "Invalid project id: " + projectid });
|
456
456
|
}
|
457
457
|
|
@@ -462,11 +462,11 @@ var projectSetter = function (req, res, next) {
|
|
462
462
|
}
|
463
463
|
q.exec(function(err, project){
|
464
464
|
if (err) {
|
465
|
-
winston.warn("Problem getting project with id: " + projectid + " req.originalUrl: " + req.originalUrl);
|
465
|
+
//winston.warn("Problem getting project with id: " + projectid + " req.originalUrl: " + req.originalUrl);
|
466
466
|
}
|
467
467
|
winston.debug("projectSetter project:" + project);
|
468
468
|
if (!project) {
|
469
|
-
winston.warn("ProjectSetter project not found with id: " + projectid);
|
469
|
+
//winston.warn("ProjectSetter project not found with id: " + projectid);
|
470
470
|
//next();
|
471
471
|
return res.status(400).send({ error: "Project not found with id: " + projectid })
|
472
472
|
} else {
|
package/models/analyticResult.js
CHANGED
package/models/channel.js
CHANGED
package/models/department.js
CHANGED
package/models/faq.js
CHANGED
@@ -101,12 +101,20 @@ var FaqSchema = new Schema({
|
|
101
101
|
attributes: {
|
102
102
|
type: Object,
|
103
103
|
},
|
104
|
+
agents_available: {
|
105
|
+
type: Boolean,
|
106
|
+
required: false,
|
107
|
+
default: function () {
|
108
|
+
return this.isNew ? false : undefined;
|
109
|
+
},
|
110
|
+
}
|
104
111
|
}, {
|
105
112
|
timestamps: true,
|
106
113
|
toJSON: { virtuals: true } //used to polulate messages in toJSON// https://mongoosejs.com/docs/populate.html
|
107
114
|
}
|
108
115
|
);
|
109
116
|
|
117
|
+
|
110
118
|
FaqSchema.virtual('faq_kb', {
|
111
119
|
ref: 'faq_kb', // The model to use
|
112
120
|
localField: 'id_faq_kb', // Find people where `localField`
|
@@ -181,7 +189,7 @@ faq.on('index', function (error) {
|
|
181
189
|
|
182
190
|
if (process.env.MONGOOSE_SYNCINDEX) {
|
183
191
|
faq.syncIndexes();
|
184
|
-
winston.
|
192
|
+
winston.verbose("faq syncIndexes")
|
185
193
|
}
|
186
194
|
|
187
195
|
|
package/models/faq_kb.js
CHANGED
@@ -11,13 +11,13 @@ var Faq_kbSchema = new Schema({
|
|
11
11
|
name: {
|
12
12
|
type: String,
|
13
13
|
required: true,
|
14
|
-
index:true
|
14
|
+
index: true
|
15
15
|
},
|
16
16
|
description: {
|
17
17
|
type: String,
|
18
18
|
// index:true
|
19
19
|
},
|
20
|
-
url: {
|
20
|
+
url: {
|
21
21
|
type: String,
|
22
22
|
// required: true
|
23
23
|
},
|
@@ -25,7 +25,7 @@ var Faq_kbSchema = new Schema({
|
|
25
25
|
type: String,
|
26
26
|
// required: true
|
27
27
|
},
|
28
|
-
webhook_enabled: {
|
28
|
+
webhook_enabled: {
|
29
29
|
type: Boolean,
|
30
30
|
required: false,
|
31
31
|
default: false,
|
@@ -74,13 +74,13 @@ var Faq_kbSchema = new Schema({
|
|
74
74
|
type: Boolean,
|
75
75
|
required: false,
|
76
76
|
default: false,
|
77
|
-
index:true
|
77
|
+
index: true
|
78
78
|
},
|
79
79
|
certified: {
|
80
80
|
type: Boolean,
|
81
81
|
required: false,
|
82
82
|
default: false,
|
83
|
-
index:true
|
83
|
+
index: true
|
84
84
|
},
|
85
85
|
mainCategory: {
|
86
86
|
type: String,
|
@@ -92,18 +92,18 @@ var Faq_kbSchema = new Schema({
|
|
92
92
|
default: 'none'
|
93
93
|
},
|
94
94
|
tags: [{
|
95
|
-
|
96
|
-
|
95
|
+
type: String
|
96
|
+
}],
|
97
97
|
score: {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
98
|
+
type: Number,
|
99
|
+
required: false,
|
100
|
+
index: true,
|
101
|
+
default: 0
|
102
|
+
},
|
103
103
|
publishedBy: {
|
104
104
|
type: String,
|
105
105
|
},
|
106
|
-
publishedAt: {
|
106
|
+
publishedAt: {
|
107
107
|
type: Date
|
108
108
|
},
|
109
109
|
trained: {
|
@@ -122,15 +122,22 @@ var Faq_kbSchema = new Schema({
|
|
122
122
|
type: Array,
|
123
123
|
required: false
|
124
124
|
},
|
125
|
+
agents_available: {
|
126
|
+
type: Boolean,
|
127
|
+
required: false,
|
128
|
+
default: function () {
|
129
|
+
return this.isNew ? false : undefined;
|
130
|
+
},
|
131
|
+
},
|
125
132
|
slug: {
|
126
133
|
type: String,
|
127
134
|
required: false,
|
128
135
|
index: true
|
129
|
-
}
|
136
|
+
}
|
130
137
|
},{
|
131
138
|
timestamps: true
|
132
|
-
}
|
133
|
-
|
139
|
+
});
|
140
|
+
|
134
141
|
|
135
142
|
Faq_kbSchema.pre("save", async function (next) {
|
136
143
|
// Check if the document is new and if the slug has not been set manually
|
@@ -175,7 +182,7 @@ var faq_kb = mongoose.model('faq_kb', Faq_kbSchema);
|
|
175
182
|
|
176
183
|
if (process.env.MONGOOSE_SYNCINDEX) {
|
177
184
|
faq_kb.syncIndexes();
|
178
|
-
winston.
|
185
|
+
winston.verbose("faq_kb syncIndexes")
|
179
186
|
}
|
180
187
|
|
181
188
|
function generateSlug(name) {
|
package/models/lead.js
CHANGED
package/models/message.js
CHANGED
package/models/profile.js
CHANGED
package/models/property.js
CHANGED
package/models/request.js
CHANGED
@@ -522,7 +522,7 @@ RequestSchema.index({ id_project: 1, preflight: 1, smartAssignment: 1, "snapshot
|
|
522
522
|
var request = mongoose.model('request', RequestSchema);
|
523
523
|
if (process.env.MONGOOSE_SYNCINDEX) {
|
524
524
|
request.syncIndexes();
|
525
|
-
winston.
|
525
|
+
winston.verbose("message syncIndexes")
|
526
526
|
|
527
527
|
}
|
528
528
|
|
package/models/requester.js
CHANGED
package/models/segment.js
CHANGED
package/models/setting.js
CHANGED
package/models/subscription.js
CHANGED
@@ -49,7 +49,7 @@ var subscription = mongoose.model('subscription', SubscriptionSchema);
|
|
49
49
|
|
50
50
|
if (process.env.MONGOOSE_SYNCINDEX) {
|
51
51
|
subscription.syncIndexes();
|
52
|
-
winston.
|
52
|
+
winston.verbose("subscription syncIndexes")
|
53
53
|
}
|
54
54
|
|
55
55
|
module.exports = subscription;
|
package/models/user.js
CHANGED
@@ -133,7 +133,7 @@ var UserModel = mongoose.model('user', UserSchema);
|
|
133
133
|
|
134
134
|
if (process.env.MONGOOSE_SYNCINDEX) {
|
135
135
|
UserModel.syncIndexes();
|
136
|
-
winston.
|
136
|
+
winston.verbose("UserModel syncIndexes")
|
137
137
|
}
|
138
138
|
|
139
139
|
module.exports = UserModel;
|
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.10.
|
4
|
+
"version": "2.10.42",
|
5
5
|
"scripts": {
|
6
6
|
"start": "node ./bin/www",
|
7
7
|
"pretest": "mongodb-runner start",
|
@@ -48,7 +48,7 @@
|
|
48
48
|
"@tiledesk/tiledesk-rasa-connector": "^1.0.10",
|
49
49
|
"@tiledesk/tiledesk-telegram-connector": "^0.1.14",
|
50
50
|
"@tiledesk/tiledesk-train-jobworker": "^0.0.11",
|
51
|
-
"@tiledesk/tiledesk-tybot-connector": "^0.2.
|
51
|
+
"@tiledesk/tiledesk-tybot-connector": "^0.2.140",
|
52
52
|
"@tiledesk/tiledesk-whatsapp-connector": "^0.1.76",
|
53
53
|
"@tiledesk/tiledesk-whatsapp-jobworker": "^0.0.11",
|
54
54
|
"@tiledesk/tiledesk-sms-connector": "^0.1.11",
|
package/routes/auth.js
CHANGED
@@ -854,7 +854,7 @@ router.get(
|
|
854
854
|
"/keycloak/callback",
|
855
855
|
passport.authenticate("keycloak"),
|
856
856
|
function(req, res) {
|
857
|
-
winston.
|
857
|
+
winston.verbose("'/keycloak/callback: ");
|
858
858
|
// Successful authentication, redirect home.
|
859
859
|
res.redirect('/');
|
860
860
|
}
|
package/routes/auth_newjwt.js
CHANGED
@@ -135,7 +135,7 @@ function (req, res) {
|
|
135
135
|
|
136
136
|
authEvent.emit("projectuser.create", savedProject_user);
|
137
137
|
|
138
|
-
winston.
|
138
|
+
winston.verbose('project user created ', savedProject_user.toObject());
|
139
139
|
|
140
140
|
|
141
141
|
// JWT_HERE
|
@@ -215,14 +215,14 @@ router.post('/signinWithCustomToken', [
|
|
215
215
|
|
216
216
|
authEvent.emit("projectuser.create", savedProject_user);
|
217
217
|
|
218
|
-
winston.
|
218
|
+
winston.verbose('project user created ', savedProject_user.toObject());
|
219
219
|
|
220
220
|
|
221
221
|
|
222
222
|
return res.json({ success: true, token: req.headers["authorization"], user: req.user });
|
223
223
|
});
|
224
224
|
}else {
|
225
|
-
winston.
|
225
|
+
winston.verbose('project user already exists ');
|
226
226
|
return res.json({ success: true, token: req.headers["authorization"], user: req.user });
|
227
227
|
}
|
228
228
|
|
package/routes/campaigns.js
CHANGED
@@ -15,7 +15,7 @@ var Segment2MongoConverter = require("../utils/segment2mongoConverter");
|
|
15
15
|
var JobManager = require("jobs-worker-queued");
|
16
16
|
|
17
17
|
var JOB_RABBITURI = process.env.JOB_RABBITURI;
|
18
|
-
winston.
|
18
|
+
winston.verbose("JobWorkerQueued uri: " + JOB_RABBITURI);
|
19
19
|
|
20
20
|
var jobManager = new JobManager(JOB_RABBITURI,
|
21
21
|
{
|
@@ -44,7 +44,7 @@ router.post('/', function (req, res) {
|
|
44
44
|
req.body.text, req.body.departmentid, req.body.sourcePage,
|
45
45
|
req.body.language, req.body.userAgent, null, req.user._id, req.body.attributes, req.body.subject, true, req.body.channel).then(function (savedRequest) {
|
46
46
|
|
47
|
-
winston.
|
47
|
+
winston.debug("savedRequest", savedRequest);
|
48
48
|
|
49
49
|
// create(sender, senderFullname, recipient, text, id_project, createdBy, status, attributes, type, metadata, language, channel_type) {
|
50
50
|
return messageService.create(req.body.sender || req.user._id, req.body.senderFullname || req.user.fullName, savedRequest.request_id, req.body.text,
|
package/routes/faq.js
CHANGED
@@ -15,6 +15,7 @@ csv = require('csv-express');
|
|
15
15
|
csv.separator = ';';
|
16
16
|
const axios = require("axios").default;
|
17
17
|
var configGlobal = require('../config/global');
|
18
|
+
const roleConstants = require('../models/roleConstants');
|
18
19
|
|
19
20
|
const apiUrl = process.env.API_URL || configGlobal.apiUrl;
|
20
21
|
|
@@ -424,6 +425,9 @@ router.put('/:faqid', function (req, res) {
|
|
424
425
|
if (req.body.attributes != undefined) {
|
425
426
|
update.attributes = req.body.attributes;
|
426
427
|
}
|
428
|
+
if (req.body.agents_available != undefined) {
|
429
|
+
update.agents_available = req.body.agents_available;
|
430
|
+
}
|
427
431
|
|
428
432
|
if (faqid.startsWith("intentId")) {
|
429
433
|
let intent_id = faqid.substring(8);
|
@@ -606,6 +610,13 @@ router.get('/', function (req, res, next) {
|
|
606
610
|
query.intent_display_name = req.query.intent_display_name
|
607
611
|
}
|
608
612
|
|
613
|
+
let project_user = req.projectuser;
|
614
|
+
if (project_user && project_user.role === roleConstants.AGENT) {
|
615
|
+
query.agents_available = {
|
616
|
+
$in: [ null, true ]
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
609
620
|
|
610
621
|
winston.debug("GET FAQ query", query);
|
611
622
|
|
package/routes/faq_kb.js
CHANGED
@@ -325,8 +325,8 @@ router.put('/:faq_kbid', roleChecker.hasRoleOrTypes('admin', ['bot','subscriptio
|
|
325
325
|
update.certifiedTags = req.body.certifiedTags
|
326
326
|
}
|
327
327
|
|
328
|
-
if (req.body.
|
329
|
-
update.
|
328
|
+
if (req.body.agents_available != undefined) {
|
329
|
+
update.agents_available = req.body.agents_available
|
330
330
|
}
|
331
331
|
|
332
332
|
if (req.body.slug != undefined) {
|
@@ -542,13 +542,19 @@ router.get('/', roleChecker.hasRoleOrTypes('agent', ['bot','subscription']), fun
|
|
542
542
|
* if filter only for 'trashed = false',
|
543
543
|
* the bots created before the implementation of the 'trashed' property are not returned
|
544
544
|
*/
|
545
|
-
|
545
|
+
let query = { "id_project": req.projectid, "trashed": { $in: [null, false] } };
|
546
|
+
|
547
|
+
if (restricted_mode === true) {
|
548
|
+
query.agents_available = {
|
549
|
+
$in: [ null, true ]
|
550
|
+
}
|
551
|
+
}
|
546
552
|
|
547
553
|
if (req.query.all != "true") {
|
548
554
|
query.type = { $ne: "identity" }
|
549
555
|
}
|
550
556
|
|
551
|
-
|
557
|
+
let search_obj = {"$search": req.query.text};
|
552
558
|
|
553
559
|
if (req.query.text) {
|
554
560
|
if (req.query.language) {
|
package/routes/kb.js
CHANGED
@@ -1445,7 +1445,7 @@ async function scheduleScrape(resources) {
|
|
1445
1445
|
winston.error("Scheduling error: ", err);
|
1446
1446
|
error_code = 400;
|
1447
1447
|
} else {
|
1448
|
-
winston.
|
1448
|
+
winston.verbose("Scheduling result: ", result);
|
1449
1449
|
}
|
1450
1450
|
await updateStatus(r.id, error_code);
|
1451
1451
|
});
|
package/routes/request.js
CHANGED
@@ -2362,7 +2362,7 @@ async function scheduleTags(id_project, tags) {
|
|
2362
2362
|
if (err) {
|
2363
2363
|
winston.error("Scheduling error: ", err);
|
2364
2364
|
} else {
|
2365
|
-
winston.
|
2365
|
+
winston.verbose("Scheduling result: ", result);
|
2366
2366
|
}
|
2367
2367
|
})
|
2368
2368
|
})
|
@@ -62,7 +62,7 @@ class ChatbotService {
|
|
62
62
|
},
|
63
63
|
method: 'GET'
|
64
64
|
}).then((resbody) => {
|
65
|
-
winston.
|
65
|
+
winston.debug("(CHATBOT SERVICE) forking public chatbot " + resbody.data.name);
|
66
66
|
let chatbot = resbody.data;
|
67
67
|
return chatbot
|
68
68
|
}).catch((err) => {
|
@@ -165,8 +165,8 @@ class OpenaiService {
|
|
165
165
|
}
|
166
166
|
|
167
167
|
getContentChunks(namespace_id, content_id, engine) {
|
168
|
-
winston.
|
169
|
-
|
168
|
+
winston.debug("[OPENAI SERVICE] kb endpoint: " + kb_endpoint_train);
|
169
|
+
|
170
170
|
return new Promise((resolve, reject) => {
|
171
171
|
|
172
172
|
let payload = { engine: engine };
|