@tiledesk/tiledesk-server 2.4.97 → 2.4.99
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 +8 -0
- package/package.json +1 -1
- package/routes/faq_kb.js +20 -4
- package/services/chatbotService.js +4 -3
- package/test/chatbot-mock.js +6 -0
- package/test/faqkbRoute.js +64 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
🚀 IN PRODUCTION 🚀
|
|
6
6
|
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
|
|
7
7
|
|
|
8
|
+
# 2.4.99
|
|
9
|
+
- Updated whatsapp-connector to 0.1.62
|
|
10
|
+
- Updated messenger-connector to 0.1.16
|
|
11
|
+
- Bug fix: globals are not exported when a chatbot is published
|
|
12
|
+
|
|
13
|
+
# 2.4.98
|
|
14
|
+
- Updated whatsapp-connector to 0.1.61
|
|
15
|
+
|
|
8
16
|
# 2.4.97
|
|
9
17
|
- Updated whatsapp-connector to 0.1.61
|
|
10
18
|
|
package/package.json
CHANGED
package/routes/faq_kb.js
CHANGED
|
@@ -637,17 +637,27 @@ router.post('/fork/:id_faq_kb', async (req, res) => {
|
|
|
637
637
|
let public = req.query.public;
|
|
638
638
|
winston.debug("public " + public);
|
|
639
639
|
|
|
640
|
+
let globals = req.query.globals;
|
|
641
|
+
winston.debug("export globals " + globals);
|
|
642
|
+
console.log("export globals? --> globals ", globals);
|
|
643
|
+
|
|
640
644
|
let token = req.headers.authorization;
|
|
641
645
|
|
|
642
646
|
let cs = req.app.get('chatbot_service')
|
|
643
647
|
|
|
644
|
-
let chatbot = await cs.getBotById(id_faq_kb, public, api_url, chatbot_templates_api_url, token, current_project_id);
|
|
648
|
+
let chatbot = await cs.getBotById(id_faq_kb, public, api_url, chatbot_templates_api_url, token, current_project_id, globals);
|
|
645
649
|
winston.debug("chatbot: ", chatbot)
|
|
646
|
-
|
|
650
|
+
console.log("/fork chatbot after getBotById: ", chatbot);
|
|
647
651
|
if (!chatbot) {
|
|
648
652
|
return res.status(500).send({ success: false, message: "Unable to get chatbot" });
|
|
649
653
|
}
|
|
650
654
|
|
|
655
|
+
if (!globals) {
|
|
656
|
+
if (chatbot.attributes) {
|
|
657
|
+
delete chatbot.attributes.globals
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
651
661
|
let savedChatbot = await cs.createBot(api_url, token, chatbot, landing_project_id);
|
|
652
662
|
winston.debug("savedChatbot: ", savedChatbot)
|
|
653
663
|
|
|
@@ -972,6 +982,7 @@ router.post('/importjson/:id_faq_kb', upload.single('uploadFile'), async (req, r
|
|
|
972
982
|
router.get('/exportjson/:id_faq_kb', (req, res) => {
|
|
973
983
|
|
|
974
984
|
winston.debug("exporting bot...")
|
|
985
|
+
console.log("exportjson req.query.globals: ", req.query.globals);
|
|
975
986
|
|
|
976
987
|
|
|
977
988
|
let id_faq_kb = req.params.id_faq_kb;
|
|
@@ -988,8 +999,13 @@ router.get('/exportjson/:id_faq_kb', (req, res) => {
|
|
|
988
999
|
// delete from exclude map intent_id
|
|
989
1000
|
const intents = faqs.map(({ _id, id_project, topic, status, id_faq_kb, createdBy, createdAt, updatedAt, __v, ...keepAttrs }) => keepAttrs)
|
|
990
1001
|
|
|
991
|
-
if (
|
|
992
|
-
|
|
1002
|
+
if (!req.query.globals) {
|
|
1003
|
+
console.log("Delete globals from attributes!")
|
|
1004
|
+
if (faq_kb.attributes) {
|
|
1005
|
+
delete faq_kb.attributes.globals;
|
|
1006
|
+
}
|
|
1007
|
+
} else {
|
|
1008
|
+
console.log("Keep globals")
|
|
993
1009
|
}
|
|
994
1010
|
|
|
995
1011
|
let json = {
|
|
@@ -12,7 +12,7 @@ class ChatbotService {
|
|
|
12
12
|
winston.debug("[CHATBOT SERVICE] fork");
|
|
13
13
|
|
|
14
14
|
return await axios({
|
|
15
|
-
url: api_url + '/' + project_id + '/faq_kb/fork/'+id_faq_kb+"?projectid="+project_id+"&public=false",
|
|
15
|
+
url: api_url + '/' + project_id + '/faq_kb/fork/'+id_faq_kb+"?projectid="+project_id+"&public=false&globals=true",
|
|
16
16
|
headers: {
|
|
17
17
|
'Content-Type': 'application/json',
|
|
18
18
|
'Authorization': token
|
|
@@ -29,15 +29,16 @@ class ChatbotService {
|
|
|
29
29
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async getBotById(id_faq_kb, published, api_url, chatbot_templates_api_url, token, project_id) {
|
|
32
|
+
async getBotById(id_faq_kb, published, api_url, chatbot_templates_api_url, token, project_id, globals) {
|
|
33
33
|
|
|
34
34
|
winston.debug("[CHATBOT SERVICE] getBotById");
|
|
35
|
+
console.log("getBotById globals: ", globals);
|
|
35
36
|
|
|
36
37
|
// private bot
|
|
37
38
|
if (published == "false") {
|
|
38
39
|
|
|
39
40
|
return await axios({
|
|
40
|
-
url: api_url + "/" + project_id + "/faq_kb/exportjson/" + id_faq_kb,
|
|
41
|
+
url: api_url + "/" + project_id + "/faq_kb/exportjson/" + id_faq_kb + "?globals=" + globals,
|
|
41
42
|
headers: {
|
|
42
43
|
'Content-Type': 'application/json',
|
|
43
44
|
'Authorization': token
|
package/test/chatbot-mock.js
CHANGED
|
@@ -11,6 +11,12 @@ const existing_chatbot_mock = {
|
|
|
11
11
|
createdAt: "2022-09-15T15:32:06.491Z",
|
|
12
12
|
updatedAt: "2022-09-15T15:32:06.491Z",
|
|
13
13
|
name: "Bot",
|
|
14
|
+
attributes: {
|
|
15
|
+
globals: {
|
|
16
|
+
"mykey1": "myvalue1",
|
|
17
|
+
"mykey2": "myvalue2"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
14
20
|
intents: [
|
|
15
21
|
{
|
|
16
22
|
"webhook_enabled": false,
|
package/test/faqkbRoute.js
CHANGED
|
@@ -947,6 +947,70 @@ describe('FaqKBRoute', () => {
|
|
|
947
947
|
});
|
|
948
948
|
}).timeout(20000);
|
|
949
949
|
|
|
950
|
+
// it('publishChatbot', (done) => {
|
|
951
|
+
|
|
952
|
+
// var email = "test-signup-" + Date.now() + "@email.com";
|
|
953
|
+
// var pwd = "pwd";
|
|
954
|
+
|
|
955
|
+
// userService.signup(email, pwd, "Test Firstname", "Test Lastname").then(function (savedUser) {
|
|
956
|
+
// projectService.create("current-project", savedUser._id).then(function (currentProject) {
|
|
957
|
+
|
|
958
|
+
// console.log("declare chatbot_service functions...")
|
|
959
|
+
|
|
960
|
+
// class chatbot_service {
|
|
961
|
+
// async fork(id, api_url, token, project_id) {
|
|
962
|
+
// console.log("chatbot_service test fork called")
|
|
963
|
+
// return { message: "Chatbot forked successfully", bot_id: savedChatbot._id }
|
|
964
|
+
// //return chatbot_mock.existing_chatbot_mock;
|
|
965
|
+
// }
|
|
966
|
+
|
|
967
|
+
// async getBotById(id, published, api_url, chatbot_templates_api_url, token, project_id, globals) {
|
|
968
|
+
// return chatbot_mock.existing_chatbot_mock;
|
|
969
|
+
// }
|
|
970
|
+
|
|
971
|
+
// async createBot(api_url, token, chatbot, project_id) {
|
|
972
|
+
// return chatbot_mock.empty_chatbot_mock
|
|
973
|
+
// }
|
|
974
|
+
|
|
975
|
+
// async importFaqs(api_url, id_faq_kb, token, chatbot, project_id) {
|
|
976
|
+
// return chatbot_mock.import_faqs_res_mock
|
|
977
|
+
// }
|
|
978
|
+
// }
|
|
979
|
+
|
|
980
|
+
// server.set('chatbot_service', new chatbot_service());
|
|
981
|
+
// console.log("chatbot_service functions declared")
|
|
982
|
+
|
|
983
|
+
// chai.request(server)
|
|
984
|
+
// .post('/' + currentProject._id + '/faq_kb')
|
|
985
|
+
// .auth(email, pwd)
|
|
986
|
+
// .send({ "name": "privateBot", type: "internal", language: 'en', public: "false", template: "blank" })
|
|
987
|
+
// .end((err, res) => {
|
|
988
|
+
// console.log("res.body: ", res.body);
|
|
989
|
+
// if (log) {
|
|
990
|
+
// }
|
|
991
|
+
// res.should.have.status(200);
|
|
992
|
+
// res.body.should.be.a('object');
|
|
993
|
+
// expect(res.body.name).to.equal("privateBot");
|
|
994
|
+
// expect(res.body.language).to.equal("en");
|
|
995
|
+
// let id_faq_kb = res.body._id;
|
|
996
|
+
|
|
997
|
+
// chai.request(server)
|
|
998
|
+
// .put('/' + currentProject._id + '/faq_kb/' + id_faq_kb + '/publish')
|
|
999
|
+
// .auth(email, pwd)
|
|
1000
|
+
// .set('Content-Type', 'application/json')
|
|
1001
|
+
// .end((err, res) => {
|
|
1002
|
+
// console.log("publish bot res.body: ", res.body);
|
|
1003
|
+
// res.should.have.status(200);
|
|
1004
|
+
|
|
1005
|
+
// done();
|
|
1006
|
+
// })
|
|
1007
|
+
// })
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
// })
|
|
1011
|
+
// })
|
|
1012
|
+
// })
|
|
1013
|
+
|
|
950
1014
|
|
|
951
1015
|
});
|
|
952
1016
|
|