@tiledesk/tiledesk-server 2.3.76 β 2.3.78
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 +32 -4
- package/docs/api-mgm.md +1 -68
- package/models/faq.js +1 -0
- package/models/faq_kb.js +9 -2
- package/package.json +3 -3
- package/pubmodules/cache/mongoose-cachegoose-fn.js +34 -1
- package/pubmodules/kaleyra/listener.js +15 -11
- package/pubmodules/whatsapp/listener.js +22 -3
- package/routes/faq_kb.js +22 -3
- package/services/faqService.js +1 -0
package/CHANGELOG.md
CHANGED
@@ -1,9 +1,31 @@
|
|
1
1
|
|
2
2
|
|
3
|
-
π₯ TILEDESK SERVER v2.3.
|
3
|
+
π₯ TILEDESK SERVER v2.3.77 π₯
|
4
4
|
π TAGGED AND PUBLISHED ON NPM π
|
5
5
|
π IN PRODUCTION π
|
6
|
-
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.
|
6
|
+
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
|
7
|
+
|
8
|
+
|
9
|
+
# 2.3.77 -> PROD v3
|
10
|
+
- Updated tiledesk/tiledesk-whatsapp-connector dependency to 0.1.24
|
11
|
+
- Added KALEYRA_API_URL environment variable
|
12
|
+
- Now GRAPH_URL environment variable is optional
|
13
|
+
- Added bot cache invalidation for new radis key without project for tilebot
|
14
|
+
- Added chatbot fulltext endpoint
|
15
|
+
|
16
|
+
# 2.3.76
|
17
|
+
- Adedd tag to bot model
|
18
|
+
- \\n fix for public private key
|
19
|
+
- Chatbot invalidation fix when created
|
20
|
+
- @tiledesk/tiledesk-tybot-connector@0.1.53
|
21
|
+
|
22
|
+
# 2.3.75
|
23
|
+
- @tiledesk/tiledesk-tybot-connector@0.1.51
|
24
|
+
|
25
|
+
# 2.3.74
|
26
|
+
- Added cache for bot
|
27
|
+
- @tiledesk/tiledesk-tybot-connector@0.1.50
|
28
|
+
- Added cache for user
|
7
29
|
|
8
30
|
# 2.3.73
|
9
31
|
- Removed unused mongoose-auto-increment dependency
|
@@ -19,9 +41,12 @@
|
|
19
41
|
- Added caching for /widgets endpoint with invalidations
|
20
42
|
- Added bot rules to /widgets endpoint
|
21
43
|
- Select false for resetpswrequestid field of user model
|
22
|
-
- Added support for Public Private Key for JWT Auth with GLOBAL_SECRET_OR_PRIVATE_KEY and GLOBAL_SECRET_OR_PUB_KEY and GLOBAL_SECRET_ALGORITHM environments variables. If these properties are configured Public
|
44
|
+
- Added support for Public Private Key for JWT Auth with GLOBAL_SECRET_OR_PRIVATE_KEY and GLOBAL_SECRET_OR_PUB_KEY and GLOBAL_SECRET_ALGORITHM(default: HS256, RS256 for pub private key) environments variables. If these properties are configured Public/Private Key method is enabled otherwise if only GLOBAL_SECRET env varible is configured the shared secret method is used.
|
23
45
|
- Updated tiledesk/tiledesk-tybot-connector@0.1.48
|
24
46
|
- Removed βsnapshotβ from request payload for external chatbot
|
47
|
+
- Added CHATBOT_TEMPLATES_API_URL env varible
|
48
|
+
- Updated tiledesk/tiledesk-tybot-connector@0.1.49
|
49
|
+
|
25
50
|
|
26
51
|
|
27
52
|
|
@@ -29,7 +54,10 @@
|
|
29
54
|
- Added Kaleyra module
|
30
55
|
- Updated tiledesk-apps to 1.0.12
|
31
56
|
|
32
|
-
# 2.3.71
|
57
|
+
# 2.3.71.1 -> PROD v2
|
58
|
+
- ocf email fix
|
59
|
+
|
60
|
+
# 2.3.71
|
33
61
|
- Email service send email direct fit without request_id
|
34
62
|
- Removed strong from transcript email template
|
35
63
|
- Added for updateWaitingTimeByRequestId the field enable_populate
|
package/docs/api-mgm.md
CHANGED
@@ -1,70 +1,3 @@
|
|
1
1
|
# TILEDESK REST API
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
```
|
6
|
-
curl -v -X POST -d 'email=andrea.leo@f21.it&password=123456' https://api.tiledesk.com/v1/auth/signup
|
7
|
-
```
|
8
|
-
|
9
|
-
### Signin
|
10
|
-
|
11
|
-
```
|
12
|
-
curl -v -X POST -d 'email=andrea.leo@f21.it&password=123456' https://api.tiledesk.com/v1/auth/signin
|
13
|
-
```
|
14
|
-
|
15
|
-
### Firebase signin
|
16
|
-
|
17
|
-
```
|
18
|
-
curl -v -X POST -d 'email=andrea.leo@f21.it&password=123456' https://api.tiledesk.com/v1/firebase/auth/signin
|
19
|
-
```
|
20
|
-
|
21
|
-
### Departments
|
22
|
-
|
23
|
-
```
|
24
|
-
curl -v -X GET -u andrea.leo@f21.it:123456 https://api.tiledesk.com/v1/5ab0f32757066e0014bfd718/departments
|
25
|
-
```
|
26
|
-
|
27
|
-
#### Get the available operator for a specific department
|
28
|
-
```
|
29
|
-
curl -v -X GET -u andrea.leo@frontiere21.it:123456 https://api.tiledesk.com/v1/5ad4c101e774ac0014ae0d07/departments/5ad5c2c9c975820014ba901b/operators
|
30
|
-
```
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
### Bots
|
35
|
-
|
36
|
-
#### List
|
37
|
-
|
38
|
-
```
|
39
|
-
curl -v -X GET -u andrea.leo@f21.it:123456 https://api.tiledesk.com/v1/5ab0f32757066e0014bfd718/faq_kb
|
40
|
-
```
|
41
|
-
|
42
|
-
#### Create
|
43
|
-
|
44
|
-
```
|
45
|
-
curl -v -X POST -u andrea.leo@f21.it:123456 -d '{"name":"testbot"}' https://api.tiledesk.com/v1/5ab0f32757066e0014bfd718/faq_kb
|
46
|
-
```
|
47
|
-
|
48
|
-
## Analytics
|
49
|
-
```
|
50
|
-
curl -v -X GET -u andrea.leo@f21.it:123456 https://api.tiledesk.com/v1/5ad5bd52c975820014ba900a/analytics/requests/count
|
51
|
-
|
52
|
-
```
|
53
|
-
|
54
|
-
```
|
55
|
-
curl -v -X GET -u andrea.leo@f21.it:123456 https://api.tiledesk.com/v1/5ad5bd52c975820014ba900a/analytics/requests/waiting
|
56
|
-
|
57
|
-
```
|
58
|
-
|
59
|
-
```
|
60
|
-
curl -v -X GET -u andrea.leo@f21.it:123456 https://api.tiledesk.com/v1/5ad5bd52c975820014ba900a/analytics/requests/waiting/day/last
|
61
|
-
```
|
62
|
-
|
63
|
-
```
|
64
|
-
curl -v -X GET -u andrea.leo@f21.it:123456 https://api.tiledesk.com/v1/5ad5bd52c975820014ba900a/analytics/requests/waiting/month
|
65
|
-
```
|
66
|
-
|
67
|
-
|
68
|
-
```
|
69
|
-
curl -v -X GET -u andrea.leo@f21.it:123456 https://api.tiledesk.com/v1/5ad5bd52c975820014ba900a/analytics/requests/aggregate/dayoftheweek/hours
|
70
|
-
```
|
3
|
+
Please refer to the [Developer Portal](https://developer.tiledesk.com/)
|
package/models/faq.js
CHANGED
@@ -155,6 +155,7 @@ FaqSchema.index({ question: 'text' },
|
|
155
155
|
|
156
156
|
|
157
157
|
FaqSchema.index({ id_project: 1, id_faq_kb: 1, intent_display_name: 1 }, { unique: true });
|
158
|
+
FaqSchema.index({ id_project: 1, id_faq_kb: 1, intent_id: 1 }, { unique: true });
|
158
159
|
|
159
160
|
|
160
161
|
var faq = mongoose.model('faq', FaqSchema);
|
package/models/faq_kb.js
CHANGED
@@ -3,6 +3,9 @@ var Schema = mongoose.Schema;
|
|
3
3
|
const uuidv4 = require('uuid/v4');
|
4
4
|
var winston = require('../config/winston');
|
5
5
|
|
6
|
+
var defaultFullTextLanguage = process.env.DEFAULT_FULLTEXT_INDEX_LANGUAGE || "none";
|
7
|
+
|
8
|
+
|
6
9
|
var Faq_kbSchema = new Schema({
|
7
10
|
name: {
|
8
11
|
type: String,
|
@@ -69,12 +72,14 @@ var Faq_kbSchema = new Schema({
|
|
69
72
|
public: {
|
70
73
|
type: Boolean,
|
71
74
|
required: false,
|
72
|
-
default: false
|
75
|
+
default: false,
|
76
|
+
index:true
|
73
77
|
},
|
74
78
|
certified: {
|
75
79
|
type: Boolean,
|
76
80
|
required: false,
|
77
|
-
default: false
|
81
|
+
default: false,
|
82
|
+
index:true
|
78
83
|
},
|
79
84
|
mainCategory: {
|
80
85
|
type: String,
|
@@ -101,6 +106,8 @@ Faq_kbSchema.virtual('fullName').get(function () {
|
|
101
106
|
Faq_kbSchema.index({certified: 1, public: 1}); //suggested by atlas
|
102
107
|
|
103
108
|
|
109
|
+
Faq_kbSchema.index({name: 'text', description: 'text', subject: 'text', "tags": 'text'},
|
110
|
+
{"name":"faqkb_fulltext","default_language": defaultFullTextLanguage,"language_override": "language"}); // schema level
|
104
111
|
|
105
112
|
|
106
113
|
var faq_kb = mongoose.model('faq_kb', Faq_kbSchema);
|
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.3.
|
4
|
+
"version": "2.3.78",
|
5
5
|
"scripts": {
|
6
6
|
"start": "node ./bin/www",
|
7
7
|
"pretest": "mongodb-runner start",
|
@@ -43,8 +43,8 @@
|
|
43
43
|
"@tiledesk/tiledesk-json-rules-engine": "^4.0.3",
|
44
44
|
"@tiledesk/tiledesk-kaleyra-proxy": "^0.1.6",
|
45
45
|
"@tiledesk/tiledesk-rasa-connector": "^1.0.10",
|
46
|
-
"@tiledesk/tiledesk-tybot-connector": "^0.1.
|
47
|
-
"@tiledesk/tiledesk-whatsapp-connector": "^0.1.
|
46
|
+
"@tiledesk/tiledesk-tybot-connector": "^0.1.55",
|
47
|
+
"@tiledesk/tiledesk-whatsapp-connector": "^0.1.30",
|
48
48
|
"amqplib": "^0.5.5",
|
49
49
|
"app-root-path": "^3.0.0",
|
50
50
|
"bcrypt-nodejs": "0.0.3",
|
@@ -423,7 +423,15 @@
|
|
423
423
|
winston.debug("Deleted cache for faq_kb.update secret",reply);
|
424
424
|
winston.verbose("Deleted cache for faq_kb.update secret",{err:err});
|
425
425
|
});
|
426
|
-
|
426
|
+
|
427
|
+
// without project for tilebot
|
428
|
+
key = "faq_kbs:id:"+faq_kb._id;
|
429
|
+
winston.verbose("Deleting cache for faq_kb.update without project for tilebot with key: " + key);
|
430
|
+
client.del(key, function (err, reply) {
|
431
|
+
winston.debug("Deleted cache for faq_kb.update without project for tilebot ",reply);
|
432
|
+
winston.verbose("Deleted cache for faq_kb.update without project for tilebot ",{err:err});
|
433
|
+
});
|
434
|
+
|
427
435
|
// TODO invalidate widgets here
|
428
436
|
winston.verbose("Deleting widgets cache for faqbot.update");
|
429
437
|
invalidateWidgets(client, faq_kb.id_project); //TESTED
|
@@ -446,6 +454,15 @@
|
|
446
454
|
client.del(key, function (err, reply) {
|
447
455
|
winston.debug("Deleted cache for faq_kb.delete secret",reply);
|
448
456
|
winston.verbose("Deleted cache for faq_kb.delete secret",{err:err});
|
457
|
+
});
|
458
|
+
|
459
|
+
|
460
|
+
// without project for tilebot
|
461
|
+
key = "faq_kbs:id:"+faq_kb._id;
|
462
|
+
winston.verbose("Deleting cache for faq_kb.update without project for tilebot with key: " + key);
|
463
|
+
client.del(key, function (err, reply) {
|
464
|
+
winston.debug("Deleted cache for faq_kb.update without project for tilebot ",reply);
|
465
|
+
winston.verbose("Deleted cache for faq_kb.update without project for tilebot ",{err:err});
|
449
466
|
});
|
450
467
|
|
451
468
|
// TODO invalidate widgets here
|
@@ -458,6 +475,7 @@
|
|
458
475
|
|
459
476
|
faqBotEvent.on("faq.create", function(faq) {
|
460
477
|
setImmediate(() => {
|
478
|
+
|
461
479
|
// TODO invalidate widgets here
|
462
480
|
winston.verbose("Deleting widgets cache for faq.create");
|
463
481
|
invalidateWidgets(client, faq.id_project); //tested
|
@@ -466,6 +484,8 @@
|
|
466
484
|
|
467
485
|
faqBotEvent.on("faq.update", function(faq) {
|
468
486
|
setImmediate(() => {
|
487
|
+
invalidateFaq(client, faq);
|
488
|
+
|
469
489
|
// TODO invalidate widgets here
|
470
490
|
winston.verbose("Deleting widgets cache for faq.update");
|
471
491
|
invalidateWidgets(client, faq.id_project);//tested
|
@@ -474,6 +494,8 @@
|
|
474
494
|
|
475
495
|
faqBotEvent.on("faq.delete", function(faq) {
|
476
496
|
setImmediate(() => {
|
497
|
+
invalidateFaq(client, faq);
|
498
|
+
|
477
499
|
// TODO invalidate widgets here
|
478
500
|
winston.verbose("Deleting widgets cache for faq.delete",faq);
|
479
501
|
invalidateWidgets(client, faq.id_project);//tested
|
@@ -689,6 +711,17 @@
|
|
689
711
|
}
|
690
712
|
|
691
713
|
|
714
|
+
function invalidateFaq(client, faq) {
|
715
|
+
key = "faqs:botid:"+faq.id_faq_kb+":faq:id:*";
|
716
|
+
winston.info("Deleting cache for faq with key: " + key);
|
717
|
+
client.del(key, function (err, reply) {
|
718
|
+
winston.debug("Deleted cache for faq",reply);
|
719
|
+
winston.info("Deleted cache for faq",{err:err});
|
720
|
+
});
|
721
|
+
|
722
|
+
|
723
|
+
}
|
724
|
+
|
692
725
|
function invalidateWidgets(client, project_id) {
|
693
726
|
key = project_id+":widgets";
|
694
727
|
winston.verbose("Deleting cache for widgets with key: " + key);
|
@@ -13,17 +13,21 @@ class Listener {
|
|
13
13
|
winston.debug("kaleyra config databaseUri: " + config.databaseUri);
|
14
14
|
}
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
if (!process.env.KALEYRA_API_URL || !process.env.API_KEY) {
|
17
|
+
winston.info("Skip Kaleyra startApp")
|
18
|
+
} else {
|
19
|
+
kaleyra.startApp({
|
20
|
+
MONGODB_URL: config.databaseUri,
|
21
|
+
API_URL: apiUrl,
|
22
|
+
BASE_URL: apiUrl + "/modules/kaleyra",
|
23
|
+
APPS_API_URL: apiUrl + "/modules/apps",
|
24
|
+
KALEYRA_API_URL: process.env.KALEYRA_API_URL,
|
25
|
+
API_KEY: process.env.API_KEY,
|
26
|
+
log: process.env.KALEYRA_LOG
|
27
|
+
}, () => {
|
28
|
+
winston.info("Tiledesk Kaleyra proxy server succesfully started.");
|
29
|
+
})
|
30
|
+
}
|
27
31
|
}
|
28
32
|
}
|
29
33
|
|
@@ -13,13 +13,32 @@ class Listener {
|
|
13
13
|
winston.debug("whatsapp config databaseUri: " + config.databaseUri);
|
14
14
|
}
|
15
15
|
|
16
|
+
var port = process.env.CACHE_REDIS_PORT || 6379;
|
17
|
+
winston.debug("-Redis port: "+ port);
|
18
|
+
|
19
|
+
var host = process.env.CACHE_REDIS_HOST || "127.0.0.1"
|
20
|
+
winston.debug("-Redis host: "+ host);
|
21
|
+
|
22
|
+
var password = process.env.REDIS_PASSWORD;
|
23
|
+
winston.debug("-Redis password: "+ password);
|
24
|
+
|
25
|
+
|
26
|
+
let graph_url = process.env.META_GRAPH_URL || config.graphUrl || "https://graph.facebook.com/v14.0/"
|
27
|
+
winston.debug("Whatsapp graph_url: "+ password);
|
28
|
+
|
29
|
+
let log = process.env.WHATSAPP_LOG || false
|
30
|
+
winston.debug("Whatsapp log: "+ log);
|
31
|
+
|
16
32
|
whatsapp.startApp({
|
17
33
|
MONGODB_URL: config.databaseUri,
|
18
34
|
API_URL: apiUrl,
|
19
|
-
GRAPH_URL:
|
35
|
+
GRAPH_URL: graph_url,
|
20
36
|
BASE_URL: apiUrl + "/modules/whatsapp",
|
21
|
-
APPS_API_URL: apiUrl + "/modules/apps",
|
22
|
-
|
37
|
+
APPS_API_URL: apiUrl + "/modules/apps",
|
38
|
+
REDIS_HOST: host,
|
39
|
+
REDIS_PORT: port,
|
40
|
+
REDIS_PASSWORD: password,
|
41
|
+
log: log
|
23
42
|
}, () => {
|
24
43
|
winston.info("Tiledesk WhatsApp Connector proxy server succesfully started.");
|
25
44
|
})
|
package/routes/faq_kb.js
CHANGED
@@ -255,6 +255,7 @@ router.put('/:faq_kbid', function (req, res) {
|
|
255
255
|
update.tags = req.body.tags;
|
256
256
|
}
|
257
257
|
|
258
|
+
|
258
259
|
Faq_kb.findByIdAndUpdate(req.params.faq_kbid, update, { new: true, upsert: true }, function (err, updatedFaq_kb) {
|
259
260
|
if (err) {
|
260
261
|
return res.status(500).send({ success: false, msg: 'Error updating object.' });
|
@@ -319,7 +320,7 @@ router.delete('/:faq_kbid', function (req, res) {
|
|
319
320
|
|
320
321
|
winston.debug(req.body);
|
321
322
|
|
322
|
-
|
323
|
+
|
323
324
|
Faq_kb.remove({ _id: req.params.faq_kbid }, function (err, faq_kb) {
|
324
325
|
if (err) {
|
325
326
|
return res.status(500).send({ success: false, msg: 'Error deleting object.' });
|
@@ -393,12 +394,30 @@ router.get('/', function (req, res) {
|
|
393
394
|
query.type = { $ne: "identity" }
|
394
395
|
}
|
395
396
|
|
396
|
-
|
397
|
+
var search_obj = {"$search": req.query.text};
|
398
|
+
|
399
|
+
if (req.query.text) {
|
400
|
+
if (req.query.language) {
|
401
|
+
search_obj["$language"] = req.query.language;
|
402
|
+
}
|
403
|
+
query.$text = search_obj;
|
404
|
+
}
|
405
|
+
|
406
|
+
if (req.query.public) {
|
407
|
+
query.public = req.query.public;
|
408
|
+
}
|
409
|
+
|
410
|
+
if (req.query.certified) {
|
411
|
+
query.certified = req.query.certified;
|
412
|
+
}
|
413
|
+
|
414
|
+
|
415
|
+
winston.info("query", query);
|
397
416
|
|
398
417
|
Faq_kb.find(query, function (err, faq_kb) {
|
399
418
|
if (err) {
|
400
419
|
winston.error('GET FAQ-KB ERROR ', err)
|
401
|
-
return (
|
420
|
+
return res.status(500).send({ success: false, message: "Unable to get chatbots" });
|
402
421
|
}
|
403
422
|
|
404
423
|
res.json(faq_kb);
|