@tiledesk/tiledesk-server 2.3.6 → 2.3.7-1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/docker-community-worker-push-latest.yml +23 -0
- package/.github/workflows/docker-image-tag-worker-community-tag-push.yml +22 -0
- package/CHANGELOG.md +361 -3
- package/Dockerfile-jobs +31 -0
- package/app.js +62 -69
- package/channels/chat21/chat21Handler.js +37 -6
- package/channels/chat21/chat21WebHook.js +62 -34
- package/channels/chat21/package-lock.json +663 -706
- package/channels/chat21/package.json +2 -2
- package/config/labels/widget.json +337 -136
- package/deploy.sh +2 -0
- package/event/messageEvent.js +110 -9
- package/jobs.js +80 -0
- package/jobsManager.js +47 -0
- package/middleware/has-role.js +10 -3
- package/middleware/ipFilter.js +220 -0
- package/middleware/passport.js +8 -2
- package/models/department.js +1 -1
- package/models/faq.js +77 -25
- package/models/faq_kb.js +19 -0
- package/models/message.js +10 -8
- package/models/project.js +10 -0
- package/models/project_user.js +10 -0
- package/models/request.js +12 -1
- package/package.json +12 -11
- package/pubmodules/activities/activityArchiver.js +216 -90
- package/pubmodules/activities/routes/activity.js +1 -1
- package/pubmodules/apps/index.js +8 -0
- package/pubmodules/apps/listener.js +27 -0
- package/pubmodules/cache/index.js +2 -0
- package/pubmodules/cache/mongoose-cachegoose-fn.js +630 -0
- package/pubmodules/canned/cannedResponse.js +4 -0
- package/pubmodules/canned/cannedResponseRoute.js +10 -5
- package/pubmodules/dialogflow/index.js +10 -0
- package/pubmodules/dialogflow/listener.js +66 -0
- package/pubmodules/emailNotification/requestNotification.js +58 -28
- package/pubmodules/events/eventRoute.js +49 -24
- package/pubmodules/messageTransformer/messageHandlebarsTransformerInterceptor.js +6 -1
- package/pubmodules/messageTransformer/messageTransformerInterceptor.js +10 -4
- package/pubmodules/pubModulesManager.js +173 -7
- package/pubmodules/queue/index.js +4 -0
- package/pubmodules/queue/reconnect.js +331 -0
- package/pubmodules/queue/reconnectFanout.js +256 -0
- package/pubmodules/rasa/listener.js +5 -5
- package/pubmodules/routing-queue/index.js +3 -0
- package/pubmodules/routing-queue/listener.js +328 -0
- package/pubmodules/rules/conciergeBot.js +2 -2
- package/pubmodules/scheduler/tasks/closeAgentUnresponsiveRequestTask.js +6 -1
- package/pubmodules/scheduler/tasks/closeBotUnresponsiveRequestTask.js +7 -1
- package/pubmodules/tilebot/index.js +11 -0
- package/pubmodules/tilebot/listener.js +85 -0
- package/pubmodules/trigger/rulesTrigger.js +137 -14
- package/pubmodules/trigger/start.js +5 -1
- package/pubmodules/whatsapp/index.js +7 -0
- package/pubmodules/whatsapp/listener.js +32 -0
- package/routes/auth.js +7 -2
- package/routes/campaigns.js +3 -3
- package/routes/department.js +3 -2
- package/routes/email.js +32 -2
- package/routes/faq.js +37 -2
- package/routes/faq_kb.js +496 -133
- package/routes/faqpub.js +5 -0
- package/routes/lead.js +56 -0
- package/routes/message.js +196 -14
- package/routes/messagesRoot.js +39 -0
- package/routes/project.js +76 -4
- package/routes/project_user.js +11 -1
- package/routes/project_user_test.js +19 -0
- package/routes/request.js +134 -30
- package/routes/troubleshooting.js +12 -0
- package/routes/users-util.js +39 -0
- package/routes/users.js +1 -1
- package/routes/widget.js +64 -2
- package/services/BotSubscriptionNotifier.js +5 -0
- package/services/banUserNotifier.js +86 -0
- package/services/cacheEnabler.js +56 -0
- package/services/chatbotService.js +101 -0
- package/services/departmentService.js +25 -3
- package/services/emailService.js +170 -28
- package/services/faqBotHandler.js +2 -3
- package/services/faqService.js +28 -3
- package/services/geoService.js +36 -6
- package/services/labelService.js +1 -1
- package/services/leadService.js +3 -2
- package/services/messageService.js +4 -2
- package/services/modulesManager.js +23 -76
- package/services/operatingHoursService.js +9 -4
- package/services/requestService.js +75 -39
- package/services/subscriptionNotifier.js +9 -4
- package/services/trainingService.js +106 -0
- package/template/email/assignedEmailMessage.html +21 -11
- package/template/email/assignedRequest.html +21 -11
- package/template/email/beenInvitedExistingUser.html +16 -6
- package/template/email/beenInvitedNewUser.html +16 -6
- package/template/email/emailDirect.html +130 -0
- package/template/email/newMessage.html +18 -8
- package/template/email/newMessageFollower.html +22 -12
- package/template/email/passwordChanged.html +15 -5
- package/template/email/pooledEmailMessage.html +21 -11
- package/template/email/pooledRequest.html +20 -10
- package/template/email/resetPassword.html +15 -5
- package/template/email/sendTranscript.html +7 -4
- package/template/email/ticket.html +17 -7
- package/template/email/verify.html +15 -5
- package/test/cannedRoute.js +157 -0
- package/test/chatbot-mock.js +127 -0
- package/test/example-json-intents.txt +1 -0
- package/test/example-json.txt +1 -0
- package/test/example.json +1 -0
- package/test/faqRoute.js +353 -208
- package/test/faqkbRoute.js +669 -64
- package/test/imageRoute.js +1 -1
- package/test/messageRoute.js +387 -5
- package/test/requestRoute.js +6 -6
- package/test/requestService.js +55 -4
- package/test-int/cache-project.js +90 -0
- package/test-int/cache-project_user.js +88 -0
- package/utils/UIDGenerator.js +20 -0
- package/utils/cacheUtil.js +2 -2
- package/utils/orgUtil.js +3 -3
- package/utils/promiseUtil.js +31 -0
- package/utils/recipientEmailUtil.js +66 -0
- package/utils/sendEmailUtil.js +34 -0
- package/utils/sendMessageUtil.js +1 -1
- package/utils/stringUtil.js +12 -0
- package/websocket/webSocketServer.js +33 -10
package/test/faqRoute.js
CHANGED
@@ -11,353 +11,498 @@ let chaiHttp = require('chai-http');
|
|
11
11
|
let server = require('../app');
|
12
12
|
let should = chai.should();
|
13
13
|
var fs = require('fs');
|
14
|
+
const path = require('path');
|
15
|
+
|
14
16
|
|
15
17
|
// chai.config.includeStack = true;
|
16
18
|
|
17
19
|
var expect = chai.expect;
|
18
20
|
var assert = chai.assert;
|
19
21
|
|
22
|
+
let log = true;
|
23
|
+
|
20
24
|
chai.use(chaiHttp);
|
21
25
|
|
22
26
|
describe('FaqKBRoute', () => {
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
describe('/create', () => {
|
27
29
|
|
28
|
-
|
30
|
+
it('create', (done) => {
|
29
31
|
|
30
|
-
|
31
|
-
// this.timeout();
|
32
|
+
// this.timeout();
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
35
|
+
var pwd = "pwd";
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
38
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
38
39
|
chai.request(server)
|
39
|
-
.post('/'+ savedProject._id + '/faq_kb')
|
40
|
+
.post('/' + savedProject._id + '/faq_kb')
|
40
41
|
.auth(email, pwd)
|
41
|
-
.send({"name":"testbot", type: "internal"})
|
42
|
+
.send({ "name": "testbot", type: "internal" })
|
42
43
|
.end((err, res) => {
|
43
44
|
//console.log("res", res);
|
44
|
-
console.log("res.body",
|
45
|
+
console.log("res.body", res.body);
|
45
46
|
res.should.have.status(200);
|
46
47
|
res.body.should.be.a('object');
|
47
|
-
expect(res.body.name).to.equal("testbot");
|
48
|
+
expect(res.body.name).to.equal("testbot");
|
49
|
+
expect(res.body.public).to.exist;
|
50
|
+
expect(res.body.public).to.equal(false);
|
48
51
|
var id_faq_kb = res.body._id;
|
49
52
|
|
50
|
-
|
51
|
-
.post('/'+ savedProject._id + '/faq')
|
53
|
+
chai.request(server)
|
54
|
+
.post('/' + savedProject._id + '/faq')
|
52
55
|
.auth(email, pwd)
|
53
|
-
.send({id_faq_kb: id_faq_kb, question: "question1", answer: "answer1"})
|
56
|
+
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1" })
|
54
57
|
.end((err, res) => {
|
55
58
|
//console.log("res", res);
|
56
|
-
console.log("res.body",
|
59
|
+
console.log("res.body", res.body);
|
57
60
|
res.should.have.status(200);
|
58
61
|
res.body.should.be.a('object');
|
59
|
-
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
60
|
-
expect(res.body.question).to.equal("question1");
|
61
|
-
expect(res.body.answer).to.equal("answer1");
|
62
|
-
expect(res.body.intent_display_name).to.not.equal(undefined);
|
63
|
-
expect(res.body.webhook_enabled).to.equal(false);
|
64
|
-
|
62
|
+
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
63
|
+
expect(res.body.question).to.equal("question1");
|
64
|
+
expect(res.body.answer).to.equal("answer1");
|
65
|
+
expect(res.body.intent_display_name).to.not.equal(undefined);
|
66
|
+
expect(res.body.webhook_enabled).to.equal(false);
|
67
|
+
|
65
68
|
done();
|
66
69
|
});
|
67
70
|
|
68
71
|
});
|
69
72
|
|
70
|
-
|
73
|
+
|
71
74
|
});
|
75
|
+
});
|
76
|
+
|
77
|
+
});
|
78
|
+
|
79
|
+
it('create with form (createFaqKb function)', (done) => {
|
80
|
+
|
81
|
+
|
82
|
+
// this.timeout();
|
83
|
+
|
84
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
85
|
+
var pwd = "pwd";
|
86
|
+
let example_form = {
|
87
|
+
fields: [
|
88
|
+
{
|
89
|
+
name: "userFullname",
|
90
|
+
type: "text",
|
91
|
+
label: "What is your name?"
|
92
|
+
},
|
93
|
+
{
|
94
|
+
name: "userEmail",
|
95
|
+
type: "text",
|
96
|
+
regex: "/^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'+/0-9=?A-Z^_`a-z{|}~]+(.[-!#$%&'+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/",
|
97
|
+
label: "Your email?",
|
98
|
+
errorLabel: "This email address is invalid\n\nCan you insert a correct email address?"
|
99
|
+
}
|
100
|
+
]
|
101
|
+
}
|
102
|
+
|
103
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
104
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
105
|
+
|
106
|
+
chai.request(server)
|
107
|
+
.post('/' + savedProject._id + '/faq_kb')
|
108
|
+
.auth(email, pwd)
|
109
|
+
.send({ "name": "testbot", type: "external", language: 'fr' })
|
110
|
+
.end((err, res) => {
|
111
|
+
//console.log("res", res);
|
112
|
+
console.log("res.body", res.body);
|
113
|
+
res.should.have.status(200);
|
114
|
+
res.body.should.be.a('object');
|
115
|
+
expect(res.body.name).to.equal("testbot");
|
116
|
+
expect(res.body.language).to.equal("fr");
|
117
|
+
var id_faq_kb = res.body._id;
|
118
|
+
|
119
|
+
chai.request(server)
|
120
|
+
.post('/' + savedProject._id + '/faq')
|
121
|
+
.auth(email, pwd)
|
122
|
+
.send({ id_faq_kb: id_faq_kb, form: example_form })
|
123
|
+
.end((err, res) => {
|
124
|
+
//console.log("res", res);
|
125
|
+
console.log("res.body", res.body);
|
126
|
+
res.should.have.status(200);
|
127
|
+
res.body.should.be.a('object');
|
128
|
+
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
129
|
+
expect(res.body.form).to.exist;
|
130
|
+
res.body.form.should.be.a('object');
|
131
|
+
expect(res.body.intent_display_name).to.not.equal(undefined);
|
132
|
+
expect(res.body.webhook_enabled).to.equal(false);
|
133
|
+
|
134
|
+
done();
|
135
|
+
});
|
136
|
+
});
|
137
|
+
|
138
|
+
|
72
139
|
});
|
73
|
-
|
74
|
-
});
|
140
|
+
});
|
75
141
|
|
142
|
+
}).timeout(20000);
|
76
143
|
|
77
144
|
|
78
145
|
|
146
|
+
it('createWithLanguage', (done) => {
|
147
|
+
|
148
|
+
|
149
|
+
// this.timeout();
|
150
|
+
|
151
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
152
|
+
var pwd = "pwd";
|
153
|
+
|
154
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
155
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
156
|
+
chai.request(server)
|
157
|
+
.post('/' + savedProject._id + '/faq_kb')
|
158
|
+
.auth(email, pwd)
|
159
|
+
.send({ "name": "testbot", type: "internal", template: "example", language: "it" })
|
160
|
+
.end((err, res) => {
|
161
|
+
//console.log("res", res);
|
162
|
+
console.log("res.body", res.body);
|
163
|
+
res.should.have.status(200);
|
164
|
+
res.body.should.be.a('object');
|
165
|
+
expect(res.body.name).to.equal("testbot");
|
166
|
+
expect(res.body.language).to.equal("it");
|
167
|
+
var id_faq_kb = res.body._id;
|
168
|
+
|
169
|
+
chai.request(server)
|
170
|
+
.post('/' + savedProject._id + '/faq')
|
171
|
+
.auth(email, pwd)
|
172
|
+
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1" })
|
173
|
+
.end((err, res) => {
|
174
|
+
//console.log("res", res);
|
175
|
+
console.log("res.body", res.body);
|
176
|
+
res.should.have.status(200);
|
177
|
+
res.body.should.be.a('object');
|
178
|
+
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
179
|
+
expect(res.body.question).to.equal("question1");
|
180
|
+
expect(res.body.answer).to.equal("answer1");
|
181
|
+
expect(res.body.intent_display_name).to.not.equal(undefined);
|
182
|
+
expect(res.body.webhook_enabled).to.equal(false);
|
183
|
+
expect(res.body.language).to.equal("it");
|
184
|
+
done();
|
185
|
+
});
|
186
|
+
|
187
|
+
});
|
188
|
+
|
189
|
+
|
190
|
+
});
|
191
|
+
});
|
79
192
|
|
80
|
-
it('createWithLanguage', (done) => {
|
81
|
-
|
82
|
-
|
83
|
-
// this.timeout();
|
84
|
-
|
85
|
-
var email = "test-signup-" + Date.now() + "@email.com";
|
86
|
-
var pwd = "pwd";
|
87
|
-
|
88
|
-
userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
89
|
-
projectService.create("test-faqkb-create", savedUser._id).then(function(savedProject) {
|
90
|
-
chai.request(server)
|
91
|
-
.post('/'+ savedProject._id + '/faq_kb')
|
92
|
-
.auth(email, pwd)
|
93
|
-
.send({"name":"testbot", type: "internal", language: "it"})
|
94
|
-
.end((err, res) => {
|
95
|
-
//console.log("res", res);
|
96
|
-
console.log("res.body", res.body);
|
97
|
-
res.should.have.status(200);
|
98
|
-
res.body.should.be.a('object');
|
99
|
-
expect(res.body.name).to.equal("testbot");
|
100
|
-
expect(res.body.language).to.equal("it");
|
101
|
-
var id_faq_kb = res.body._id;
|
102
|
-
|
103
|
-
chai.request(server)
|
104
|
-
.post('/'+ savedProject._id + '/faq')
|
105
|
-
.auth(email, pwd)
|
106
|
-
.send({id_faq_kb: id_faq_kb, question: "question1", answer: "answer1"})
|
107
|
-
.end((err, res) => {
|
108
|
-
//console.log("res", res);
|
109
|
-
console.log("res.body", res.body);
|
110
|
-
res.should.have.status(200);
|
111
|
-
res.body.should.be.a('object');
|
112
|
-
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
113
|
-
expect(res.body.question).to.equal("question1");
|
114
|
-
expect(res.body.answer).to.equal("answer1");
|
115
|
-
expect(res.body.intent_display_name).to.not.equal(undefined);
|
116
|
-
expect(res.body.webhook_enabled).to.equal(false);
|
117
|
-
expect(res.body.language).to.equal("it");
|
118
|
-
done();
|
119
|
-
});
|
120
|
-
|
121
|
-
});
|
122
|
-
|
123
|
-
|
124
|
-
});
|
125
|
-
});
|
126
|
-
|
127
193
|
});
|
128
|
-
|
129
|
-
|
130
194
|
|
131
195
|
|
132
196
|
|
133
197
|
|
134
|
-
it('createWithIntentDisplayNameAndWebhookEnalbed', (done) => {
|
135
198
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
199
|
+
|
200
|
+
it('createWithIntentDisplayNameAndWebhookEnalbed', (done) => {
|
201
|
+
|
202
|
+
|
203
|
+
// this.timeout();
|
204
|
+
|
205
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
206
|
+
var pwd = "pwd";
|
207
|
+
|
208
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
209
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
210
|
+
|
145
211
|
chai.request(server)
|
146
|
-
.post('/'+ savedProject._id + '/faq_kb')
|
212
|
+
.post('/' + savedProject._id + '/faq_kb')
|
147
213
|
.auth(email, pwd)
|
148
|
-
.send({"name":"testbot", type: "internal"})
|
214
|
+
.send({ "name": "testbot", type: "internal", template: "example", })
|
149
215
|
.end((err, res) => {
|
150
216
|
//console.log("res", res);
|
151
|
-
console.log("res.body",
|
217
|
+
console.log("res.body", res.body);
|
152
218
|
res.should.have.status(200);
|
153
219
|
res.body.should.be.a('object');
|
154
|
-
expect(res.body.name).to.equal("testbot");
|
220
|
+
expect(res.body.name).to.equal("testbot");
|
155
221
|
var id_faq_kb = res.body._id;
|
156
222
|
|
157
|
-
|
158
|
-
.post('/'+ savedProject._id + '/faq')
|
223
|
+
chai.request(server)
|
224
|
+
.post('/' + savedProject._id + '/faq')
|
159
225
|
.auth(email, pwd)
|
160
|
-
.send({id_faq_kb: id_faq_kb, question: "question1", answer: "answer1", webhook_enabled:true, intent_display_name: "intent_display_name1"})
|
226
|
+
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1", webhook_enabled: true, intent_display_name: "intent_display_name1" })
|
161
227
|
.end((err, res) => {
|
162
228
|
//console.log("res", res);
|
163
|
-
console.log("res.body",
|
229
|
+
console.log("res.body", res.body);
|
164
230
|
res.should.have.status(200);
|
165
231
|
res.body.should.be.a('object');
|
166
|
-
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
167
|
-
expect(res.body.question).to.equal("question1");
|
168
|
-
expect(res.body.answer).to.equal("answer1");
|
169
|
-
expect(res.body.intent_display_name).to.equal("intent_display_name1");
|
170
|
-
expect(res.body.webhook_enabled).to.equal(true);
|
232
|
+
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
233
|
+
expect(res.body.question).to.equal("question1");
|
234
|
+
expect(res.body.answer).to.equal("answer1");
|
235
|
+
expect(res.body.intent_display_name).to.equal("intent_display_name1");
|
236
|
+
expect(res.body.webhook_enabled).to.equal(true);
|
171
237
|
|
172
238
|
done();
|
173
239
|
});
|
174
240
|
|
175
241
|
});
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
242
|
+
|
243
|
+
|
244
|
+
});
|
245
|
+
});
|
246
|
+
|
181
247
|
});
|
182
|
-
|
183
|
-
|
248
|
+
|
249
|
+
|
184
250
|
|
185
251
|
|
186
252
|
|
187
253
|
it('update', (done) => {
|
188
254
|
|
189
|
-
|
255
|
+
|
190
256
|
// this.timeout();
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
257
|
+
|
258
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
259
|
+
var pwd = "pwd";
|
260
|
+
|
261
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
262
|
+
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {
|
263
|
+
chai.request(server)
|
264
|
+
.post('/' + savedProject._id + '/faq_kb')
|
265
|
+
.auth(email, pwd)
|
266
|
+
.send({ "name": "testbot", type: "internal" })
|
267
|
+
.end((err, res) => {
|
268
|
+
//console.log("res", res);
|
269
|
+
console.log("res.body", res.body);
|
270
|
+
res.should.have.status(200);
|
271
|
+
res.body.should.be.a('object');
|
272
|
+
expect(res.body.name).to.equal("testbot");
|
273
|
+
var id_faq_kb = res.body._id;
|
274
|
+
|
197
275
|
chai.request(server)
|
198
|
-
.post('/'+ savedProject._id + '/
|
276
|
+
.post('/' + savedProject._id + '/faq')
|
199
277
|
.auth(email, pwd)
|
200
|
-
.send({
|
278
|
+
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1" })
|
201
279
|
.end((err, res) => {
|
202
280
|
//console.log("res", res);
|
203
|
-
console.log("res.body",
|
281
|
+
console.log("res.body", res.body);
|
204
282
|
res.should.have.status(200);
|
205
283
|
res.body.should.be.a('object');
|
206
|
-
expect(res.body.
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
284
|
+
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
285
|
+
expect(res.body.question).to.equal("question1");
|
286
|
+
expect(res.body.answer).to.equal("answer1");
|
287
|
+
expect(res.body.intent_display_name).to.not.equal(undefined);
|
288
|
+
expect(res.body.webhook_enabled).to.equal(false);
|
289
|
+
|
290
|
+
chai.request(server)
|
291
|
+
.put('/' + savedProject._id + '/faq/' + res.body._id)
|
211
292
|
.auth(email, pwd)
|
212
|
-
.send({id_faq_kb: id_faq_kb, question: "
|
293
|
+
.send({ id_faq_kb: id_faq_kb, question: "question2", answer: "answer2", webhook_enabled: true })
|
213
294
|
.end((err, res) => {
|
214
295
|
//console.log("res", res);
|
215
|
-
console.log("res.body",
|
296
|
+
console.log("res.body", res.body);
|
216
297
|
res.should.have.status(200);
|
217
298
|
res.body.should.be.a('object');
|
218
|
-
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
219
|
-
expect(res.body.question).to.equal("
|
220
|
-
expect(res.body.answer).to.equal("
|
221
|
-
expect(res.body.intent_display_name).to.not.equal(undefined);
|
222
|
-
expect(res.body.webhook_enabled).to.equal(
|
223
|
-
|
224
|
-
chai.request(server)
|
225
|
-
.put('/'+ savedProject._id + '/faq/'+res.body._id)
|
226
|
-
.auth(email, pwd)
|
227
|
-
.send({id_faq_kb: id_faq_kb, question: "question2", answer: "answer2", webhook_enabled:true})
|
228
|
-
.end((err, res) => {
|
229
|
-
//console.log("res", res);
|
230
|
-
console.log("res.body", res.body);
|
231
|
-
res.should.have.status(200);
|
232
|
-
res.body.should.be.a('object');
|
233
|
-
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
234
|
-
expect(res.body.question).to.equal("question2");
|
235
|
-
expect(res.body.answer).to.equal("answer2");
|
236
|
-
expect(res.body.intent_display_name).to.not.equal(undefined);
|
237
|
-
expect(res.body.webhook_enabled).to.equal(true);
|
238
|
-
|
239
|
-
done();
|
240
|
-
});
|
299
|
+
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
300
|
+
expect(res.body.question).to.equal("question2");
|
301
|
+
expect(res.body.answer).to.equal("answer2");
|
302
|
+
expect(res.body.intent_display_name).to.not.equal(undefined);
|
303
|
+
expect(res.body.webhook_enabled).to.equal(true);
|
241
304
|
|
305
|
+
done();
|
242
306
|
});
|
243
|
-
|
307
|
+
|
244
308
|
});
|
245
|
-
|
246
|
-
|
247
|
-
});
|
309
|
+
|
248
310
|
});
|
249
|
-
|
311
|
+
|
312
|
+
|
313
|
+
});
|
250
314
|
});
|
251
315
|
|
252
|
-
|
316
|
+
});
|
317
|
+
|
318
|
+
|
253
319
|
it('uploadcsv', (done) => {
|
254
320
|
|
255
|
-
|
321
|
+
|
256
322
|
// this.timeout();
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
.post('/'+ savedProject._id + '/faq_kb')
|
323
|
+
|
324
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
325
|
+
var pwd = "pwd";
|
326
|
+
|
327
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
328
|
+
projectService.create("test-uploadcsv", savedUser._id).then(function (savedProject) {
|
329
|
+
|
330
|
+
chai.request(server)
|
331
|
+
.post('/' + savedProject._id + '/faq_kb')
|
266
332
|
.auth(email, pwd)
|
267
|
-
.send({"name":"testbot", type: "internal"})
|
333
|
+
.send({ "name": "testbot", type: "internal" })
|
268
334
|
.end((err, res) => {
|
269
335
|
//console.log("res", res);
|
270
|
-
console.log("res.body",
|
336
|
+
console.log("res.body", res.body);
|
271
337
|
res.should.have.status(200);
|
272
338
|
res.body.should.be.a('object');
|
273
|
-
expect(res.body.name).to.equal("testbot");
|
339
|
+
expect(res.body.name).to.equal("testbot");
|
274
340
|
var id_faq_kb = res.body._id;
|
275
341
|
|
276
342
|
chai.request(server)
|
277
|
-
.post('/'+ savedProject._id + '/faq/uploadcsv')
|
343
|
+
.post('/' + savedProject._id + '/faq/uploadcsv')
|
278
344
|
.auth(email, pwd)
|
279
345
|
.set('Content-Type', 'text/csv')
|
280
|
-
.attach('uploadFile',
|
346
|
+
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-faqs.csv')), 'example-faqs.csv')
|
281
347
|
.field('id_faq_kb', id_faq_kb)
|
282
348
|
.field('delimiter', ';')
|
283
349
|
// .send({id_faq_kb: id_faq_kb})
|
284
350
|
.end((err, res) => {
|
285
|
-
console.log("err",
|
286
|
-
console.log("res.body",
|
351
|
+
console.log("err", err);
|
352
|
+
console.log("res.body", res.body);
|
287
353
|
res.should.have.status(200);
|
288
354
|
res.body.should.be.a('object');
|
289
|
-
|
290
|
-
|
355
|
+
|
356
|
+
done();
|
291
357
|
});
|
292
|
-
|
293
|
-
});
|
294
|
-
|
295
|
-
});
|
358
|
+
|
296
359
|
});
|
297
|
-
|
360
|
+
|
361
|
+
});
|
298
362
|
});
|
299
|
-
|
363
|
+
|
364
|
+
});
|
365
|
+
|
366
|
+
|
300
367
|
|
301
368
|
|
302
369
|
|
303
370
|
|
304
371
|
|
305
|
-
|
306
372
|
it('uploadcsvWithLanguage', (done) => {
|
307
373
|
|
308
|
-
|
374
|
+
|
309
375
|
// this.timeout();
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
.post('/'+ savedProject._id + '/faq_kb')
|
376
|
+
|
377
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
378
|
+
var pwd = "pwd";
|
379
|
+
|
380
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
381
|
+
projectService.create("test-uploadcsv", savedUser._id).then(function (savedProject) {
|
382
|
+
|
383
|
+
chai.request(server)
|
384
|
+
.post('/' + savedProject._id + '/faq_kb')
|
319
385
|
.auth(email, pwd)
|
320
|
-
.send({"name":"testbot", type: "internal", language: "it"})
|
386
|
+
.send({ "name": "testbot", type: "internal", language: "it" })
|
321
387
|
.end((err, res) => {
|
322
388
|
//console.log("res", res);
|
323
|
-
console.log("res.body",
|
389
|
+
console.log("res.body", res.body);
|
324
390
|
res.should.have.status(200);
|
325
391
|
res.body.should.be.a('object');
|
326
|
-
expect(res.body.name).to.equal("testbot");
|
327
|
-
expect(res.body.language).to.equal("it");
|
392
|
+
expect(res.body.name).to.equal("testbot");
|
393
|
+
expect(res.body.language).to.equal("it");
|
328
394
|
var id_faq_kb = res.body._id;
|
329
395
|
|
330
396
|
chai.request(server)
|
331
|
-
.post('/'+ savedProject._id + '/faq/uploadcsv')
|
397
|
+
.post('/' + savedProject._id + '/faq/uploadcsv')
|
332
398
|
.auth(email, pwd)
|
333
399
|
.set('Content-Type', 'text/csv')
|
334
|
-
.attach('uploadFile',
|
400
|
+
.attach('uploadFile', fs.readFileSync(path.resolve(__dirname, './example-faqs.csv')), 'example-faqs.csv')
|
335
401
|
.field('id_faq_kb', id_faq_kb)
|
336
402
|
.field('delimiter', ';')
|
337
403
|
// .send({id_faq_kb: id_faq_kb})
|
338
404
|
.end((err, res) => {
|
339
|
-
console.log("err",
|
340
|
-
console.log("res.body",
|
405
|
+
console.log("err", err);
|
406
|
+
console.log("res.body", res.body);
|
341
407
|
res.should.have.status(200);
|
342
408
|
res.body.should.be.a('object');
|
343
|
-
|
344
|
-
|
409
|
+
|
410
|
+
done();
|
345
411
|
});
|
346
|
-
|
347
|
-
});
|
348
|
-
|
349
|
-
});
|
412
|
+
|
350
413
|
});
|
351
|
-
|
414
|
+
|
415
|
+
});
|
352
416
|
});
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
417
|
|
418
|
+
});
|
358
419
|
|
359
420
|
|
360
|
-
|
421
|
+
it('searchFaqs', (done) => {
|
422
|
+
|
423
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
424
|
+
var pwd = "pwd";
|
425
|
+
|
426
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
427
|
+
projectService.create("test-search-faqs", savedUser._id).then((savedProject) => {
|
428
|
+
|
429
|
+
chai.request(server)
|
430
|
+
.post('/' + savedProject._id + '/faq_kb')
|
431
|
+
.auth(email, pwd)
|
432
|
+
.send({ "name": "testbot", type: "internal", template: "example" })
|
433
|
+
.end((err, res) => {
|
434
|
+
if (log) {
|
435
|
+
console.log("res.body", res.body);
|
436
|
+
}
|
437
|
+
res.should.have.status(200);
|
438
|
+
res.body.should.be.a('object');
|
439
|
+
expect(res.body.name).to.equal("testbot");
|
440
|
+
var id_faq_kb = res.body._id;
|
441
|
+
|
442
|
+
|
443
|
+
chai.request(server)
|
444
|
+
//.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
445
|
+
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb + "&page=0&limit=25&text=looking")
|
446
|
+
.auth(email, pwd)
|
447
|
+
.end((err, res) => {
|
448
|
+
if (log) {
|
449
|
+
console.log("found these faqs: \n", res.body);
|
450
|
+
}
|
451
|
+
res.should.have.status(200);
|
452
|
+
res.body.should.be.an('array');
|
453
|
+
|
454
|
+
|
455
|
+
done();
|
456
|
+
|
457
|
+
})
|
458
|
+
})
|
459
|
+
})
|
460
|
+
})
|
461
|
+
});
|
462
|
+
|
463
|
+
it('intentsEngine on', (done) => {
|
464
|
+
|
465
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
466
|
+
var pwd = "pwd";
|
467
|
+
|
468
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
469
|
+
projectService.create("test-search-faqs", savedUser._id).then((savedProject) => {
|
470
|
+
|
471
|
+
chai.request(server)
|
472
|
+
.post('/' + savedProject._id + '/faq_kb')
|
473
|
+
.auth(email, pwd)
|
474
|
+
.send({ "name": "testbot", type: "internal", template: "example", intentsEngine: 'tiledesk-ai' })
|
475
|
+
.end((err, res) => {
|
476
|
+
if (log) {
|
477
|
+
console.log("res.body", res.body);
|
478
|
+
}
|
479
|
+
res.should.have.status(200);
|
480
|
+
res.body.should.be.a('object');
|
481
|
+
expect(res.body.name).to.equal("testbot");
|
482
|
+
var id_faq_kb = res.body._id;
|
483
|
+
|
484
|
+
|
485
|
+
chai.request(server)
|
486
|
+
.post('/' + savedProject._id + '/faq')
|
487
|
+
.auth(email, pwd)
|
488
|
+
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1" })
|
489
|
+
.end((err, res) => {
|
490
|
+
// if (log) {
|
491
|
+
// }
|
492
|
+
|
493
|
+
console.log("intentEngin on resbody (create faq): \n", res.body);
|
494
|
+
res.should.have.status(200);
|
495
|
+
|
496
|
+
done();
|
497
|
+
|
498
|
+
})
|
499
|
+
})
|
500
|
+
})
|
501
|
+
})
|
502
|
+
});
|
503
|
+
|
504
|
+
|
505
|
+
});
|
361
506
|
|
362
507
|
});
|
363
508
|
|