@tiledesk/tiledesk-server 2.2.38 → 2.3.1-8.1
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 +121 -0
- package/LICENSE +14 -657
- package/README.md +36 -21
- package/app.js +35 -62
- package/channels/chat21/chat21Handler.js +18 -3
- package/channels/chat21/chat21WebHook.js +31 -15
- package/channels/chat21/package-lock.json +663 -706
- package/channels/chat21/package.json +2 -2
- package/config/labels/widget.json +320 -0
- package/deploy.sh +2 -0
- package/event/botEvent.js +1 -1
- package/event/subscriptionEvent.js +11 -0
- package/fonts/Roboto-Italic.ttf +0 -0
- package/fonts/Roboto-Medium.ttf +0 -0
- package/fonts/Roboto-MediumItalic.ttf +0 -0
- package/fonts/Roboto-Regular.ttf +0 -0
- package/middleware/ipFilter.js +220 -0
- package/middleware/passport.js +11 -2
- package/models/lead.js +2 -0
- package/models/project.js +10 -0
- package/models/project_user.js +4 -0
- package/models/request.js +50 -12
- package/models/subscriptionLog.js +34 -0
- package/models/tagLibrary.js +42 -0
- package/package.json +6 -11
- package/pubmodules/activities/activityArchiver.js +314 -0
- package/pubmodules/activities/index.js +3 -0
- package/pubmodules/activities/models/activity.js +88 -0
- package/pubmodules/activities/routes/activity.js +710 -0
- package/pubmodules/activities/test/activityRoute.js +85 -0
- package/pubmodules/analytics/analytics.js +1719 -0
- package/pubmodules/analytics/index.js +3 -0
- package/pubmodules/canned/cannedResponse.js +55 -0
- package/pubmodules/canned/cannedResponseRoute.js +163 -0
- package/pubmodules/canned/index.js +3 -0
- package/pubmodules/emailNotification/requestNotification.js +215 -28
- package/pubmodules/events/eventRoute.js +37 -7
- package/pubmodules/messageActions/messageActionsInterceptor.js +4 -2
- package/pubmodules/pubModulesManager.js +140 -7
- package/pubmodules/rasa/index.js +8 -1
- package/pubmodules/rasa/listener.js +30 -9
- package/pubmodules/rules/conciergeBot.js +4 -4
- package/pubmodules/scheduler/tasks/closeAgentUnresponsiveRequestTask.js +3 -1
- package/pubmodules/scheduler/tasks/closeBotUnresponsiveRequestTask.js +5 -3
- package/pubmodules/tilebot/index.js +11 -0
- package/pubmodules/tilebot/listener.js +69 -0
- package/pubmodules/trigger/default.js +271 -0
- package/pubmodules/trigger/event/actionEventEmitter.js +10 -0
- package/pubmodules/trigger/event/flowEventEmitter.js +10 -0
- package/pubmodules/trigger/event/triggerEventEmitter.js +10 -0
- package/pubmodules/trigger/index.js +3 -0
- package/pubmodules/trigger/models/trigger.js +149 -0
- package/pubmodules/trigger/rulesTrigger.js +1181 -0
- package/pubmodules/trigger/start.js +118 -0
- package/pubmodules/trigger/triggerRoute.js +150 -0
- package/routes/auth.js +7 -2
- package/routes/department.js +51 -0
- package/routes/faq.js +7 -0
- package/routes/faq_kb.js +1 -1
- package/routes/group.js +140 -0
- package/routes/lead.js +24 -1
- package/routes/message.js +6 -3
- package/routes/project.js +118 -0
- package/routes/project_user.js +9 -0
- package/routes/public-request.js +280 -2
- package/routes/request.js +124 -17
- package/routes/subscription.js +140 -0
- package/routes/tag.js +138 -0
- package/routes/user-request.js +3 -2
- package/routes/users.js +1 -1
- package/routes/widget.js +80 -3
- package/routes/widgetLoader.js +31 -0
- package/services/banUserNotifier.js +86 -0
- package/services/emailService.js +189 -11
- package/services/faqBotHandler.js +2 -2
- package/services/faqBotSupport.js +0 -1
- package/services/faqService.js +2 -2
- package/services/geoService.js +30 -4
- package/services/leadService.js +2 -0
- package/services/modulesManager.js +16 -182
- package/services/requestService.js +364 -6
- package/services/subscriptionNotifier.js +485 -0
- package/template/email/assignedEmailMessage.html +1 -1
- package/template/email/assignedRequest.html +1 -1
- package/template/email/newMessage.html +1 -1
- package/template/email/newMessageFollower.html +236 -0
- package/template/email/passwordChanged.html +1 -1
- package/template/email/pooledEmailMessage.html +1 -1
- package/template/email/pooledRequest.html +1 -1
- package/template/email/resetPassword.html +2 -2
- package/template/email/ticket.html +1 -1
- package/test/cannedRoute.js +166 -0
- package/test/messageRoute.js +69 -0
- package/test/requestService.js +3 -1
- package/utils/orgUtil.js +3 -3
- package/views/messages.jade +2 -2
- package/websocket/webSocketServer.js +23 -5
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var messageService = require("./messageService");
|
|
2
|
+
var projectEvent = require("../event/projectEvent");
|
|
3
|
+
|
|
4
|
+
var winston = require('../config/winston');
|
|
5
|
+
|
|
6
|
+
var MessageConstants = require("../models/messageConstants");
|
|
7
|
+
|
|
8
|
+
class BanUserNotifier {
|
|
9
|
+
|
|
10
|
+
listen() {
|
|
11
|
+
projectEvent.on("project.update.user.ban", function(data) {
|
|
12
|
+
var project=data.project;
|
|
13
|
+
var banInfo = data.banInfo;
|
|
14
|
+
|
|
15
|
+
winston.debug("User Banned");
|
|
16
|
+
|
|
17
|
+
var message = {
|
|
18
|
+
sender: 'system',
|
|
19
|
+
senderFullname: 'Bot',
|
|
20
|
+
recipient: banInfo.id,
|
|
21
|
+
recipientFullname: banInfo.id,
|
|
22
|
+
text: "User Banned",
|
|
23
|
+
id_project: project._id,
|
|
24
|
+
createdBy: "system",
|
|
25
|
+
attributes: {subtype:"info", messagelabel: {key: "USER_BANNED"} },
|
|
26
|
+
channel_type: MessageConstants.CHANNEL_TYPE.DIRECT,
|
|
27
|
+
status: MessageConstants.CHAT_MESSAGE_STATUS.SENDING,
|
|
28
|
+
// channel: {name: "chat21"}
|
|
29
|
+
};
|
|
30
|
+
messageService.save(message);
|
|
31
|
+
winston.info("User banned", message);
|
|
32
|
+
// messageService.send(
|
|
33
|
+
// 'system',
|
|
34
|
+
// 'Bot',
|
|
35
|
+
// banInfo.id,
|
|
36
|
+
// "User Banned",
|
|
37
|
+
// project._id,
|
|
38
|
+
// 'system',
|
|
39
|
+
// {subtype:"info"},
|
|
40
|
+
// undefined,
|
|
41
|
+
// undefined
|
|
42
|
+
// );
|
|
43
|
+
});
|
|
44
|
+
projectEvent.on("project.update.user.unban", function(data) {
|
|
45
|
+
var project=data.project;
|
|
46
|
+
var banInfo = data.banInfo;
|
|
47
|
+
|
|
48
|
+
winston.debug("User UnBanned: "+banInfo);
|
|
49
|
+
|
|
50
|
+
// var message = {
|
|
51
|
+
// sender: 'system',
|
|
52
|
+
// senderFullname: 'Bot',
|
|
53
|
+
// recipient: banInfo,
|
|
54
|
+
// recipientFullname: banInfo,
|
|
55
|
+
// text: "User Unbanned",
|
|
56
|
+
// id_project: project._id,
|
|
57
|
+
// createdBy: "system",
|
|
58
|
+
// attributes: {subtype:"info", messagelabel: {key: "USER_BANNED"}},
|
|
59
|
+
// channel_type: MessageConstants.CHANNEL_TYPE.DIRECT,
|
|
60
|
+
// status: MessageConstants.CHAT_MESSAGE_STATUS.SENDING,
|
|
61
|
+
// };
|
|
62
|
+
// messageService.save(message);
|
|
63
|
+
// winston.info("User UnBanned", message);
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// messageService.send(
|
|
69
|
+
// 'system',
|
|
70
|
+
// 'Bot',
|
|
71
|
+
// banInfo.id,
|
|
72
|
+
// "User Unbanned",
|
|
73
|
+
// project._id,
|
|
74
|
+
// 'system',
|
|
75
|
+
// {subtype:"info"},
|
|
76
|
+
// undefined,
|
|
77
|
+
// undefined
|
|
78
|
+
// );
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
var banUserNotifier = new BanUserNotifier();
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
module.exports = banUserNotifier;
|
package/services/emailService.js
CHANGED
|
@@ -191,20 +191,24 @@ class EmailService {
|
|
|
191
191
|
user: configEmail.user,
|
|
192
192
|
pass: configEmail.pass
|
|
193
193
|
},
|
|
194
|
+
// secureConnection: false,
|
|
195
|
+
// tls:{
|
|
196
|
+
// ciphers:'SSLv3'
|
|
197
|
+
// },
|
|
194
198
|
|
|
195
|
-
// openssl genrsa -out dkim_private.pem 2048
|
|
199
|
+
// openssl genrsa -out dkim_private.pem 2048
|
|
196
200
|
// openssl rsa -in dkim_private.pem -pubout -outform der 2>/dev/null | openssl base64 -A
|
|
197
201
|
// ->
|
|
198
202
|
// v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAunT2EopDAYnHwAOHd33KhlzjUXJfhmA+fK+cG85i9Pm33oyv1NoGrOynsni0PO6j7oRxxHqs6EMDOw4I/Q0C7aWn20oBomJZehTOkCV2xpuPKESiRktCe/MIZqbkRdypis4jSkFfFFkBHwgkAg5tb11E9elJap0ed/lN5/XlpGedqoypKxp+nEabgYO5mBMMNKRvbHx0eQttRYyIaNkTuMbAaqs4y3TkHOpGvZTJsvUonVMGAstSCfUmXnjF38aKpgyTausTSsxHbaxh3ieUB4ex+svnvsJ4Uh5Skklr+bxLVEHeJN55rxmV67ytLg5XCRWqdKIcJHFvSlm2YwJfcwIDAQABMacAL
|
|
199
203
|
// testdkim._domainkey.tiledesk.com. 86400 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAunT2EopDAYnHwAOHd33KhlzjUXJfhmA+fK+cG85i9Pm33oyv1NoGrOynsni0PO6j7oRxxHqs6EMDOw4I/Q0C7aWn20oBomJZehTOkCV2xpuPKESiRktCe/MIZqbkRdypis4jSkFfFFkBHwgkAg5tb11E9elJap0ed/lN5/XlpGedqoypKxp+nEabgYO5mBMMNKRvbHx0eQttRYyIaNkTuMbAaqs4y3TkHOpGvZTJsvUonVMGAstSCfUmXnjF38aKpgyTausTSsxHbaxh3ieUB4ex+svnvsJ4Uh5Skklr+bxLVEHeJN55rxmV67ytLg5XCRWqdKIcJHFvSlm2YwJfcwIDAQABMacAL"
|
|
200
204
|
|
|
201
|
-
dkim: {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
205
|
+
// dkim: {
|
|
206
|
+
// domainName: "example.com",
|
|
207
|
+
// keySelector: "2017",
|
|
208
|
+
// privateKey: "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBg...",
|
|
209
|
+
// cacheDir: "/tmp",
|
|
210
|
+
// cacheTreshold: 100 * 1024
|
|
211
|
+
// }
|
|
208
212
|
};
|
|
209
213
|
|
|
210
214
|
winston.debug("getTransport transport: ",transport);
|
|
@@ -406,7 +410,9 @@ class EmailService {
|
|
|
406
410
|
}
|
|
407
411
|
}
|
|
408
412
|
|
|
409
|
-
|
|
413
|
+
// troncare nome utnete e nome progetto a max 10 caratteri
|
|
414
|
+
// cambiare in [Nicky:Dashboard Support] Assigned Chat
|
|
415
|
+
// serve per aggiornare native... fai aggiornamento
|
|
410
416
|
|
|
411
417
|
let subject = `[Tiledesk ${project ? project.name : '-'}] New Assigned Chat`;
|
|
412
418
|
|
|
@@ -958,11 +964,12 @@ class EmailService {
|
|
|
958
964
|
|
|
959
965
|
let inReplyTo;
|
|
960
966
|
let references;
|
|
967
|
+
winston.debug("message.request.attributes", message.request.attributes);
|
|
961
968
|
if (message.request.attributes) {
|
|
962
969
|
if (message.request.attributes.email_messageId) {
|
|
963
970
|
inReplyTo = message.request.attributes.email_messageId;
|
|
964
971
|
}
|
|
965
|
-
if (message.attributes.email_references) {
|
|
972
|
+
if (message.request.attributes.email_references) {
|
|
966
973
|
references = message.request.attributes.email_references;
|
|
967
974
|
}
|
|
968
975
|
}
|
|
@@ -1176,6 +1183,177 @@ class EmailService {
|
|
|
1176
1183
|
}
|
|
1177
1184
|
|
|
1178
1185
|
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
async sendFollowerNotification(to, message, project) {
|
|
1196
|
+
|
|
1197
|
+
var that = this;
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
if (project.toJSON) {
|
|
1201
|
+
project = project.toJSON();
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
var html = await this.readTemplate('newMessageFollower.html', project.settings);
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
var envTemplate = process.env.EMAIL_FOLLOWER_HTML_TEMPLATE;
|
|
1208
|
+
winston.debug("envTemplate: " + envTemplate);
|
|
1209
|
+
|
|
1210
|
+
if (envTemplate) {
|
|
1211
|
+
html = envTemplate;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
winston.debug("html: " + html);
|
|
1215
|
+
|
|
1216
|
+
var template = handlebars.compile(html);
|
|
1217
|
+
|
|
1218
|
+
var baseScope = JSON.parse(JSON.stringify(that));
|
|
1219
|
+
delete baseScope.pass;
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
let msgText = message.text;//.replace(/[\n\r]/g, '<br>');
|
|
1223
|
+
msgText = encode(msgText);
|
|
1224
|
+
if (this.markdown) {
|
|
1225
|
+
msgText = marked(msgText);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
winston.debug("msgText: " + msgText);
|
|
1229
|
+
winston.debug("baseScope: " + JSON.stringify(baseScope));
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
var replacements = {
|
|
1233
|
+
message: message,
|
|
1234
|
+
project: project,
|
|
1235
|
+
msgText: msgText,
|
|
1236
|
+
baseScope: baseScope
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
var html = template(replacements);
|
|
1240
|
+
winston.debug("html: " + html);
|
|
1241
|
+
|
|
1242
|
+
const fs = require('fs');
|
|
1243
|
+
fs.writeFileSync('tem1111.html', html);
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
|
|
1247
|
+
let messageId = message._id + "@" + MESSAGE_ID_DOMAIN;
|
|
1248
|
+
|
|
1249
|
+
let replyTo;
|
|
1250
|
+
if (this.replyEnabled) {
|
|
1251
|
+
replyTo = message.request.request_id + this.inboundDomainDomainWithAt;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
let headers;
|
|
1255
|
+
if (message.request) {
|
|
1256
|
+
|
|
1257
|
+
messageId = message.request.request_id + "+" + messageId;
|
|
1258
|
+
|
|
1259
|
+
if (message.request.attributes && message.request.attributes.email_replyTo) {
|
|
1260
|
+
replyTo = message.request.attributes.email_replyTo;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
headers = {"X-TILEDESK-PROJECT-ID": project._id, "X-TILEDESK-REQUEST-ID": message.request.request_id, "X-TILEDESK-TICKET-ID":message.request.ticket_id };
|
|
1264
|
+
|
|
1265
|
+
winston.verbose("messageId: " + messageId);
|
|
1266
|
+
winston.verbose("replyTo: " + replyTo);
|
|
1267
|
+
winston.verbose("email headers", headers);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
|
|
1271
|
+
let inReplyTo;
|
|
1272
|
+
let references;
|
|
1273
|
+
let cc;
|
|
1274
|
+
let ccString;
|
|
1275
|
+
|
|
1276
|
+
if (message.request && message.request.attributes) {
|
|
1277
|
+
winston.debug("email message.request.attributes: ", message.request.attributes);
|
|
1278
|
+
|
|
1279
|
+
if (message.request.attributes.email_messageId) {
|
|
1280
|
+
inReplyTo = message.request.attributes.email_messageId;
|
|
1281
|
+
}
|
|
1282
|
+
if (message.request.attributes.email_references) {
|
|
1283
|
+
references = message.request.attributes.email_references;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
if (message.request.attributes.email_cc) {
|
|
1287
|
+
cc = message.request.attributes.email_cc;
|
|
1288
|
+
}
|
|
1289
|
+
winston.debug("email message.request.attributes.email_ccStr: "+ message.request.attributes.email_ccStr);
|
|
1290
|
+
if (message.request.attributes.email_ccStr!=undefined) {
|
|
1291
|
+
ccString = message.request.attributes.email_ccStr;
|
|
1292
|
+
winston.debug("email set ccString");
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
winston.verbose("email inReplyTo: "+ inReplyTo);
|
|
1296
|
+
winston.verbose("email references: "+ references);
|
|
1297
|
+
winston.verbose("email cc: ", cc);
|
|
1298
|
+
winston.verbose("email ccString: "+ ccString);
|
|
1299
|
+
|
|
1300
|
+
let from;
|
|
1301
|
+
let configEmail;
|
|
1302
|
+
if (project && project.settings && project.settings.email) {
|
|
1303
|
+
if (project.settings.email.config) {
|
|
1304
|
+
configEmail = project.settings.email.config;
|
|
1305
|
+
winston.verbose("custom email configEmail setting found: ", configEmail);
|
|
1306
|
+
}
|
|
1307
|
+
if (project.settings.email.from) {
|
|
1308
|
+
from = project.settings.email.from;
|
|
1309
|
+
winston.verbose("custom from email setting found: "+ from);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
that.send({
|
|
1317
|
+
messageId: messageId,
|
|
1318
|
+
// sender: message.senderFullname, //must be an email
|
|
1319
|
+
from:from,
|
|
1320
|
+
to:to,
|
|
1321
|
+
cc: ccString,
|
|
1322
|
+
replyTo: replyTo,
|
|
1323
|
+
inReplyTo: inReplyTo,
|
|
1324
|
+
references: references,
|
|
1325
|
+
// subject:`${message.request ? message.request.subject : '-'}`,
|
|
1326
|
+
subject:`${message.request ? message.request.ticket_id : '-'}`, //gmail uses subject
|
|
1327
|
+
text:html,
|
|
1328
|
+
html:html,
|
|
1329
|
+
config:configEmail,
|
|
1330
|
+
headers:headers
|
|
1331
|
+
});
|
|
1332
|
+
|
|
1333
|
+
// // messageId = "notification" + messageId;
|
|
1334
|
+
|
|
1335
|
+
// // that.send({
|
|
1336
|
+
// // messageId: messageId,
|
|
1337
|
+
// // // sender: message.senderFullname, //must be an email
|
|
1338
|
+
// // to: that.bcc,
|
|
1339
|
+
// // replyTo: replyTo,
|
|
1340
|
+
// // inReplyTo: inReplyTo,
|
|
1341
|
+
// // references: references,
|
|
1342
|
+
// // // subject: `${message.request ? message.request.subject : '-'} - notification`,
|
|
1343
|
+
// // subject: `${message.request ? message.request.subject : '-'} - notification`,
|
|
1344
|
+
// // text:html,
|
|
1345
|
+
// // html:html,
|
|
1346
|
+
// // headers:headers
|
|
1347
|
+
// // });
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1179
1357
|
/*
|
|
1180
1358
|
sendEmailChannelTakingNotification(to, request, project, tokenQueryString) {
|
|
1181
1359
|
|
|
@@ -1505,6 +1683,6 @@ async sendRequestTranscript(to, messages, request, project) {
|
|
|
1505
1683
|
|
|
1506
1684
|
var emailService = new EmailService();
|
|
1507
1685
|
|
|
1508
|
-
//
|
|
1686
|
+
// emailService.sendTest("asd.");
|
|
1509
1687
|
|
|
1510
1688
|
module.exports = emailService;
|
|
@@ -10,7 +10,6 @@ var BotFromParticipant = require("../utils/botFromParticipant");
|
|
|
10
10
|
var cacheUtil = require('../utils/cacheUtil');
|
|
11
11
|
var eventService = require('../pubmodules/events/eventService');
|
|
12
12
|
var mongoose = require('mongoose');
|
|
13
|
-
const { TiledeskChatbotUtil } = require('@tiledesk/tiledesk-chatbot-util');
|
|
14
13
|
const ActionsConstants = require('../models/actionsConstants');
|
|
15
14
|
var httpUtil = require('../utils/httpUtil');
|
|
16
15
|
|
|
@@ -138,7 +137,7 @@ class FaqBotHandler {
|
|
|
138
137
|
|
|
139
138
|
|
|
140
139
|
|
|
141
|
-
|
|
140
|
+
// EXACT MATCH
|
|
142
141
|
Faq.find(query)
|
|
143
142
|
.lean().
|
|
144
143
|
exec(async (err, faqs) => {
|
|
@@ -301,6 +300,7 @@ class FaqBotHandler {
|
|
|
301
300
|
}
|
|
302
301
|
|
|
303
302
|
|
|
303
|
+
|
|
304
304
|
Faq.find(query, mongoproject)
|
|
305
305
|
.sort(sort)
|
|
306
306
|
.lean().
|
package/services/faqService.js
CHANGED
|
@@ -39,7 +39,7 @@ class FaqService {
|
|
|
39
39
|
|
|
40
40
|
winston.debug('type '+ type)
|
|
41
41
|
|
|
42
|
-
if (type==="internal") {
|
|
42
|
+
if (type==="internal" || type==="tilebot") {
|
|
43
43
|
|
|
44
44
|
if (!template) {
|
|
45
45
|
template = "example";
|
|
@@ -78,7 +78,7 @@ class FaqService {
|
|
|
78
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
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
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/
|
|
81
|
+
{ 'question': 'Sample Image', 'answer': 'tdImage:https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v2.png\n* What can you do?\n* Back to start tdAction:start', 'topic': 'sample' },
|
|
82
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
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
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' },
|
package/services/geoService.js
CHANGED
|
@@ -8,6 +8,13 @@ var geoip = require('geoip-lite');
|
|
|
8
8
|
|
|
9
9
|
class GeoService {
|
|
10
10
|
|
|
11
|
+
constructor() {
|
|
12
|
+
this.enabled = true;
|
|
13
|
+
if (process.env.GEO_SERVICE_ENABLED=="false" || process.env.GEO_SERVICE_ENABLED==false) {
|
|
14
|
+
this.enabled = false;
|
|
15
|
+
}
|
|
16
|
+
winston.debug("GeoService this.enabled: "+ this.enabled);
|
|
17
|
+
}
|
|
11
18
|
|
|
12
19
|
|
|
13
20
|
// https://medium.com/@rossbulat/node-js-client-ip-location-with-geoip-lite-fallback-c25833c94a76
|
|
@@ -16,7 +23,12 @@ class GeoService {
|
|
|
16
23
|
|
|
17
24
|
listen() {
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
if (this.enabled==true) {
|
|
27
|
+
winston.info("GeoService listener started");
|
|
28
|
+
} else {
|
|
29
|
+
return winston.info("GeoService listener disabled");
|
|
30
|
+
}
|
|
31
|
+
|
|
20
32
|
|
|
21
33
|
|
|
22
34
|
|
|
@@ -36,9 +48,19 @@ class GeoService {
|
|
|
36
48
|
// area: 200 }
|
|
37
49
|
|
|
38
50
|
|
|
39
|
-
requestEvent.on('request.create', function(request) {
|
|
40
51
|
|
|
41
|
-
|
|
52
|
+
var requestCreateKey = 'request.create';
|
|
53
|
+
// if (requestEvent.queueEnabled) {
|
|
54
|
+
// requestCreateKey = 'request.create.queue';
|
|
55
|
+
// }
|
|
56
|
+
// winston.debug('GeoService requestCreateKey: ' + requestCreateKey);
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
requestEvent.on(requestCreateKey, function(request) {
|
|
60
|
+
|
|
61
|
+
setImmediate(() => {
|
|
62
|
+
|
|
63
|
+
winston.debug("request", request);
|
|
42
64
|
|
|
43
65
|
var ip = (request.location && request.location.ipAddress) || (request.attributes && request.attributes.ipAddress);
|
|
44
66
|
winston.debug("ip" + ip);
|
|
@@ -114,11 +136,15 @@ class GeoService {
|
|
|
114
136
|
}
|
|
115
137
|
return winston.verbose("Saved location metadata for request with id " + request._id);
|
|
116
138
|
});
|
|
139
|
+
|
|
140
|
+
//TODO AGGIORNA ANCHE LEAD e req.snapshot.lead?
|
|
141
|
+
// leggi ip da request e nn da attributes
|
|
117
142
|
|
|
118
143
|
}
|
|
119
144
|
}
|
|
120
145
|
});
|
|
121
|
-
|
|
146
|
+
});
|
|
147
|
+
}
|
|
122
148
|
|
|
123
149
|
|
|
124
150
|
}
|
package/services/leadService.js
CHANGED