@tiledesk/tiledesk-server 2.4.52 → 2.4.54
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +3 -0
- package/app.js +5 -2
- package/docs/api-dev.md +42 -1
- package/models/faq.js +6 -0
- package/models/segment.js +67 -0
- package/package.json +2 -2
- package/routes/faq.js +66 -23
- package/routes/faq_kb.js +7 -3
- package/routes/kbsettings.js +76 -29
- package/routes/lead.js +22 -2
- package/routes/openai.js +112 -0
- package/routes/segment.js +157 -0
- package/routes/users.js +24 -0
- package/services/emailService.js +33 -0
- package/services/openaiService.js +110 -0
- package/template/email/redirectToDesktopEmail.html +304 -0
- package/template/email/redirectToDesktopEmail_new.html +303 -0
- package/test/faqRoute.js +116 -51
- package/test/openaiRoute.js +134 -0
- package/test/userRoute.js +63 -0
- package/utils/segment2mongoConverter.js +98 -0
- package/routes/openai_kbs.js +0 -58
- package/test/openaiKbsRoute.js +0 -75
@@ -0,0 +1,303 @@
|
|
1
|
+
<!DOCTYPE html
|
2
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
|
5
|
+
style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
6
|
+
|
7
|
+
<head>
|
8
|
+
<meta name="viewport" content="width=device-width" />
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
10
|
+
<title>Join Tiledesk from Desktop</title>
|
11
|
+
|
12
|
+
<style type="text/css">
|
13
|
+
img {
|
14
|
+
max-width: 100%;
|
15
|
+
text-align: center !important;
|
16
|
+
}
|
17
|
+
|
18
|
+
img.CToWUd {
|
19
|
+
margin-bottom: 16px;
|
20
|
+
max-width: 200px !important;
|
21
|
+
width: 200px !important;
|
22
|
+
min-width: 200px !important;
|
23
|
+
outline: none;
|
24
|
+
text-decoration: none;
|
25
|
+
border: none;
|
26
|
+
height: auto;
|
27
|
+
margin-left: 0px;
|
28
|
+
}
|
29
|
+
|
30
|
+
body {
|
31
|
+
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
32
|
+
box-sizing: border-box;
|
33
|
+
font-size: 14px;
|
34
|
+
-webkit-font-smoothing: antialiased;
|
35
|
+
-webkit-text-size-adjust: none;
|
36
|
+
width: 100% !important;
|
37
|
+
height: 100%;
|
38
|
+
line-height: 1.6em;
|
39
|
+
background-color: #f6f6f6;
|
40
|
+
margin: 0;
|
41
|
+
}
|
42
|
+
|
43
|
+
.content {
|
44
|
+
width: 100%;
|
45
|
+
display: flex;
|
46
|
+
margin-top: 16px;
|
47
|
+
}
|
48
|
+
|
49
|
+
.inner-content {
|
50
|
+
width: 556px;
|
51
|
+
}
|
52
|
+
|
53
|
+
.content-box {
|
54
|
+
width: 100%;
|
55
|
+
background-color: white;
|
56
|
+
border: solid 1px #e9e9e9;
|
57
|
+
border-radius: 6px;
|
58
|
+
}
|
59
|
+
|
60
|
+
.header-image-container {
|
61
|
+
margin-top: 10px;
|
62
|
+
height: 40px;
|
63
|
+
background-image: url("https://tiledesk.com/wp-content/uploads/2022/08/tiledesk_v1-1.png");
|
64
|
+
background-size: contain;
|
65
|
+
background-position: center;
|
66
|
+
background-repeat: no-repeat;
|
67
|
+
}
|
68
|
+
|
69
|
+
.title-container {
|
70
|
+
width: 100%;
|
71
|
+
display: flex;
|
72
|
+
margin-top: 20px;
|
73
|
+
}
|
74
|
+
|
75
|
+
.text-container {
|
76
|
+
padding: 20px 30px;
|
77
|
+
text-align: center;
|
78
|
+
}
|
79
|
+
|
80
|
+
.custom-divider {
|
81
|
+
width: 94%;
|
82
|
+
height: 1px;
|
83
|
+
border: none;
|
84
|
+
background-color: #cacaca;
|
85
|
+
}
|
86
|
+
|
87
|
+
.custom-button {
|
88
|
+
background-color: #ff8574 !important;
|
89
|
+
border: none;
|
90
|
+
color: white !important;
|
91
|
+
padding: 6px 18px;
|
92
|
+
text-align: center;
|
93
|
+
text-decoration: none;
|
94
|
+
display: inline-block;
|
95
|
+
font-size: 14px;
|
96
|
+
font-weight: 600;
|
97
|
+
letter-spacing: 1px;
|
98
|
+
margin: 4px 2px;
|
99
|
+
cursor: pointer;
|
100
|
+
border-radius: 8px;
|
101
|
+
}
|
102
|
+
|
103
|
+
.footer {
|
104
|
+
width: 100%;
|
105
|
+
text-align: center;
|
106
|
+
padding: 12px 0px
|
107
|
+
}
|
108
|
+
|
109
|
+
.powered-by-container {
|
110
|
+
display: flex;
|
111
|
+
padding: 20px 18px;
|
112
|
+
color: #888888;
|
113
|
+
}
|
114
|
+
|
115
|
+
.social-button-container {
|
116
|
+
display: flex;
|
117
|
+
}
|
118
|
+
|
119
|
+
.social-icon-container {
|
120
|
+
border: solid 1px;
|
121
|
+
border-radius: 14px;
|
122
|
+
width: 20px;
|
123
|
+
height: 20px;
|
124
|
+
padding: 4px;
|
125
|
+
margin: 0px 6px;
|
126
|
+
cursor: pointer;
|
127
|
+
}
|
128
|
+
|
129
|
+
.unsubscribe-container {
|
130
|
+
align-items: center;
|
131
|
+
margin-top: 30px;
|
132
|
+
}
|
133
|
+
|
134
|
+
.site-link {
|
135
|
+
font-size: 12px;
|
136
|
+
font-weight: bold;
|
137
|
+
color: #999;
|
138
|
+
}
|
139
|
+
|
140
|
+
.unsubscribe-link {
|
141
|
+
font-size: 12px;
|
142
|
+
color: #999;
|
143
|
+
}
|
144
|
+
|
145
|
+
@media only screen and (max-width: 640px) {
|
146
|
+
body {
|
147
|
+
padding: 0 !important;
|
148
|
+
}
|
149
|
+
|
150
|
+
h1 {
|
151
|
+
font-weight: 800 !important;
|
152
|
+
margin: 20px 0 5px !important;
|
153
|
+
text-align: center !important;
|
154
|
+
}
|
155
|
+
|
156
|
+
h2 {
|
157
|
+
font-weight: 800 !important;
|
158
|
+
margin: 20px 0 5px !important;
|
159
|
+
}
|
160
|
+
|
161
|
+
h3 {
|
162
|
+
font-weight: 800 !important;
|
163
|
+
margin: 20px 0 5px !important;
|
164
|
+
}
|
165
|
+
|
166
|
+
h4 {
|
167
|
+
font-weight: 800 !important;
|
168
|
+
margin: 20px 0 5px !important;
|
169
|
+
}
|
170
|
+
|
171
|
+
h1 {
|
172
|
+
font-size: 22px !important;
|
173
|
+
}
|
174
|
+
|
175
|
+
h2 {
|
176
|
+
font-size: 18px !important;
|
177
|
+
}
|
178
|
+
|
179
|
+
h3 {
|
180
|
+
font-size: 16px !important;
|
181
|
+
}
|
182
|
+
|
183
|
+
.inner-content {
|
184
|
+
width: auto;
|
185
|
+
padding: 0px 8px;
|
186
|
+
}
|
187
|
+
|
188
|
+
.content-box {
|
189
|
+
width: auto;
|
190
|
+
}
|
191
|
+
|
192
|
+
.text-container {
|
193
|
+
padding: 20px 10px;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
</style>
|
197
|
+
</head>
|
198
|
+
|
199
|
+
<body itemscope itemtype="http://schema.org/EmailMessage" bgcolor="#f6f6f6">
|
200
|
+
|
201
|
+
<div class="content" style="flex-direction: column;align-items: center;">
|
202
|
+
<div class="inner-content">
|
203
|
+
|
204
|
+
<div class="content-box">
|
205
|
+
<div class="header-image-container"></div>
|
206
|
+
<div class="title-container" style="justify-content: center;">
|
207
|
+
<h2>Get Ready for a Full Tiledesk Experience!</h2>
|
208
|
+
</div>
|
209
|
+
<div class="text-container">
|
210
|
+
For the optimal Tiledesk experience, we recommend using it on a desktop device. We've made
|
211
|
+
access easier for you with a personalized link.
|
212
|
+
|
213
|
+
<div style="margin-top: 20px; font-weight: 600;">Access Tiledesk on your desktop now 👇</div>
|
214
|
+
<div style="margin-top: 10px;">
|
215
|
+
<a href="{{baseScope.baseUrl}}/{{project_id}}/home?token={{token}}" class="custom-button" style="color: white;">
|
216
|
+
Enjoy Tiledesk
|
217
|
+
</a>
|
218
|
+
</div>
|
219
|
+
|
220
|
+
<div style="margin-top: 40px; text-align: left;">
|
221
|
+
Alternatively, simply copy and paste this URL into your browser:
|
222
|
+
<div>
|
223
|
+
<a
|
224
|
+
href="{{baseScope.baseUrl}}/{{project_id}}/home?token={{token}}">
|
225
|
+
{{baseScope.baseUrl}}/{{project_id}}/home
|
226
|
+
</a>
|
227
|
+
</div>
|
228
|
+
</div>
|
229
|
+
</div>
|
230
|
+
|
231
|
+
<hr class="custom-divider">
|
232
|
+
|
233
|
+
<div class="powered-by-container" style="align-items: center;">
|
234
|
+
<span>Powered by </span>
|
235
|
+
<span style="display: flex;"><img
|
236
|
+
src="https://tiledesk.com/wp-content/uploads/2023/05/tiledesk-solo_logo_new_gray.png" width="15"
|
237
|
+
height="15" style="margin-left: 6px; margin-top: 2px;" /></span>
|
238
|
+
<span style="font-weight: bold; margin-left: 2px;">Tiledesk</span>
|
239
|
+
</div>
|
240
|
+
|
241
|
+
</div>
|
242
|
+
|
243
|
+
<div class="footer">
|
244
|
+
<div style="margin-bottom: 10px; font-style: italic;">Follow us on:</div>
|
245
|
+
<div class="social-button-container" style="flex-direction: row; justify-content: center;">
|
246
|
+
|
247
|
+
<!-- Facebook -->
|
248
|
+
<a href="https://www.facebook.com/tiledesk" target="_blank">
|
249
|
+
<div class="social-icon-container" style="border-color: #3d6ad6;">
|
250
|
+
<img
|
251
|
+
src="https://github.com/Tiledesk/tiledesk-dashboard/assets/45603238/f762a3d7-541a-4b78-ae33-c35cdbe3b083"
|
252
|
+
width="20px" height="20px" />
|
253
|
+
</div>
|
254
|
+
</a>
|
255
|
+
|
256
|
+
<!-- YouTube -->
|
257
|
+
<a href="https://www.youtube.com/@tiledesk" target="_blank">
|
258
|
+
<div class="social-icon-container" style="border-color: #e7332f;">
|
259
|
+
<img
|
260
|
+
src="https://github.com/Tiledesk/tiledesk-dashboard/assets/45603238/5dc5be2d-8bd3-43cf-b1ca-f12a36c01f1a"
|
261
|
+
width="20px" height="20px" />
|
262
|
+
</div>
|
263
|
+
</a>
|
264
|
+
|
265
|
+
<!-- Linkedin -->
|
266
|
+
<a href="https://www.linkedin.com/company/tiledesk/" target="_blank">
|
267
|
+
<div class="social-icon-container" style="border-color: #1f77b5;">
|
268
|
+
<img
|
269
|
+
src="https://github.com/Tiledesk/tiledesk-dashboard/assets/45603238/52d8909f-c847-4b44-8dfb-7cd041e481c3"
|
270
|
+
width="20px" height="20px" />
|
271
|
+
</div>
|
272
|
+
</a>
|
273
|
+
|
274
|
+
<!-- Instagram -->
|
275
|
+
<a href="https://www.instagram.com/tiledesk/" target="_blank">
|
276
|
+
<div class="social-icon-container" style="border-color: #f78881;">
|
277
|
+
<img
|
278
|
+
src="https://github.com/Tiledesk/tiledesk-dashboard/assets/45603238/4c35afe2-277a-4fdd-8e50-0844148216c8"
|
279
|
+
width="20px" height="20px" />
|
280
|
+
</div>
|
281
|
+
</a>
|
282
|
+
|
283
|
+
<!-- Twitter -->
|
284
|
+
<a href="https://twitter.com/tiledesk" target="_blank">
|
285
|
+
<div class="social-icon-container" style="border-color: #2ea1f2;">
|
286
|
+
<img
|
287
|
+
src="https://github.com/Tiledesk/tiledesk-dashboard/assets/45603238/3288635e-50b6-4b2d-bccc-0c9313dd11a5"
|
288
|
+
width="20px" height="20px" />
|
289
|
+
</div>
|
290
|
+
</a>
|
291
|
+
|
292
|
+
</div>
|
293
|
+
|
294
|
+
<div class="unsubscribe-container" style="display: flex;flex-direction: column;">
|
295
|
+
<a href="http://www.tiledesk.com" class="site-link">Tiledesk.com </a>
|
296
|
+
<a href="%unsubscribe_url%" class="unsubscribe-link">Unsubscribe</a>
|
297
|
+
</div>
|
298
|
+
|
299
|
+
</div>
|
300
|
+
</div>
|
301
|
+
</div>
|
302
|
+
|
303
|
+
</body>
|
package/test/faqRoute.js
CHANGED
@@ -19,7 +19,7 @@ const path = require('path');
|
|
19
19
|
var expect = chai.expect;
|
20
20
|
var assert = chai.assert;
|
21
21
|
|
22
|
-
let log =
|
22
|
+
let log = false;
|
23
23
|
|
24
24
|
chai.use(chaiHttp);
|
25
25
|
|
@@ -27,7 +27,7 @@ describe('FaqKBRoute', () => {
|
|
27
27
|
|
28
28
|
describe('/create', () => {
|
29
29
|
|
30
|
-
it('create', (done) => {
|
30
|
+
it('create qwerty', (done) => {
|
31
31
|
|
32
32
|
// this.timeout();
|
33
33
|
|
@@ -41,8 +41,7 @@ describe('FaqKBRoute', () => {
|
|
41
41
|
.auth(email, pwd)
|
42
42
|
.send({ "name": "testbot", type: "internal" })
|
43
43
|
.end((err, res) => {
|
44
|
-
|
45
|
-
console.log("res.body", res.body);
|
44
|
+
if (log) { console.log("create bot res.body", res.body); }
|
46
45
|
res.should.have.status(200);
|
47
46
|
res.body.should.be.a('object');
|
48
47
|
expect(res.body.name).to.equal("testbot");
|
@@ -55,8 +54,7 @@ describe('FaqKBRoute', () => {
|
|
55
54
|
.auth(email, pwd)
|
56
55
|
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1", attributes: { attr1: { one: "one", two: "two"}, attr2: {three: "three"}}, intent_id: 'custom-intent-id' }) // if intent_id is null the value will be the default one
|
57
56
|
.end((err, res) => {
|
58
|
-
|
59
|
-
console.log("res.body", res.body);
|
57
|
+
if (log) { console.log("create intent res.body", res.body); }
|
60
58
|
res.should.have.status(200);
|
61
59
|
res.body.should.be.a('object');
|
62
60
|
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
@@ -108,8 +106,7 @@ describe('FaqKBRoute', () => {
|
|
108
106
|
.auth(email, pwd)
|
109
107
|
.send({ "name": "testbot", type: "external", language: 'fr' })
|
110
108
|
.end((err, res) => {
|
111
|
-
|
112
|
-
console.log("res.body", res.body);
|
109
|
+
if (log) { console.log("res.body", res.body); }
|
113
110
|
res.should.have.status(200);
|
114
111
|
res.body.should.be.a('object');
|
115
112
|
expect(res.body.name).to.equal("testbot");
|
@@ -121,8 +118,7 @@ describe('FaqKBRoute', () => {
|
|
121
118
|
.auth(email, pwd)
|
122
119
|
.send({ id_faq_kb: id_faq_kb, form: example_form })
|
123
120
|
.end((err, res) => {
|
124
|
-
|
125
|
-
console.log("res.body", res.body);
|
121
|
+
if (log) { console.log("res.body", res.body); }
|
126
122
|
res.should.have.status(200);
|
127
123
|
res.body.should.be.a('object');
|
128
124
|
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
@@ -156,8 +152,7 @@ describe('FaqKBRoute', () => {
|
|
156
152
|
.auth(email, pwd)
|
157
153
|
.send({ "name": "testbot", type: "internal", template: "example", language: "it" })
|
158
154
|
.end((err, res) => {
|
159
|
-
|
160
|
-
console.log("res.body", res.body);
|
155
|
+
if (log) { console.log("res.body", res.body); }
|
161
156
|
res.should.have.status(200);
|
162
157
|
res.body.should.be.a('object');
|
163
158
|
expect(res.body.name).to.equal("testbot");
|
@@ -169,8 +164,7 @@ describe('FaqKBRoute', () => {
|
|
169
164
|
.auth(email, pwd)
|
170
165
|
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1" })
|
171
166
|
.end((err, res) => {
|
172
|
-
|
173
|
-
console.log("res.body", res.body);
|
167
|
+
if (log) { console.log("res.body", res.body); }
|
174
168
|
res.should.have.status(200);
|
175
169
|
res.body.should.be.a('object');
|
176
170
|
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
@@ -206,8 +200,7 @@ describe('FaqKBRoute', () => {
|
|
206
200
|
.auth(email, pwd)
|
207
201
|
.send({ "name": "testbot", type: "internal", template: "example", })
|
208
202
|
.end((err, res) => {
|
209
|
-
|
210
|
-
console.log("res.body", res.body);
|
203
|
+
if (log) { console.log("res.body", res.body); }
|
211
204
|
res.should.have.status(200);
|
212
205
|
res.body.should.be.a('object');
|
213
206
|
expect(res.body.name).to.equal("testbot");
|
@@ -218,8 +211,7 @@ describe('FaqKBRoute', () => {
|
|
218
211
|
.auth(email, pwd)
|
219
212
|
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1", webhook_enabled: true, intent_display_name: "intent_display_name1" })
|
220
213
|
.end((err, res) => {
|
221
|
-
|
222
|
-
console.log("res.body", res.body);
|
214
|
+
if (log) { console.log("res.body", res.body); }
|
223
215
|
res.should.have.status(200);
|
224
216
|
res.body.should.be.a('object');
|
225
217
|
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
@@ -254,8 +246,7 @@ describe('FaqKBRoute', () => {
|
|
254
246
|
.auth(email, pwd)
|
255
247
|
.send({ "name": "testbot", type: "internal" })
|
256
248
|
.end((err, res) => {
|
257
|
-
|
258
|
-
console.log("res.body", res.body);
|
249
|
+
if (log) { console.log("res.body", res.body); }
|
259
250
|
res.should.have.status(200);
|
260
251
|
res.body.should.be.a('object');
|
261
252
|
expect(res.body.name).to.equal("testbot");
|
@@ -266,8 +257,7 @@ describe('FaqKBRoute', () => {
|
|
266
257
|
.auth(email, pwd)
|
267
258
|
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1", attributes: { attr1: {one: "one", two: "two"}} })
|
268
259
|
.end((err, res) => {
|
269
|
-
|
270
|
-
console.log("res.body", res.body);
|
260
|
+
if (log) { console.log("res.body", res.body); }
|
271
261
|
res.should.have.status(200);
|
272
262
|
res.body.should.be.a('object');
|
273
263
|
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
@@ -281,8 +271,7 @@ describe('FaqKBRoute', () => {
|
|
281
271
|
.auth(email, pwd)
|
282
272
|
.send({ id_faq_kb: id_faq_kb, question: "question2", answer: "answer2", webhook_enabled: true, attributes: { two: "twooo" } })
|
283
273
|
.end((err, res) => {
|
284
|
-
|
285
|
-
console.log("res.body", res.body);
|
274
|
+
if (log) { console.log("res.body", res.body); }
|
286
275
|
res.should.have.status(200);
|
287
276
|
res.body.should.be.a('object');
|
288
277
|
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
@@ -306,8 +295,6 @@ describe('FaqKBRoute', () => {
|
|
306
295
|
|
307
296
|
it('update attributes', (done) => {
|
308
297
|
|
309
|
-
console.log("update attributes test start... ");
|
310
|
-
|
311
298
|
var email = "test-signup-" + Date.now() + "@email.com";
|
312
299
|
var pwd = "pwd";
|
313
300
|
|
@@ -318,8 +305,7 @@ describe('FaqKBRoute', () => {
|
|
318
305
|
.auth(email, pwd)
|
319
306
|
.send({ "name": "testbot", type: "internal" })
|
320
307
|
.end((err, res) => {
|
321
|
-
|
322
|
-
console.log("res.body", res.body);
|
308
|
+
if (log) { console.log("res.body", res.body); }
|
323
309
|
res.should.have.status(200);
|
324
310
|
res.body.should.be.a('object');
|
325
311
|
expect(res.body.name).to.equal("testbot");
|
@@ -330,8 +316,7 @@ describe('FaqKBRoute', () => {
|
|
330
316
|
.auth(email, pwd)
|
331
317
|
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1" })
|
332
318
|
.end((err, res) => {
|
333
|
-
|
334
|
-
console.log("res.body", res.body);
|
319
|
+
if (log) { console.log("res.body", res.body); }
|
335
320
|
res.should.have.status(200);
|
336
321
|
res.body.should.be.a('object');
|
337
322
|
expect(res.body.id_faq_kb).to.equal(id_faq_kb);
|
@@ -353,9 +338,10 @@ describe('FaqKBRoute', () => {
|
|
353
338
|
}
|
354
339
|
})
|
355
340
|
.end((err, res) => {
|
356
|
-
|
357
|
-
|
358
|
-
|
341
|
+
if (log) {
|
342
|
+
console.log("res.body attributes", res.body);
|
343
|
+
console.log("res.body attributes", res.body.attributes);
|
344
|
+
}
|
359
345
|
res.should.have.status(200);
|
360
346
|
res.body.should.be.a('object');
|
361
347
|
expect(res.body.attributes).to.not.equal(undefined);
|
@@ -389,8 +375,7 @@ describe('FaqKBRoute', () => {
|
|
389
375
|
.auth(email, pwd)
|
390
376
|
.send({ "name": "testbot", type: "internal" })
|
391
377
|
.end((err, res) => {
|
392
|
-
|
393
|
-
console.log("res.body", res.body);
|
378
|
+
if (log) { console.log("res.body", res.body); }
|
394
379
|
res.should.have.status(200);
|
395
380
|
res.body.should.be.a('object');
|
396
381
|
expect(res.body.name).to.equal("testbot");
|
@@ -405,8 +390,8 @@ describe('FaqKBRoute', () => {
|
|
405
390
|
.field('delimiter', ';')
|
406
391
|
// .send({id_faq_kb: id_faq_kb})
|
407
392
|
.end((err, res) => {
|
408
|
-
console.log("err", err);
|
409
|
-
console.log("res.body", res.body);
|
393
|
+
if (err) { console.log("err", err); }
|
394
|
+
if (log) { console.log("res.body", res.body); }
|
410
395
|
res.should.have.status(200);
|
411
396
|
res.body.should.be.a('object');
|
412
397
|
|
@@ -420,12 +405,6 @@ describe('FaqKBRoute', () => {
|
|
420
405
|
|
421
406
|
});
|
422
407
|
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
408
|
it('uploadcsvWithLanguage', (done) => {
|
430
409
|
|
431
410
|
|
@@ -442,8 +421,7 @@ describe('FaqKBRoute', () => {
|
|
442
421
|
.auth(email, pwd)
|
443
422
|
.send({ "name": "testbot", type: "internal", language: "it" })
|
444
423
|
.end((err, res) => {
|
445
|
-
|
446
|
-
console.log("res.body", res.body);
|
424
|
+
if (log) { console.log("res.body", res.body); }
|
447
425
|
res.should.have.status(200);
|
448
426
|
res.body.should.be.a('object');
|
449
427
|
expect(res.body.name).to.equal("testbot");
|
@@ -459,8 +437,10 @@ describe('FaqKBRoute', () => {
|
|
459
437
|
.field('delimiter', ';')
|
460
438
|
// .send({id_faq_kb: id_faq_kb})
|
461
439
|
.end((err, res) => {
|
462
|
-
|
463
|
-
|
440
|
+
if (err) {
|
441
|
+
console.log("err", err);
|
442
|
+
}
|
443
|
+
if (log) { console.log("res.body", res.body); }
|
464
444
|
res.should.have.status(200);
|
465
445
|
res.body.should.be.a('object');
|
466
446
|
|
@@ -544,10 +524,7 @@ describe('FaqKBRoute', () => {
|
|
544
524
|
.auth(email, pwd)
|
545
525
|
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1" })
|
546
526
|
.end((err, res) => {
|
547
|
-
|
548
|
-
// }
|
549
|
-
|
550
|
-
console.log("intentEngin on resbody (create faq): \n", res.body);
|
527
|
+
if (log) { console.log("intentEngin on resbody (create faq): \n", res.body); }
|
551
528
|
res.should.have.status(200);
|
552
529
|
|
553
530
|
done();
|
@@ -558,6 +535,94 @@ describe('FaqKBRoute', () => {
|
|
558
535
|
})
|
559
536
|
});
|
560
537
|
|
538
|
+
it('delete with _id', (done) => {
|
539
|
+
|
540
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
541
|
+
var pwd = "pwd";
|
542
|
+
|
543
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
544
|
+
projectService.create("test-search-faqs", savedUser._id).then((savedProject) => {
|
545
|
+
|
546
|
+
chai.request(server)
|
547
|
+
.post('/' + savedProject._id + '/faq_kb')
|
548
|
+
.auth(email, pwd)
|
549
|
+
.send({ "name": "testbot", type: "internal", template: "example", intentsEngine: 'tiledesk-ai' })
|
550
|
+
.end((err, res) => {
|
551
|
+
if (log) { console.log("create chatbot res.body", res.body); }
|
552
|
+
res.should.have.status(200);
|
553
|
+
res.body.should.be.a('object');
|
554
|
+
expect(res.body.name).to.equal("testbot");
|
555
|
+
var id_faq_kb = res.body._id;
|
556
|
+
|
557
|
+
chai.request(server)
|
558
|
+
.post('/' + savedProject._id + '/faq')
|
559
|
+
.auth(email, pwd)
|
560
|
+
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1" })
|
561
|
+
.end((err, res) => {
|
562
|
+
if (log) { console.log("create intent res.body", res.body); }
|
563
|
+
res.should.have.status(200);
|
564
|
+
let faqid = res.body._id;
|
565
|
+
|
566
|
+
chai.request(server)
|
567
|
+
.delete('/' + savedProject._id + '/faq/' + faqid)
|
568
|
+
.auth(email, pwd)
|
569
|
+
.end((err, res) => {
|
570
|
+
if (log) { console.log("delete intent res.body", res.body); }
|
571
|
+
res.should.have.status(200);
|
572
|
+
|
573
|
+
done();
|
574
|
+
})
|
575
|
+
|
576
|
+
})
|
577
|
+
})
|
578
|
+
})
|
579
|
+
})
|
580
|
+
});
|
581
|
+
|
582
|
+
it('delete with intent_id', (done) => {
|
583
|
+
|
584
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
585
|
+
var pwd = "pwd";
|
586
|
+
|
587
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
588
|
+
projectService.create("test-search-faqs", savedUser._id).then((savedProject) => {
|
589
|
+
|
590
|
+
chai.request(server)
|
591
|
+
.post('/' + savedProject._id + '/faq_kb')
|
592
|
+
.auth(email, pwd)
|
593
|
+
.send({ "name": "testbot", type: "internal", template: "example", intentsEngine: 'tiledesk-ai' })
|
594
|
+
.end((err, res) => {
|
595
|
+
if (log) { console.log("create chatbot res.body", res.body); }
|
596
|
+
res.should.have.status(200);
|
597
|
+
res.body.should.be.a('object');
|
598
|
+
expect(res.body.name).to.equal("testbot");
|
599
|
+
var id_faq_kb = res.body._id;
|
600
|
+
|
601
|
+
chai.request(server)
|
602
|
+
.post('/' + savedProject._id + '/faq')
|
603
|
+
.auth(email, pwd)
|
604
|
+
.send({ id_faq_kb: id_faq_kb, question: "question1", answer: "answer1" })
|
605
|
+
.end((err, res) => {
|
606
|
+
if (log) { console.log("create intent res.body", res.body); }
|
607
|
+
res.should.have.status(200);
|
608
|
+
let faqid = res.body.intent_id;
|
609
|
+
|
610
|
+
chai.request(server)
|
611
|
+
.delete('/' + savedProject._id + '/faq/intentId' + faqid)
|
612
|
+
.auth(email, pwd)
|
613
|
+
.end((err, res) => {
|
614
|
+
if (log) { console.log("delete intent res.body", res.body); }
|
615
|
+
res.should.have.status(200);
|
616
|
+
|
617
|
+
done();
|
618
|
+
})
|
619
|
+
|
620
|
+
})
|
621
|
+
})
|
622
|
+
})
|
623
|
+
})
|
624
|
+
});
|
625
|
+
|
561
626
|
|
562
627
|
});
|
563
628
|
|