@tiledesk/tiledesk-server 2.2.24 → 2.2.29
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +30 -2
- package/README.md +6 -0
- package/app.js +72 -2
- package/bin/www +4 -1
- package/config/email.js +1 -1
- package/config/global.js +2 -0
- package/config/labels/widget.json +781 -611
- package/models/project.js +10 -0
- package/models/project_user.js +2 -0
- package/package.json +4 -3
- package/pubmodules/rules/conciergeBot.js +5 -2
- package/pubmodules/scheduler/tasks/closeBotUnresponsiveRequestTask.js +12 -3
- package/routes/faq_kb.js +2 -3
- package/routes/labels.js +2 -0
- package/routes/project.js +72 -0
- package/routes/project_user.js +9 -2
- package/routes/request.js +15 -0
- package/routes/user-request.js +326 -0
- package/routes/widget.js +1 -1
- package/services/departmentService.js +5 -4
- package/services/emailService.js +2 -2
- package/services/faqService.js +62 -29
- package/utils/orgUtil.js +74 -0
- package/config/labels/widget copy.json +0 -624
- package/services/faqBotSupport copy.js_consplit +0 -453
@@ -283,6 +283,7 @@ getOperators(departmentid, projectid, nobot, disableWebHookCall, context) {
|
|
283
283
|
return resolve ({
|
284
284
|
department: department, available_agents: _available_agents, agents: project_users,
|
285
285
|
id_bot:department.id_bot, project: project,
|
286
|
+
context: context,
|
286
287
|
// botprefix
|
287
288
|
operators: [{ id_user: 'bot_' + department.id_bot }]
|
288
289
|
});
|
@@ -386,7 +387,7 @@ getOperators(departmentid, projectid, nobot, disableWebHookCall, context) {
|
|
386
387
|
selectedoperator = that.getRandomAvailableOperator(_available_agents);
|
387
388
|
}
|
388
389
|
|
389
|
-
let objectToReturn = { available_agents: _available_agents, agents: project_users, operators: selectedoperator, department: department, group: group, id_project: projectid, project: project };
|
390
|
+
let objectToReturn = { available_agents: _available_agents, agents: project_users, operators: selectedoperator, department: department, group: group, id_project: projectid, project: project, context: context };
|
390
391
|
|
391
392
|
that.roundRobin(objectToReturn).then(function(objectToReturnRoundRobin){
|
392
393
|
|
@@ -409,7 +410,7 @@ getOperators(departmentid, projectid, nobot, disableWebHookCall, context) {
|
|
409
410
|
|
410
411
|
} else {
|
411
412
|
// here subscription notifier??
|
412
|
-
var objectToReturn = { available_agents: [], agents: [], operators: [] };
|
413
|
+
var objectToReturn = { available_agents: [], agents: [], operators: [], context: context };
|
413
414
|
return resolve(objectToReturn);
|
414
415
|
}
|
415
416
|
|
@@ -447,7 +448,7 @@ getOperators(departmentid, projectid, nobot, disableWebHookCall, context) {
|
|
447
448
|
selectedoperator = that.getRandomAvailableOperator(_available_agents);
|
448
449
|
}
|
449
450
|
|
450
|
-
let objectToReturn = { available_agents: _available_agents, agents: project_users, operators: selectedoperator, department: department, id_project: projectid, project: project };
|
451
|
+
let objectToReturn = { available_agents: _available_agents, agents: project_users, operators: selectedoperator, department: department, id_project: projectid, project: project, context: context };
|
451
452
|
|
452
453
|
that.roundRobin(objectToReturn).then(function(objectToReturnRoundRobin) {
|
453
454
|
winston.debug("context2",context);
|
@@ -474,7 +475,7 @@ getOperators(departmentid, projectid, nobot, disableWebHookCall, context) {
|
|
474
475
|
|
475
476
|
} else {
|
476
477
|
// here subscription notifier??
|
477
|
-
let objectToReturn = { available_agents: [], agents: [], operators: [] };
|
478
|
+
let objectToReturn = { available_agents: [], agents: [], operators: [], context: context };
|
478
479
|
return resolve(objectToReturn);
|
479
480
|
}
|
480
481
|
|
package/services/emailService.js
CHANGED
@@ -98,13 +98,13 @@ class EmailService {
|
|
98
98
|
this.host = process.env.EMAIL_HOST || config.host;
|
99
99
|
winston.info('EmailService host: ' + this.host);
|
100
100
|
|
101
|
-
this.secure = process.env.EMAIL_SECURE || false;
|
101
|
+
this.secure = process.env.EMAIL_SECURE || false;
|
102
102
|
winston.info('EmailService secure: ' + this.secure);
|
103
103
|
|
104
104
|
this.user = process.env.EMAIL_USERNAME || config.username;
|
105
105
|
winston.info('EmailService username: ' + this.user);
|
106
106
|
|
107
|
-
this.port = process.env.EMAIL_PORT;
|
107
|
+
this.port = process.env.EMAIL_PORT;
|
108
108
|
winston.info('EmailService port: ' + this.port);
|
109
109
|
|
110
110
|
|
package/services/faqService.js
CHANGED
@@ -8,7 +8,7 @@ const ActionsConstants = require('../models/actionsConstants');
|
|
8
8
|
class FaqService {
|
9
9
|
|
10
10
|
|
11
|
-
create(name, url, projectid, user_id, type, description, webhook_url, webhook_enabled, language) {
|
11
|
+
create(name, url, projectid, user_id, type, description, webhook_url, webhook_enabled, language, template) {
|
12
12
|
var that = this;
|
13
13
|
return new Promise(function (resolve, reject) {
|
14
14
|
|
@@ -37,8 +37,15 @@ class FaqService {
|
|
37
37
|
|
38
38
|
botEvent.emit('faqbot.create', savedFaq_kb);
|
39
39
|
|
40
|
+
winston.debug('type '+ type)
|
41
|
+
|
40
42
|
if (type==="internal") {
|
41
|
-
|
43
|
+
|
44
|
+
if (!template) {
|
45
|
+
template = "example";
|
46
|
+
}
|
47
|
+
winston.debug('template '+ template);
|
48
|
+
that.createGreetingsAndOperationalsFaqs(savedFaq_kb._id, savedFaq_kb.createdBy, savedFaq_kb.id_project, template);
|
42
49
|
} else {
|
43
50
|
winston.debug('external bot: ', savedFaq_kb);
|
44
51
|
}
|
@@ -50,33 +57,63 @@ class FaqService {
|
|
50
57
|
});
|
51
58
|
}
|
52
59
|
|
53
|
-
createGreetingsAndOperationalsFaqs(faq_kb_id, created_by, projectid,
|
60
|
+
createGreetingsAndOperationalsFaqs(faq_kb_id, created_by, projectid, template) {
|
54
61
|
var that = this;
|
55
62
|
return new Promise(function (resolve, reject) {
|
56
63
|
|
57
64
|
// aggiungi esempio tdAction con intent_id
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
65
|
+
|
66
|
+
winston.debug('template: '+ template);
|
67
|
+
|
68
|
+
var faqsArray;
|
69
|
+
|
70
|
+
if (template==="example") {
|
71
|
+
|
72
|
+
faqsArray = [
|
73
|
+
{ 'question': 'Hi', 'answer': 'Hi', 'topic': 'greetings' },
|
74
|
+
{ 'question': 'Hello', 'answer': 'Hello', 'topic': 'greetings' },
|
75
|
+
{ 'question': 'Who are you?', 'answer': 'Hi, I\'m a bot 🤖. You can find more about me [here](https://tiledesk.com/chatbot-for-customer-service).\ntdImage:https://console.tiledesk.com/assets/images/tily-welcomebot.gif\n* See the website https://tiledesk.com/\n* Back to start tdAction:start', 'topic': 'greetings' },
|
76
|
+
{ 'question': '👨🏻🦰 I want an agent', 'answer': 'We are looking for an operator.. '+ActionsConstants.CHAT_ACTION_MESSAGE.AGENT, 'intent_display_name': 'agent_handoff', 'topic': 'internal' },
|
77
|
+
{ 'question': 'Close\nResolved', 'answer': ActionsConstants.CHAT_ACTION_MESSAGE.CLOSE, 'topic': 'internal' },
|
78
|
+
{ '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' },
|
79
|
+
{ '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', 'intent_display_name': 'defaultFallback', 'topic': 'internal' }, //TODO se metto spazio n * nn va
|
80
|
+
{ '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' },
|
81
|
+
{ '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' },
|
82
|
+
{ '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' },
|
83
|
+
{ 'question': 'Sample Video', 'answer': 'tdVideo:https://www.youtube.com/embed/EngW7tLk6R8\n* What can you do?\n* Back to start tdAction:start', 'topic': 'sample' },
|
84
|
+
{ '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' },
|
85
|
+
|
86
|
+
// { 'question': 'Sample Webhook', 'answer': 'tdWebhook:https://tiledesk-bot-webhook.tiledesk.repl.co', 'topic': 'sample' },
|
87
|
+
{ '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' },
|
88
|
+
{ 'question': 'Yes Action', 'answer': 'Great! Take a look here:\n* Tiledesk Pricing https://tiledesk.com/pricing-cloud/', 'intent_display_name': 'yes_action','topic': 'sample' },
|
89
|
+
{ 'question': 'No Action', 'answer': 'All right! If you need anything, let us know.', 'intent_display_name': 'no_action','topic': 'sample' },
|
90
|
+
|
91
|
+
|
92
|
+
// action button nn si può fare perche gli id cambiano
|
93
|
+
]
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
if (template==="blank") {
|
98
|
+
|
99
|
+
faqsArray = [
|
100
|
+
{ 'question': '\\start', 'answer': 'Hello', 'intent_display_name': 'start', 'topic': 'internal' },
|
101
|
+
{ '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', 'intent_display_name': 'defaultFallback', 'topic': 'internal' }, //TODO se metto spazio n * nn va
|
102
|
+
]
|
103
|
+
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
if (template==="handoff") {
|
108
|
+
|
109
|
+
faqsArray = [
|
110
|
+
{ 'question': '\\start', 'answer': 'Hello', 'intent_display_name': 'start', 'topic': 'internal' },
|
111
|
+
{ 'question': '👨🏻🦰 I want an agent', 'answer': 'We are looking for an operator.. '+ActionsConstants.CHAT_ACTION_MESSAGE.AGENT, 'intent_display_name': 'agent_handoff', 'topic': 'internal' },
|
112
|
+
{ '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', 'intent_display_name': 'defaultFallback', 'topic': 'internal' }, //TODO se metto spazio n * nn va
|
113
|
+
]
|
114
|
+
|
115
|
+
}
|
116
|
+
|
80
117
|
|
81
118
|
faqsArray.forEach(faq => {
|
82
119
|
|
@@ -101,10 +138,6 @@ class FaqService {
|
|
101
138
|
winston.debug('FAQ SERVICE (save new faq) - QUESTION OF THE NEW GREETINGS FAQ CREATED ', savedFaq.question)
|
102
139
|
winston.debug('FAQ SERVICE (save new faq) - ANSWER OF THE NEW GREETINGS FAQ CREATED ', savedFaq.answer)
|
103
140
|
winston.debug('FAQ SERVICE (save new faq) - ID FAQKB GET IN THE OBJECT OF NEW FAQ CREATED ', savedFaq.id_faq_kb)
|
104
|
-
// res.json({ 'Greetings Faqs': savedFaq });
|
105
|
-
// return resolve(savedFaq);
|
106
|
-
|
107
|
-
// that.createRemoteFaq(remote_faqkb_key, savedFaq);
|
108
141
|
|
109
142
|
})
|
110
143
|
});
|
package/utils/orgUtil.js
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
'use strict';
|
4
|
+
var global = require('../config/global');
|
5
|
+
var email = require('../config/email');
|
6
|
+
var winston = require('../config/winston');
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
class OrgUtil {
|
12
|
+
|
13
|
+
constructor() {
|
14
|
+
this.ORGANIZATION_ENABLED = process.env.ORGANIZATION_ENABLED || global.organizationEnabled;
|
15
|
+
if (this.ORGANIZATION_ENABLED===true || this.ORGANIZATION_ENABLED === "true") {
|
16
|
+
this.ORGANIZATION_ENABLED = true;
|
17
|
+
}else {
|
18
|
+
this.ORGANIZATION_ENABLED = false;
|
19
|
+
}
|
20
|
+
|
21
|
+
winston.info("Organization enabled: "+ this.ORGANIZATION_ENABLED );
|
22
|
+
|
23
|
+
this.ORGANIZATION_BASE_URL = process.env.ORGANIZATION_BASE_URL || global.organizationBaseUrl;
|
24
|
+
winston.info("Organization base url: "+ this.ORGANIZATION_BASE_URL );
|
25
|
+
|
26
|
+
}
|
27
|
+
|
28
|
+
getOrg(req) {
|
29
|
+
|
30
|
+
// if (this.ORGANIZATION_ENABLED===false) {
|
31
|
+
// return undefined;
|
32
|
+
// }
|
33
|
+
|
34
|
+
|
35
|
+
// let host = req.get('host');
|
36
|
+
// winston.info("host: "+ host );
|
37
|
+
|
38
|
+
let origin = req.get('origin');
|
39
|
+
winston.info("origin: "+ origin );
|
40
|
+
|
41
|
+
// winston.info("email: " + email.baseUrl);
|
42
|
+
winston.info("this.ORGANIZATION_BASE_URL: " + this.ORGANIZATION_BASE_URL);
|
43
|
+
// global.organizationBaseUrl
|
44
|
+
// if (host !=email.baseUrl ) {
|
45
|
+
if (origin && origin.indexOf(this.ORGANIZATION_BASE_URL)>-1) {
|
46
|
+
// if (origin!=this.ORGANIZATION_BASE_URL) {
|
47
|
+
// winston.info("host found: "+ host );
|
48
|
+
// return host;
|
49
|
+
winston.info("origin found: "+ origin );
|
50
|
+
return origin;
|
51
|
+
}
|
52
|
+
winston.info("origin not found: "+ origin );
|
53
|
+
|
54
|
+
// winston.info("host not found: "+ host );
|
55
|
+
// if (host.indexOf("localhost1")>-1) {
|
56
|
+
// console.log("host found: "+ host );
|
57
|
+
// return "localhost";
|
58
|
+
// }
|
59
|
+
return undefined;
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
var orgUtil = new OrgUtil();
|
72
|
+
|
73
|
+
|
74
|
+
module.exports = orgUtil;
|