@tiledesk/tiledesk-whatsapp-connector 0.1.14 → 0.1.15
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/index.js +154 -47
- package/package.json +1 -1
- package/template/css/style.css +173 -0
- package/template/detail.html +226 -0
- package/test/test_translate_whatsapp.js +6 -5
- package/tiledesk/TiledeskAppsClient.js +168 -0
- package/tiledesk/TiledeskWhatsappTranslator.js +23 -17
package/index.js
CHANGED
|
@@ -3,17 +3,10 @@ const express = require("express");
|
|
|
3
3
|
const app = express();
|
|
4
4
|
const router = express.Router();
|
|
5
5
|
const bodyParser = require("body-parser");
|
|
6
|
-
//const request = require("request");
|
|
7
|
-
//const multer = require('multer');
|
|
8
|
-
//const jwt = require('jsonwebtoken');
|
|
9
|
-
//const { v4: uuidv4 } = require('uuid');
|
|
10
|
-
//const axios = require("axios").default;
|
|
11
|
-
//const mongoose = require("mongoose");
|
|
12
6
|
const appRoot = require('app-root-path');
|
|
13
7
|
const handlebars = require('handlebars');
|
|
14
8
|
const fs = require('fs');
|
|
15
9
|
const path = require('path');
|
|
16
|
-
//const FormData = require('form-data');
|
|
17
10
|
|
|
18
11
|
// tiledesk clients
|
|
19
12
|
const { TiledeskClient } = require('@tiledesk/tiledesk-client');
|
|
@@ -21,6 +14,7 @@ const { TiledeskWhatsappTranslator } = require('./tiledesk/TiledeskWhatsappTrans
|
|
|
21
14
|
const { TiledeskSubscriptionClient } = require('./tiledesk/TiledeskSubscriptionClient');
|
|
22
15
|
const { TiledeskWhatsapp } = require('./tiledesk/TiledeskWhatsapp');
|
|
23
16
|
const { TiledeskChannel } = require('./tiledesk/TiledeskChannel');
|
|
17
|
+
const { TiledeskAppsClient } = require('./tiledesk/TiledeskAppsClient');
|
|
24
18
|
|
|
25
19
|
// mongo
|
|
26
20
|
const { KVBaseMongo } = require('@tiledesk/tiledesk-kvbasemongo');
|
|
@@ -30,36 +24,142 @@ router.use(bodyParser.json());
|
|
|
30
24
|
router.use(bodyParser.urlencoded({ extended: true }));
|
|
31
25
|
router.use(express.static(path.join(__dirname, 'template')));
|
|
32
26
|
|
|
33
|
-
//const TOKEN = process.env.WHATSAPP_TOKEN; // From FB DevX getting started page
|
|
34
|
-
//const VERIFY_TOKEN = process.env.VERIFY_TOKEN; // Arbitrary, used with webhook configuration in FB DevX
|
|
35
|
-
//const BASE_URL = process.env.BASE_URL;
|
|
36
|
-
//const API_URL = process.env.API_URL;
|
|
37
|
-
//const project_id = process.env.PROJECT_ID;
|
|
38
|
-
//const token_jwt = process.env.TOKEN_JWT
|
|
39
|
-
//const GRAPH_URL = process.env.GRAPH_URL;
|
|
40
|
-
//const MONGODB_URL = process.env.MONGODB_URL;
|
|
41
|
-
|
|
42
|
-
|
|
43
27
|
var API_URL = null;
|
|
44
28
|
var GRAPH_URL = null;
|
|
45
29
|
var BASE_URL = null;
|
|
30
|
+
var APPS_API_URL = null;
|
|
46
31
|
var log = true;
|
|
47
32
|
|
|
48
33
|
const db = new KVBaseMongo(kvbase_collection);
|
|
49
|
-
/*
|
|
50
|
-
db.connect(MONGODB_URL, () => {
|
|
51
|
-
console.log("KVBaseMongo successfully connected.");
|
|
52
|
-
var server = app.listen(process.env.PORT || 1337, function() {
|
|
53
|
-
var port = server.address().port;
|
|
54
|
-
console.log("App now running on port", port);
|
|
55
|
-
});
|
|
56
|
-
})
|
|
57
|
-
*/
|
|
58
34
|
|
|
59
35
|
router.get('/', async (req, res) => {
|
|
60
36
|
res.send('Home works!')
|
|
61
37
|
})
|
|
62
38
|
|
|
39
|
+
router.get('/detail', async (req, res) => {
|
|
40
|
+
|
|
41
|
+
let projectId = req.query.project_id;
|
|
42
|
+
let token = req.query.token;
|
|
43
|
+
let app_id = req.query.app_id;
|
|
44
|
+
|
|
45
|
+
const appClient = new TiledeskAppsClient({ APPS_API_URL: APPS_API_URL });
|
|
46
|
+
let installation = await appClient.getInstallations(projectId, app_id);
|
|
47
|
+
|
|
48
|
+
let installed = false;
|
|
49
|
+
if (installation) {
|
|
50
|
+
installed = true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
readHTMLFile('/detail.html', (err, html) => {
|
|
54
|
+
if (err) {
|
|
55
|
+
console.log("(ERROR) Read html file: ", err);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var template = handlebars.compile(html);
|
|
59
|
+
var replacements = {
|
|
60
|
+
project_id: projectId,
|
|
61
|
+
token: token,
|
|
62
|
+
app_id: app_id,
|
|
63
|
+
installed: installed
|
|
64
|
+
}
|
|
65
|
+
if (log) {
|
|
66
|
+
console.log("Replacements: ", replacements);
|
|
67
|
+
}
|
|
68
|
+
var html = template(replacements);
|
|
69
|
+
res.send(html);
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
router.post('/install', async (req, res) => {
|
|
74
|
+
|
|
75
|
+
let project_id = req.body.project_id;
|
|
76
|
+
let app_id = req.body.app_id;
|
|
77
|
+
let token = req.body.token;
|
|
78
|
+
|
|
79
|
+
console.log("Install app " + app_id + " for project id " + project_id);
|
|
80
|
+
let installation_info = {
|
|
81
|
+
project_id: project_id,
|
|
82
|
+
app_id: app_id,
|
|
83
|
+
createdAt: Date.now()
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
console.log("installation info: ", installation_info)
|
|
87
|
+
|
|
88
|
+
const appClient = new TiledeskAppsClient({ APPS_API_URL: APPS_API_URL });
|
|
89
|
+
//let installation = await appClient.install(installation_info);
|
|
90
|
+
appClient.install(installation_info).then((installation) => {
|
|
91
|
+
|
|
92
|
+
if (log) {
|
|
93
|
+
console.log("installation response: ", installation);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let installed = true;
|
|
97
|
+
|
|
98
|
+
readHTMLFile('/detail.html', (err, html) => {
|
|
99
|
+
if (err) {
|
|
100
|
+
console.log("(ERROR) Read html file: ", err);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var template = handlebars.compile(html);
|
|
104
|
+
var replacements = {
|
|
105
|
+
project_id: project_id,
|
|
106
|
+
token: token,
|
|
107
|
+
app_id: app_id,
|
|
108
|
+
installed: installed
|
|
109
|
+
}
|
|
110
|
+
if (log) {
|
|
111
|
+
console.log("Replacements: ", replacements);
|
|
112
|
+
}
|
|
113
|
+
var html = template(replacements);
|
|
114
|
+
res.send(html);
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
}).catch((err) => {
|
|
118
|
+
console.error("installation error: ", err.data)
|
|
119
|
+
res.send("An error occurred during the installation");
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
router.post('/uninstall', async (req, res) => {
|
|
125
|
+
let project_id = req.body.project_id;
|
|
126
|
+
let app_id = req.body.app_id;
|
|
127
|
+
let token = req.body.token;
|
|
128
|
+
|
|
129
|
+
const appClient = new TiledeskAppsClient({ APPS_API_URL: APPS_API_URL });
|
|
130
|
+
appClient.uninstall(project_id, app_id).then((response) => {
|
|
131
|
+
|
|
132
|
+
if (log) {
|
|
133
|
+
console.log("uninstallation response: ", response);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let installed = false;
|
|
137
|
+
|
|
138
|
+
readHTMLFile('/detail.html', (err, html) => {
|
|
139
|
+
if (err) {
|
|
140
|
+
console.log("(ERROR) Read html file: ", err);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
var template = handlebars.compile(html);
|
|
144
|
+
var replacements = {
|
|
145
|
+
project_id: project_id,
|
|
146
|
+
token: token,
|
|
147
|
+
app_id: app_id,
|
|
148
|
+
installed: installed
|
|
149
|
+
}
|
|
150
|
+
if (log) {
|
|
151
|
+
console.log("Replacements: ", replacements);
|
|
152
|
+
}
|
|
153
|
+
var html = template(replacements);
|
|
154
|
+
res.send(html);
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
}).catch((err) => {
|
|
158
|
+
console.error("uninsallation error: ", err.data)
|
|
159
|
+
res.send("An error occurred during the uninstallation");
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
|
|
63
163
|
router.get('/configure', async (req, res) => {
|
|
64
164
|
console.log("\n/configure");
|
|
65
165
|
if (log) {
|
|
@@ -468,7 +568,7 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
468
568
|
console.log("File position: ", filename);
|
|
469
569
|
let file_path = path.join(__dirname, 'tmp', filename);
|
|
470
570
|
|
|
471
|
-
|
|
571
|
+
|
|
472
572
|
const media_url = await util.uploadMedia(file_path, "files");
|
|
473
573
|
console.log("image_url: ", media_url)
|
|
474
574
|
|
|
@@ -583,29 +683,36 @@ function startApp(settings, callback) {
|
|
|
583
683
|
console.log("GRAPH_URL: ", GRAPH_URL);
|
|
584
684
|
}
|
|
585
685
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
686
|
+
if (!settings.APPS_API_URL) {
|
|
687
|
+
throw new Error("settings.APPS_API_URL is mandatory");
|
|
688
|
+
} else {
|
|
689
|
+
APPS_API_URL = settings.APPS_API_URL;
|
|
690
|
+
console.log("APPS_API_URL: ", APPS_API_URL);
|
|
691
|
+
}
|
|
589
692
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
if (callback) {
|
|
593
|
-
callback();
|
|
693
|
+
if (settings.log) {
|
|
694
|
+
log = settings.log;
|
|
594
695
|
}
|
|
595
|
-
})
|
|
596
|
-
}
|
|
597
696
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
if (err) {
|
|
603
|
-
throw err;
|
|
604
|
-
//callback(err);
|
|
605
|
-
} else {
|
|
606
|
-
callback(null, html)
|
|
697
|
+
db.connect(settings.MONGODB_URL, () => {
|
|
698
|
+
console.log("KVBaseMongo successfully connected.");
|
|
699
|
+
if (callback) {
|
|
700
|
+
callback();
|
|
607
701
|
}
|
|
608
702
|
})
|
|
609
|
-
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function readHTMLFile(templateName, callback) {
|
|
706
|
+
console.log("Reading file: ", templateName)
|
|
707
|
+
fs.readFile(__dirname + '/template' + templateName, { encoding: 'utf-8' },
|
|
708
|
+
function(err, html) {
|
|
709
|
+
if (err) {
|
|
710
|
+
throw err;
|
|
711
|
+
//callback(err);
|
|
712
|
+
} else {
|
|
713
|
+
callback(null, html)
|
|
714
|
+
}
|
|
715
|
+
})
|
|
716
|
+
}
|
|
610
717
|
|
|
611
|
-
module.exports = { router: router, startApp: startApp };
|
|
718
|
+
module.exports = { router: router, startApp: startApp };
|
package/package.json
CHANGED
package/template/css/style.css
CHANGED
|
@@ -43,4 +43,177 @@
|
|
|
43
43
|
.custom-tooltip:hover .custom-tooltiptext {
|
|
44
44
|
visibility: visible;
|
|
45
45
|
opacity: 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
.content {
|
|
50
|
+
width: 52%;
|
|
51
|
+
min-width: 960px;
|
|
52
|
+
height: 1000px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.installation-info-box {
|
|
56
|
+
background-color: aliceblue;
|
|
57
|
+
height: 28px;
|
|
58
|
+
border-radius: 8px;
|
|
59
|
+
display: flex;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
align-items: center;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.icon-and-title {
|
|
65
|
+
margin-top: 20px;
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: row;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.install-button {
|
|
71
|
+
width: 120px;
|
|
72
|
+
color: white;
|
|
73
|
+
background-color: #04AA6D;
|
|
74
|
+
letter-spacing: 0.5px;
|
|
75
|
+
font-size: 13px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.install-button:hover {
|
|
79
|
+
width: 120px;
|
|
80
|
+
color: white;
|
|
81
|
+
background-color: #079d66;
|
|
82
|
+
border-color: #079d66;
|
|
83
|
+
letter-spacing: 0.5px;
|
|
84
|
+
font-size: 13px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.open-button {
|
|
88
|
+
width: 120px;
|
|
89
|
+
color: white;
|
|
90
|
+
background-color: #04AA6D;
|
|
91
|
+
letter-spacing: 0.5px;
|
|
92
|
+
font-size: 13px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.open-button:hover {
|
|
96
|
+
width: 120px;
|
|
97
|
+
color: white;
|
|
98
|
+
background-color: #079d66;
|
|
99
|
+
border-color: #079d66;
|
|
100
|
+
letter-spacing: 0.5px;
|
|
101
|
+
font-size: 13px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.open-button:focus {
|
|
105
|
+
width: 120px;
|
|
106
|
+
color: white;
|
|
107
|
+
font-weight: 500;
|
|
108
|
+
background-color: #079d66;
|
|
109
|
+
border-color: #079d66;
|
|
110
|
+
letter-spacing: 0.5px;
|
|
111
|
+
font-size: 13px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.uninstall-button {
|
|
115
|
+
width: 120px;
|
|
116
|
+
margin-top: 5px;
|
|
117
|
+
color: white;
|
|
118
|
+
border-color: #f0593d;
|
|
119
|
+
background-color: #f0593d;
|
|
120
|
+
letter-spacing: 0.5px;
|
|
121
|
+
font-size: 13px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.uninstall-button:hover {
|
|
125
|
+
width: 120px;
|
|
126
|
+
margin-top: 5px;
|
|
127
|
+
color: white;
|
|
128
|
+
border-color: #d53e21;
|
|
129
|
+
background-color: #d53e21;
|
|
130
|
+
letter-spacing: 0.5px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.uninstall-button:focus {
|
|
134
|
+
width: 120px;
|
|
135
|
+
margin-top: 5px;
|
|
136
|
+
color: white;
|
|
137
|
+
font-weight: 500;
|
|
138
|
+
border-color: #d53e21;
|
|
139
|
+
background-color: #d53e21;
|
|
140
|
+
letter-spacing: 0.5px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.cancel-btn {
|
|
144
|
+
width: 120px;
|
|
145
|
+
margin-top: 5px;
|
|
146
|
+
color: white;
|
|
147
|
+
border-color: #c0c0c0;
|
|
148
|
+
background-color: #c0c0c0;
|
|
149
|
+
letter-spacing: 0.5px;
|
|
150
|
+
margin-right: 30px;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.cancel-btn:hover {
|
|
154
|
+
width: 120px;
|
|
155
|
+
margin-top: 5px;
|
|
156
|
+
color: white;
|
|
157
|
+
border-color: #929292;
|
|
158
|
+
background-color: #929292;
|
|
159
|
+
letter-spacing: 0.5px;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.cancel-btn:focus {
|
|
163
|
+
width: 120px;
|
|
164
|
+
margin-top: 5px;
|
|
165
|
+
color: white;
|
|
166
|
+
font-weight: 500;
|
|
167
|
+
border-color: #929292;
|
|
168
|
+
background-color: #929292;
|
|
169
|
+
letter-spacing: 0.5px;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.app-summary-div {
|
|
173
|
+
text-align: center;
|
|
174
|
+
margin-right: 40px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.app-summary-name {
|
|
178
|
+
max-width: 100px;
|
|
179
|
+
margin-top: 7px;
|
|
180
|
+
font-style: italic;
|
|
181
|
+
color: grey;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
.modal {
|
|
186
|
+
text-align: center;
|
|
187
|
+
display: none;
|
|
188
|
+
justify-content: center;
|
|
189
|
+
position: fixed;
|
|
190
|
+
z-index: 1;
|
|
191
|
+
padding-top: 100px;
|
|
192
|
+
left: 0;
|
|
193
|
+
top: 0;
|
|
194
|
+
width: 100%;
|
|
195
|
+
height: 100%;
|
|
196
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.modal-content {
|
|
200
|
+
width: 500px;
|
|
201
|
+
height: 300px;
|
|
202
|
+
background-color: white;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.close {
|
|
206
|
+
color: grey;
|
|
207
|
+
float: right;
|
|
208
|
+
font-size: 30px;
|
|
209
|
+
font-weight: bold;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.close:hover, .close:focus {
|
|
213
|
+
color: black;
|
|
214
|
+
cursor: pointer;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.btn:focus {
|
|
218
|
+
outline: none !important;
|
|
46
219
|
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
+
|
|
9
|
+
<!-- Latest compiled and minified CSS -->
|
|
10
|
+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
|
|
11
|
+
integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
|
|
12
|
+
|
|
13
|
+
<!-- Optional theme -->
|
|
14
|
+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
|
|
15
|
+
integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
|
|
16
|
+
|
|
17
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
18
|
+
|
|
19
|
+
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
|
|
20
|
+
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
|
|
21
|
+
|
|
22
|
+
<!-- Latest compiled and minified JavaScript -->
|
|
23
|
+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
|
|
24
|
+
integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous">
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<link rel="stylesheet" href="./css/style.css">
|
|
28
|
+
|
|
29
|
+
</head>
|
|
30
|
+
|
|
31
|
+
<body style="display: flex; justify-content: center;">
|
|
32
|
+
<div class="content">
|
|
33
|
+
<div style="margin-top: 10px;">
|
|
34
|
+
<p style="font-size: 20px;">Tiledesk <b>App Store</b></p>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<hr style="margin-top: 10px; margin-bottom: 10px">
|
|
38
|
+
|
|
39
|
+
<div class="installation-info-box">
|
|
40
|
+
<p style="margin: 0px; color: #676767; font-size: 13px;">You can install this application for free.</p>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
<div class="icon-and-title" style="margin-top: 20px;">
|
|
45
|
+
<div>
|
|
46
|
+
<img src="https://www.clipartmax.com/png/full/205-2058823_whatsapp-ios-icon-whatsapp-ios-icon-png.png" width="180" height="auto" />
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<div style="display: flex; flex-direction: row; justify-content: space-between; margin-left: 40px; width: 100%;">
|
|
50
|
+
<div>
|
|
51
|
+
<p style="font-size: 26px; font-weight: 500; margin-bottom: 0px;">WhatsApp Business</p>
|
|
52
|
+
<p style="color: #676767; font-size: 16px; margin-bottom: 5px;">Connect your WhatsApp number with Tiledesk</p>
|
|
53
|
+
<a style="font-size: 18px;" href="https://tiledesk.com/" target="_blank">Tiledesk</a>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div style="display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end;">
|
|
57
|
+
|
|
58
|
+
{{#if installed}}
|
|
59
|
+
<form action="./configure" method="get">
|
|
60
|
+
<input type="hidden" name="project_id" value="{{ project_id }}" />
|
|
61
|
+
<input type="hidden" name="app_id" value="{{ app_id }}" />
|
|
62
|
+
<input type="hidden" name="token" value="{{ token }}" />
|
|
63
|
+
<input type="submit" class="btn install-button" value="Open">
|
|
64
|
+
</form>
|
|
65
|
+
|
|
66
|
+
<!--
|
|
67
|
+
<form action="./uninstall" method="post">
|
|
68
|
+
<input type="hidden" name="project_id" value="{{ project_id }}" />
|
|
69
|
+
<input type="hidden" name="app_id" value="{{ app_id }}" />
|
|
70
|
+
<input type="hidden" name="token" value="{{ token }}" />
|
|
71
|
+
<input type="submit" class="btn uninstall-button" value="Uninstall">
|
|
72
|
+
</form>-->
|
|
73
|
+
|
|
74
|
+
<button class="btn uninstall-button" onclick="document.getElementById('uninstall-modal').style.display='flex'">Uninstall</button>
|
|
75
|
+
|
|
76
|
+
<div id="uninstall-modal" class="modal">
|
|
77
|
+
<div class="modal-content">
|
|
78
|
+
<!--<span class="close">×</span-->
|
|
79
|
+
<h2>WhatsApp Business</h2>
|
|
80
|
+
<div style="margin-top: 20px;">
|
|
81
|
+
<img src="https://www.clipartmax.com/png/full/205-2058823_whatsapp-ios-icon-whatsapp-ios-icon-png.png" width="70" height="auto" />
|
|
82
|
+
</div>
|
|
83
|
+
<p style="margin-top: 20px; margin-bottom: 20px;">Are you sure you want to uninstall this app?</p>
|
|
84
|
+
|
|
85
|
+
<div style="display: flex; flex-direction: row; width: 100%; justify-content: center;">
|
|
86
|
+
<button class="btn cancel-btn" onclick="document.getElementById('uninstall-modal').style.display='none'">Cancel</button>
|
|
87
|
+
|
|
88
|
+
<form action="./uninstall" method="post">
|
|
89
|
+
<input type="hidden" name="project_id" value="{{ project_id }}" />
|
|
90
|
+
<input type="hidden" name="app_id" value="{{ app_id }}" />
|
|
91
|
+
<input type="hidden" name="token" value="{{ token }}" />
|
|
92
|
+
<input type="submit" class="btn uninstall-button" value="Yes, uninstall">
|
|
93
|
+
</form>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
{{else}}
|
|
103
|
+
<p style="font-size: 12px; color: #676767; font-style: italic; margin-bottom: 0px; margin-right: 3px;">Free</p>
|
|
104
|
+
<form action="./install" method="post">
|
|
105
|
+
<input type="hidden" name="project_id" value="{{ project_id }}" />
|
|
106
|
+
<input type="hidden" name="app_id" value="{{ app_id }}" />
|
|
107
|
+
<input type="hidden" name="token" value="{{ token }}" />
|
|
108
|
+
<input type="submit" class="btn install-button" value="Install">
|
|
109
|
+
</form>
|
|
110
|
+
{{/if}}
|
|
111
|
+
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<hr style="margin-top: 20px; margin-bottom: 20px">
|
|
117
|
+
|
|
118
|
+
<p style="font-size: 18px;"><b>Screenshot from the application</b></p>
|
|
119
|
+
<img src="https://media.discordapp.net/attachments/998542078587973734/1018841949534429184/2211.jpg?width=1055&height=686" style="width: 100%; height: 50%;"/>
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
<hr style="margin-top: 20px; margin-bottom: 20px">
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
<div>
|
|
126
|
+
<h7>Receive Whatsapp bot conversations in your Tiledesk dashboard. Seamlessly Chat with your targeted audience on Whatsapp right from the Tiledesk dashboard.</h7>
|
|
127
|
+
<ul style="padding: 10px 20px;">
|
|
128
|
+
<li><h7>Integrate your Whatsapp number with Tiledesk.</h7></li>
|
|
129
|
+
<li><h7>Once a chat is initiated on your Whatsapp number, receive an alert on your Tiledesk account.</h7></li>
|
|
130
|
+
<li><h7>Enable instant messaging and answer multiple conversations - everything from Tiledesk account.</h7></li>
|
|
131
|
+
</ul>
|
|
132
|
+
|
|
133
|
+
<div style="padding: 20px; background-color: aliceblue; border-radius: 8px;">
|
|
134
|
+
<div style="display: flex; flex-direction: row; align-items: baseline;">
|
|
135
|
+
<div>
|
|
136
|
+
<img src="https://freeiconshop.com/wp-content/uploads/edd/arrow-flat.png" width="20px" height="auto" style="margin-right: 10px;">
|
|
137
|
+
</div>
|
|
138
|
+
<div>
|
|
139
|
+
<a href="https://gethelp.tiledesk.com/articles/telegram/" target="_blank">Connect Tiledesk with WhatsApp Business</a>
|
|
140
|
+
<p style="color: grey; margin-bottom: 0px;">A small but very useful guide on how to connect your WhatsApp Business number with Tiledesk</p>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<hr style="margin-top: 10px; margin-bottom: 10px;">
|
|
145
|
+
|
|
146
|
+
<div style="display: flex; flex-direction: row; align-items: baseline;">
|
|
147
|
+
<div>
|
|
148
|
+
<img src="https://freeiconshop.com/wp-content/uploads/edd/arrow-flat.png" width="20px" height="auto" style="margin-right: 10px;">
|
|
149
|
+
</div>
|
|
150
|
+
<div>
|
|
151
|
+
<a href="https://gethelp.tiledesk.com/articles/telegram/" target="_blank">Configure a WhatsApp Business account</a>
|
|
152
|
+
<p style="color: grey; margin-bottom: 0px;">Not sure how to set up a business account? Take a look here.</p>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
<hr style="margin-top: 20px; margin-bottom: 20px">
|
|
161
|
+
|
|
162
|
+
<p style="font-size: 18px;"><b>What's new?</b></p>
|
|
163
|
+
|
|
164
|
+
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 5px;">
|
|
165
|
+
<div>
|
|
166
|
+
<p style="margin-bottom: 0px;">Add support for pdf from Tiledesk</p>
|
|
167
|
+
<p>Bug fixes</p>
|
|
168
|
+
</div>
|
|
169
|
+
<p style="font-size: 12px; color: #676767">Version <b>0.1.14</b></p>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between;">
|
|
173
|
+
<p>Bug fixes and performance improvements</p>
|
|
174
|
+
<p style="font-size: 12px; color: #676767">Version <b>0.1.13</b></p>
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<!--
|
|
178
|
+
|
|
179
|
+
<hr style="margin-top: 20px; margin-bottom: 20px">
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
<p style="font-size: 18px;"><b>Other from Tiledesk</b> <a onclick="getParent()" target="_blank" style="font-size: 13px; margin-left: 15px;">View all</a></p>
|
|
183
|
+
|
|
184
|
+
<div>
|
|
185
|
+
<p>Visit our store and discovery all the available apps!</p>
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
<div style="display: flex;">
|
|
190
|
+
<div class="app-summary-div">
|
|
191
|
+
<img src="https://cdn3.iconfinder.com/data/icons/social-media-chamfered-corner/154/telegram-512.png" width="110" height="auto">
|
|
192
|
+
<p class="app-summary-name">Telegram</p>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<div class="app-summary-div">
|
|
196
|
+
<img src="https://cdn.jim-nielsen.com/ios/512/messenger-2020-11-17.png" width="110" height="auto">
|
|
197
|
+
<p class="app-summary-name">Facebook Messenger</p>
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
<div class="app-summary-div">
|
|
201
|
+
<img src="https://i.ibb.co/yWz3bZ5/2022-04-21-11-28-20.jpg" width="110" height="auto">
|
|
202
|
+
<p class="app-summary-name">Help Center</p>
|
|
203
|
+
</div>
|
|
204
|
+
|
|
205
|
+
<div class="app-summary-div">
|
|
206
|
+
<img src="https://i.pinimg.com/474x/f4/07/55/f407552380549b7ce1b508c5a6639b38.jpg" width="110" height="auto">
|
|
207
|
+
<p class="app-summary-name">Github</p>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
-->
|
|
211
|
+
|
|
212
|
+
<hr style="margin-top: 50px; margin-bottom: 20px">
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
<!--
|
|
218
|
+
<script>
|
|
219
|
+
function getParent() {
|
|
220
|
+
let parent_base = document.referrer;
|
|
221
|
+
let app_store_url = parent_base + "dashboard/#/project/"+ {{project_id}} +"/app-store/"
|
|
222
|
+
}
|
|
223
|
+
</script>
|
|
224
|
+
-->
|
|
225
|
+
|
|
226
|
+
</body>
|
|
@@ -71,7 +71,8 @@ describe('Test Translator\n', function() {
|
|
|
71
71
|
recipient: 'support-group-62c3f10152dc7400352bab0d-86a2293e-wab-104777398965560-393484506627',
|
|
72
72
|
metadata: {
|
|
73
73
|
src: 'https://fakevideourl.com/',
|
|
74
|
-
type: 'video/mp4'
|
|
74
|
+
type: 'video/mp4',
|
|
75
|
+
name: 'fakevideo.mp4'
|
|
75
76
|
},
|
|
76
77
|
attributes: {
|
|
77
78
|
userFullname: 'John Doe'
|
|
@@ -86,9 +87,9 @@ describe('Test Translator\n', function() {
|
|
|
86
87
|
assert(whatsappJsonMessage.messaging_product === TiledeskWhatsappTranslator.WHATSAPP_MESSAGING_PRODUCT);
|
|
87
88
|
assert(whatsappJsonMessage.to === whatsapp_receiver);
|
|
88
89
|
assert(!whatsappJsonMessage.text);
|
|
89
|
-
assert(whatsappJsonMessage.
|
|
90
|
-
assert(whatsappJsonMessage.
|
|
91
|
-
assert(whatsappJsonMessage.
|
|
90
|
+
assert(whatsappJsonMessage.video);
|
|
91
|
+
assert(whatsappJsonMessage.video.link === tiledeskChannelMessage.metadata.src);
|
|
92
|
+
assert(whatsappJsonMessage.video.caption === tiledeskChannelMessage.metadata.name);
|
|
92
93
|
if (log) {
|
|
93
94
|
console.log("(test) whatsappJsonMessage: ", whatsappJsonMessage);
|
|
94
95
|
}
|
|
@@ -103,7 +104,7 @@ describe('Test Translator\n', function() {
|
|
|
103
104
|
recipient: 'support-group-62c3f10152dc7400352bab0d-86a2293e-wab-104777398965560-393484506627',
|
|
104
105
|
metadata: {
|
|
105
106
|
src: 'https://fakedocumenturl.com/',
|
|
106
|
-
name: "
|
|
107
|
+
name: "fakedocument.pdf",
|
|
107
108
|
type: 'application/pdf'
|
|
108
109
|
},
|
|
109
110
|
attributes: {
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
const axios = require("axios").default;
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const FormData = require('form-data');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
class TiledeskAppsClient {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor for TiledeskChannel
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const { TiledeskAppsClient } = require('tiledesk-apps-client');
|
|
12
|
+
* const appClient = new TiledeskAppsClient({ APPS_API_URL: APPS_API_URL});
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} config JSON configuration.
|
|
15
|
+
* @param {string} config.APPS_API_URL Mandatory. The api url for tiledesk apps.
|
|
16
|
+
* @param {boolean} options.log Optional. If true HTTP requests are logged.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
constructor(config) {
|
|
20
|
+
if (!config) {
|
|
21
|
+
throw new Error('config is mandatory');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!config.APPS_API_URL) {
|
|
25
|
+
throw new Error('config.APPS_URL is mandatory');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.APPS_API_URL = config.APPS_API_URL;
|
|
29
|
+
|
|
30
|
+
this.log = true;
|
|
31
|
+
if (config.log) {
|
|
32
|
+
this.log = config.log;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
install(installation_info, callback) {
|
|
38
|
+
|
|
39
|
+
const URL = this.APPS_API_URL + `/api/installation`;
|
|
40
|
+
const HTTPREQUEST = {
|
|
41
|
+
url: URL,
|
|
42
|
+
headers: {
|
|
43
|
+
'Content-Type': 'application/json',
|
|
44
|
+
},
|
|
45
|
+
json: installation_info,
|
|
46
|
+
method: 'POST'
|
|
47
|
+
};
|
|
48
|
+
let promise = new Promise((resolve, reject) => {
|
|
49
|
+
TiledeskAppsClient.myrequest(
|
|
50
|
+
HTTPREQUEST,
|
|
51
|
+
function(err, resbody) {
|
|
52
|
+
if (err) {
|
|
53
|
+
if (callback) {
|
|
54
|
+
callback(err);
|
|
55
|
+
}
|
|
56
|
+
reject(err);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
if (callback) {
|
|
60
|
+
callback(null, resbody);
|
|
61
|
+
}
|
|
62
|
+
console.log("[Tiledesk Apps Client] Installed!");
|
|
63
|
+
resolve(resbody);
|
|
64
|
+
}
|
|
65
|
+
}, true);
|
|
66
|
+
})
|
|
67
|
+
return promise;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getInstallations(project_id, app_id) {
|
|
71
|
+
const URL = this.APPS_API_URL + `/api/installation/${project_id}`;
|
|
72
|
+
const HTTPREQUEST = {
|
|
73
|
+
url: URL,
|
|
74
|
+
headers: {
|
|
75
|
+
'Content-Type': 'application/json',
|
|
76
|
+
},
|
|
77
|
+
method: 'GET'
|
|
78
|
+
};
|
|
79
|
+
let promise = new Promise((resolve, reject) => {
|
|
80
|
+
TiledeskAppsClient.myrequest(
|
|
81
|
+
HTTPREQUEST,
|
|
82
|
+
function(err, resbody) {
|
|
83
|
+
if (err) {
|
|
84
|
+
reject(err);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
let obj = resbody.find(o => o.app_id === app_id);
|
|
88
|
+
if (obj) {
|
|
89
|
+
resolve(obj);
|
|
90
|
+
} else {
|
|
91
|
+
resolve(null);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, true);
|
|
95
|
+
})
|
|
96
|
+
return promise;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
uninstall(project_id, app_id, callback) {
|
|
100
|
+
const URL = this.APPS_API_URL + `/api/installation/${project_id}/${app_id}`;
|
|
101
|
+
const HTTPREQUEST = {
|
|
102
|
+
url: URL,
|
|
103
|
+
headers: {
|
|
104
|
+
'Content-Type': 'application/json',
|
|
105
|
+
},
|
|
106
|
+
method: 'DELETE'
|
|
107
|
+
};
|
|
108
|
+
let promise = new Promise((resolve, reject) => {
|
|
109
|
+
TiledeskAppsClient.myrequest(
|
|
110
|
+
HTTPREQUEST,
|
|
111
|
+
function(err, resbody) {
|
|
112
|
+
if (err) {
|
|
113
|
+
if (callback) {
|
|
114
|
+
callback(err);
|
|
115
|
+
}
|
|
116
|
+
reject(err);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
if (callback) {
|
|
120
|
+
callback(null, resbody);
|
|
121
|
+
}
|
|
122
|
+
console.log("[Tiledesk Apps Client] Uninstalled!");
|
|
123
|
+
resolve(resbody);
|
|
124
|
+
}
|
|
125
|
+
}, true);
|
|
126
|
+
})
|
|
127
|
+
return promise;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
// HTTP REQUEST
|
|
133
|
+
|
|
134
|
+
static async myrequest(options, callback, log) {
|
|
135
|
+
if (this.log) {
|
|
136
|
+
console.log("[Tiledesk Subscription Client] Options: ", options);
|
|
137
|
+
}
|
|
138
|
+
return await axios({
|
|
139
|
+
url: options.url,
|
|
140
|
+
method: options.method,
|
|
141
|
+
data: options.json,
|
|
142
|
+
params: options.params,
|
|
143
|
+
headers: options.headers
|
|
144
|
+
}).then((res) => {
|
|
145
|
+
if (this.log) {
|
|
146
|
+
console.log("[Tiledesk Subscription Client] Response headers:\n", res.headers);
|
|
147
|
+
}
|
|
148
|
+
if (res && res.status == 200 && res.data) {
|
|
149
|
+
if (callback) {
|
|
150
|
+
callback(null, res.data);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
if (callback) {
|
|
155
|
+
callback(TiledeskClient.getErr({ message: "Response status not 200" }, options, res), null, null);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}).catch((err) => {
|
|
159
|
+
console.error("An error occured: ", err);
|
|
160
|
+
if (callback) {
|
|
161
|
+
callback(err, null, null);
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
module.exports = { TiledeskAppsClient }
|
|
@@ -2,7 +2,10 @@ class TiledeskWhatsappTranslator {
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Constructor for TiledeskWhatsappTranslator
|
|
5
|
-
*
|
|
5
|
+
*const axios = require("axios").default;
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const FormData = require('form-data');
|
|
8
|
+
const path = require('path');
|
|
6
9
|
* @example
|
|
7
10
|
* const { TiledeskWhatsappTranslator } = require('tiledesk-whatsapp-translator');
|
|
8
11
|
* const tlr = new TiledeskWhatsappTranslator();
|
|
@@ -14,7 +17,7 @@ class TiledeskWhatsappTranslator {
|
|
|
14
17
|
static CHANNEL_NAME = "whatsapp";
|
|
15
18
|
|
|
16
19
|
constructor() {
|
|
17
|
-
|
|
20
|
+
|
|
18
21
|
|
|
19
22
|
/*
|
|
20
23
|
if (!config.tiledeskChannelMessage) {
|
|
@@ -23,9 +26,9 @@ class TiledeskWhatsappTranslator {
|
|
|
23
26
|
this.tiledeskChannelMessage = config.tiledeskChannelMessage;
|
|
24
27
|
console.log("this.tiledeskChannelMessage: ", this.tiledeskChannelMessage);
|
|
25
28
|
*/
|
|
26
|
-
|
|
29
|
+
|
|
27
30
|
this.log = true;
|
|
28
|
-
|
|
31
|
+
|
|
29
32
|
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -48,13 +51,16 @@ class TiledeskWhatsappTranslator {
|
|
|
48
51
|
*/
|
|
49
52
|
toWhatsapp(tiledeskChannelMessage, whatsapp_receiver) {
|
|
50
53
|
|
|
51
|
-
|
|
52
54
|
// to --> recipient
|
|
53
55
|
if (this.log) {
|
|
54
56
|
console.log("[Translator] tiledesk message: ", tiledeskChannelMessage)
|
|
55
57
|
}
|
|
56
|
-
|
|
57
|
-
text =
|
|
58
|
+
|
|
59
|
+
let text = '';
|
|
60
|
+
if (tiledeskChannelMessage.text) {
|
|
61
|
+
text = tiledeskChannelMessage.text.replace(/-{1,}/g, '');
|
|
62
|
+
text = text.replace(/\*{2,}/g, '*')
|
|
63
|
+
}
|
|
58
64
|
|
|
59
65
|
let whatsapp_message = {
|
|
60
66
|
messaging_product: TiledeskWhatsappTranslator.WHATSAPP_MESSAGING_PRODUCT,
|
|
@@ -62,24 +68,24 @@ class TiledeskWhatsappTranslator {
|
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
if (tiledeskChannelMessage.metadata) {
|
|
65
|
-
|
|
71
|
+
|
|
66
72
|
if (tiledeskChannelMessage.metadata.type.startsWith('image')) {
|
|
67
|
-
|
|
73
|
+
//if (tiledeskChannelMessage.metadata.type.startsWith('image/')) {
|
|
68
74
|
var imgUrl = tiledeskChannelMessage.metadata.src;
|
|
69
75
|
whatsapp_message.type = 'image'
|
|
70
76
|
whatsapp_message.image = {
|
|
71
77
|
link: imgUrl,
|
|
72
78
|
caption: text
|
|
73
79
|
}
|
|
74
|
-
}
|
|
80
|
+
}
|
|
75
81
|
|
|
76
82
|
else if (tiledeskChannelMessage.metadata.type.startsWith('video')) {
|
|
77
|
-
|
|
83
|
+
//if (tiledeskChannelMessage.metadata.type.startsWith('video/')) {
|
|
78
84
|
var videoUrl = tiledeskChannelMessage.metadata.src;
|
|
79
|
-
whatsapp_message.type = '
|
|
80
|
-
whatsapp_message.
|
|
85
|
+
whatsapp_message.type = 'video'
|
|
86
|
+
whatsapp_message.video = {
|
|
81
87
|
link: videoUrl,
|
|
82
|
-
caption:
|
|
88
|
+
caption: tiledeskChannelMessage.metadata.name
|
|
83
89
|
}
|
|
84
90
|
/*
|
|
85
91
|
data.type = 'video'
|
|
@@ -91,7 +97,7 @@ class TiledeskWhatsappTranslator {
|
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
else if (tiledeskChannelMessage.metadata.type.startsWith('application')) {
|
|
94
|
-
|
|
100
|
+
//if (tiledeskChannelMessage.metadata.type.startsWith('application/')) {
|
|
95
101
|
var doc = tiledeskChannelMessage.metadata.src;
|
|
96
102
|
whatsapp_message.type = 'document'
|
|
97
103
|
whatsapp_message.document = {
|
|
@@ -141,7 +147,7 @@ class TiledeskWhatsappTranslator {
|
|
|
141
147
|
console.log("[Translator] whatsapp message: ", whatsapp_message)
|
|
142
148
|
}
|
|
143
149
|
return whatsapp_message;
|
|
144
|
-
|
|
150
|
+
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
if (buttons_count > 0 && buttons_count < 4) {
|
|
@@ -311,7 +317,7 @@ class TiledeskWhatsappTranslator {
|
|
|
311
317
|
}
|
|
312
318
|
return whatsapp_message;
|
|
313
319
|
|
|
314
|
-
|
|
320
|
+
|
|
315
321
|
//return null
|
|
316
322
|
}
|
|
317
323
|
}
|