@tiledesk/tiledesk-whatsapp-connector 1.0.11 → 1.0.13
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/package.json +1 -1
- package/routes/api.js +11 -11
- package/template/configure.html +16 -18
- package/template/css/configure.css +21 -1
- package/template/css/template_detail.css +1 -0
- package/template/detail.html +16 -16
- package/template/error.html +15 -16
- package/template/template_detail.html +15 -16
- package/template/templates.html +15 -16
- package/tiledesk/TiledeskWhatsappTranslator.js +49 -10
package/package.json
CHANGED
package/routes/api.js
CHANGED
|
@@ -145,26 +145,26 @@ router.post('/tiledesk/broadcast', async (req, res) => {
|
|
|
145
145
|
winston.verbose("(wab) Action received from Tiledesk (Broadcast)");
|
|
146
146
|
winston.debug("Body (broadcast): ", JSON.stringify(req.body, null, 2));
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
const { id_project, template, receiver_list, phone_number_id, transaction_id, broadcast = true } = req.body;
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
const requiredFields = ['id_project', 'template', 'phone_number_id'];
|
|
151
|
+
const missingFields = requiredFields.filter(field => !req.body[field]);
|
|
152
|
+
|
|
153
|
+
if (missingFields.length > 0) {
|
|
154
|
+
return res.status(400).send({ success: false, error: `Missing parameters: ${missingFields.join(', ')}` });
|
|
155
|
+
}
|
|
156
156
|
|
|
157
157
|
if (!transaction_id) {
|
|
158
158
|
transaction_id = "tiledesk-broadcast-" + Date.now();
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
let settings = await utils.getSettingsByProjectId(
|
|
161
|
+
let settings = await utils.getSettingsByProjectId(id_project);
|
|
162
162
|
if (!settings) {
|
|
163
|
-
settings = await utils.getSettings(
|
|
163
|
+
settings = await utils.getSettings(id_project, null);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
if (!settings) {
|
|
167
|
-
return res.status(400).send({ success: false, error: "WhatsApp is not installed for the project_id: " +
|
|
167
|
+
return res.status(400).send({ success: false, error: "WhatsApp is not installed for the project_id: " + id_project });
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
if (!settings.business_account_id) {
|
|
@@ -173,7 +173,7 @@ router.post('/tiledesk/broadcast', async (req, res) => {
|
|
|
173
173
|
|
|
174
174
|
let scheduler = new Scheduler({ AMQP_MANAGER_URL: AMQP_MANAGER_URL, JOB_TOPIC_EXCHANGE: JOB_TOPIC_EXCHANGE });
|
|
175
175
|
let data_To_scheduler = {
|
|
176
|
-
project_id:
|
|
176
|
+
project_id: id_project,
|
|
177
177
|
receiver_list: receiver_list,
|
|
178
178
|
phone_number_id: phone_number_id,
|
|
179
179
|
transaction_id: transaction_id,
|
package/template/configure.html
CHANGED
|
@@ -6,26 +6,25 @@
|
|
|
6
6
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
8
|
|
|
9
|
-
<!--
|
|
10
|
-
<link rel="stylesheet" href="https://
|
|
11
|
-
|
|
9
|
+
<!-- Bootstrap 5.3 CSS -->
|
|
10
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
|
11
|
+
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
|
12
|
+
crossorigin="anonymous">
|
|
12
13
|
|
|
13
|
-
<!--
|
|
14
|
-
<link rel="stylesheet" href="https://
|
|
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">
|
|
14
|
+
<!-- Font Awesome 7 (latest version) -->
|
|
15
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" crossorigin="anonymous" />
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
<
|
|
17
|
+
<!-- Font Poppins -->
|
|
18
|
+
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet" />
|
|
21
19
|
|
|
22
|
-
<!--
|
|
23
|
-
|
|
24
|
-
integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous">
|
|
25
|
-
</script>
|
|
20
|
+
<!-- Custom CSS -->
|
|
21
|
+
<link rel="stylesheet" href="./css/configure.css">
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
<
|
|
23
|
+
<!-- Bootstrap 5.3 JavaScript Bundle (include Popper) -->
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
|
25
|
+
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
|
26
|
+
crossorigin="anonymous">
|
|
27
|
+
</script>
|
|
29
28
|
|
|
30
29
|
<style>
|
|
31
30
|
body {
|
|
@@ -214,8 +213,7 @@
|
|
|
214
213
|
|
|
215
214
|
{{#if isOAuth}}
|
|
216
215
|
<button onclick="launchWhatsAppSignup()" class="btn"
|
|
217
|
-
style="
|
|
218
|
-
background-color: #075E54;
|
|
216
|
+
style="background-color: #075E54;
|
|
219
217
|
color: white;
|
|
220
218
|
font-weight: 500;
|
|
221
219
|
display: flex; align-items: center; justify-content: center">
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
body {
|
|
4
4
|
padding: 20px 0px;
|
|
5
|
+
font-size: 14px;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
.header {
|
|
@@ -105,6 +106,9 @@ ul {
|
|
|
105
106
|
margin-top: 20px;
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
.form-group {
|
|
110
|
+
margin-bottom: 15px;
|
|
111
|
+
}
|
|
108
112
|
|
|
109
113
|
.input-label {
|
|
110
114
|
margin-bottom: 5px;
|
|
@@ -128,7 +132,7 @@ ul {
|
|
|
128
132
|
padding: 0px 8px;
|
|
129
133
|
cursor: pointer;
|
|
130
134
|
margin-top: 12px;
|
|
131
|
-
margin-left: -
|
|
135
|
+
margin-left: -66px;
|
|
132
136
|
font-size: 18px;
|
|
133
137
|
}
|
|
134
138
|
|
|
@@ -141,6 +145,12 @@ ul {
|
|
|
141
145
|
padding: 6px 36px 6px 14px;
|
|
142
146
|
}
|
|
143
147
|
|
|
148
|
+
input[readonly],
|
|
149
|
+
textarea[readonly] {
|
|
150
|
+
background-color: #eee !important;
|
|
151
|
+
opacity: 1;
|
|
152
|
+
}
|
|
153
|
+
|
|
144
154
|
.custom-input {
|
|
145
155
|
height: 45px;
|
|
146
156
|
box-shadow: 0px 0px 7px 0px #bdbdbd;
|
|
@@ -164,6 +174,15 @@ ul {
|
|
|
164
174
|
box-shadow: 0px 0px 7px 0px #bdbdbd;
|
|
165
175
|
border: solid 2px transparent;
|
|
166
176
|
border-radius: 6px;
|
|
177
|
+
appearance: none; /* Rimuove lo stile di default */
|
|
178
|
+
-webkit-appearance: none; /* Safari */
|
|
179
|
+
-moz-appearance: none; /* Firefox */
|
|
180
|
+
background-color: #fff;
|
|
181
|
+
background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='gray' class='bi bi-caret-down-fill' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14l-4.796-5.481C2.122 5.332 2.482 4.5 3.252 4.5h9.496c.77 0 1.13.832.801 1.159l-4.796 5.481a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
|
|
182
|
+
background-repeat: no-repeat;
|
|
183
|
+
background-position: right 0.75rem center; /* posizionamento freccia */
|
|
184
|
+
background-size: 12px;
|
|
185
|
+
padding-right: 2rem; /* spazio per la freccia */
|
|
167
186
|
}
|
|
168
187
|
|
|
169
188
|
.custom-select:hover {
|
|
@@ -188,6 +207,7 @@ ul {
|
|
|
188
207
|
width: 300px;
|
|
189
208
|
background-color: #8c8e8fbd;
|
|
190
209
|
font-size: 13px;
|
|
210
|
+
font-weight: 400;
|
|
191
211
|
color: #fff;
|
|
192
212
|
text-align: center;
|
|
193
213
|
padding: 8px 8px;
|
package/template/detail.html
CHANGED
|
@@ -6,25 +6,25 @@
|
|
|
6
6
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
8
|
|
|
9
|
-
<!--
|
|
10
|
-
<link rel="stylesheet" href="https://
|
|
11
|
-
|
|
9
|
+
<!-- Bootstrap 5.3 CSS -->
|
|
10
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
|
11
|
+
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
|
12
|
+
crossorigin="anonymous">
|
|
12
13
|
|
|
13
|
-
<!--
|
|
14
|
-
<link rel="stylesheet" href="https://
|
|
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">
|
|
14
|
+
<!-- Font Awesome 7 (latest version) -->
|
|
15
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" crossorigin="anonymous" />
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
<
|
|
17
|
+
<!-- Font Poppins -->
|
|
18
|
+
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet" />
|
|
21
19
|
|
|
22
|
-
<!--
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
<!-- Custom CSS -->
|
|
21
|
+
<link rel="stylesheet" href="./css/detail.css">
|
|
22
|
+
|
|
23
|
+
<!-- Bootstrap 5.3 JavaScript Bundle (include Popper) -->
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
|
25
|
+
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
|
26
|
+
crossorigin="anonymous">
|
|
27
|
+
</script>
|
|
28
28
|
|
|
29
29
|
<style>
|
|
30
30
|
body {
|
package/template/error.html
CHANGED
|
@@ -6,26 +6,25 @@
|
|
|
6
6
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
8
|
|
|
9
|
-
<!--
|
|
10
|
-
<link rel="stylesheet" href="https://
|
|
11
|
-
|
|
9
|
+
<!-- Bootstrap 5.3 CSS -->
|
|
10
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
|
11
|
+
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
|
12
|
+
crossorigin="anonymous">
|
|
12
13
|
|
|
13
|
-
<!--
|
|
14
|
-
<link rel="stylesheet" href="https://
|
|
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">
|
|
14
|
+
<!-- Font Awesome 7 (latest version) -->
|
|
15
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" crossorigin="anonymous" />
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
<
|
|
17
|
+
<!-- Font Poppins -->
|
|
18
|
+
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet" />
|
|
21
19
|
|
|
22
|
-
<!--
|
|
23
|
-
|
|
24
|
-
integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous">
|
|
25
|
-
</script>
|
|
20
|
+
<!-- Custom CSS -->
|
|
21
|
+
<link rel="stylesheet" href="./css/error.css">
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
<
|
|
23
|
+
<!-- Bootstrap 5.3 JavaScript Bundle (include Popper) -->
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
|
25
|
+
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
|
26
|
+
crossorigin="anonymous">
|
|
27
|
+
</script>
|
|
29
28
|
|
|
30
29
|
<style>
|
|
31
30
|
body {
|
|
@@ -6,26 +6,25 @@
|
|
|
6
6
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
8
|
|
|
9
|
-
<!--
|
|
10
|
-
<link rel="stylesheet" href="https://
|
|
11
|
-
|
|
9
|
+
<!-- Bootstrap 5.3 CSS -->
|
|
10
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
|
11
|
+
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
|
12
|
+
crossorigin="anonymous">
|
|
12
13
|
|
|
13
|
-
<!--
|
|
14
|
-
<link rel="stylesheet" href="https://
|
|
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">
|
|
14
|
+
<!-- Font Awesome 7 (latest version) -->
|
|
15
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" crossorigin="anonymous" />
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
<
|
|
17
|
+
<!-- Font Poppins -->
|
|
18
|
+
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet" />
|
|
21
19
|
|
|
22
|
-
<!--
|
|
23
|
-
|
|
24
|
-
integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous">
|
|
25
|
-
</script>
|
|
20
|
+
<!-- Custom CSS -->
|
|
21
|
+
<link rel="stylesheet" href="./css/template_detail.css">
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
<
|
|
23
|
+
<!-- Bootstrap 5.3 JavaScript Bundle (include Popper) -->
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
|
25
|
+
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
|
26
|
+
crossorigin="anonymous">
|
|
27
|
+
</script>
|
|
29
28
|
|
|
30
29
|
<style>
|
|
31
30
|
body {
|
package/template/templates.html
CHANGED
|
@@ -6,26 +6,25 @@
|
|
|
6
6
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
8
|
|
|
9
|
-
<!--
|
|
10
|
-
<link rel="stylesheet" href="https://
|
|
11
|
-
|
|
9
|
+
<!-- Bootstrap 5.3 CSS -->
|
|
10
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
|
11
|
+
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
|
12
|
+
crossorigin="anonymous">
|
|
12
13
|
|
|
13
|
-
<!--
|
|
14
|
-
<link rel="stylesheet" href="https://
|
|
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">
|
|
14
|
+
<!-- Font Awesome 7 (latest version) -->
|
|
15
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" crossorigin="anonymous" />
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
<
|
|
17
|
+
<!-- Font Poppins -->
|
|
18
|
+
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet" />
|
|
21
19
|
|
|
22
|
-
<!--
|
|
23
|
-
|
|
24
|
-
integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous">
|
|
25
|
-
</script>
|
|
20
|
+
<!-- Custom CSS -->
|
|
21
|
+
<link rel="stylesheet" href="./css/configure.css">
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
<
|
|
23
|
+
<!-- Bootstrap 5.3 JavaScript Bundle (include Popper) -->
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
|
25
|
+
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
|
26
|
+
crossorigin="anonymous">
|
|
27
|
+
</script>
|
|
29
28
|
|
|
30
29
|
<style>
|
|
31
30
|
body {
|
|
@@ -715,7 +715,8 @@ const path = require('path');
|
|
|
715
715
|
|
|
716
716
|
async createReceiversList(records) {
|
|
717
717
|
return records.map(row => {
|
|
718
|
-
|
|
718
|
+
|
|
719
|
+
//const phone_number = row.phone_number.startsWith('+') ? row.phone_number : `+39${row.phone_number}`;
|
|
719
720
|
const receiver = { phone_number };
|
|
720
721
|
|
|
721
722
|
let header_params = [];
|
|
@@ -726,27 +727,52 @@ const path = require('path');
|
|
|
726
727
|
if (!value || key === 'phone_number') continue;
|
|
727
728
|
|
|
728
729
|
if (key.startsWith('header')) {
|
|
729
|
-
|
|
730
|
+
const type = detectMediaType(value);
|
|
731
|
+
|
|
732
|
+
if (type === "text") {
|
|
733
|
+
header_params.push({
|
|
734
|
+
type: "text",
|
|
735
|
+
text: value
|
|
736
|
+
})
|
|
737
|
+
} else if (type === "image") {
|
|
730
738
|
header_params.push({
|
|
731
|
-
type: "
|
|
739
|
+
type: "image",
|
|
732
740
|
image: { link: value }
|
|
733
741
|
});
|
|
734
|
-
} else {
|
|
742
|
+
} else if (type === "video") {
|
|
735
743
|
header_params.push({
|
|
736
|
-
type: "
|
|
737
|
-
|
|
744
|
+
type: "video",
|
|
745
|
+
video: { link: value }
|
|
746
|
+
});
|
|
747
|
+
} else if (type === "document") {
|
|
748
|
+
header_params.push({
|
|
749
|
+
type: "document",
|
|
750
|
+
document: { link: value }
|
|
738
751
|
});
|
|
739
752
|
}
|
|
753
|
+
|
|
754
|
+
continue;
|
|
755
|
+
|
|
740
756
|
} else if (key.startsWith('body')) {
|
|
741
757
|
body_params.push({
|
|
742
758
|
type: "text",
|
|
743
759
|
text: value
|
|
744
760
|
});
|
|
745
761
|
} else if (key.startsWith('buttons')) {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
762
|
+
|
|
763
|
+
if (value.startsWith("http")) {
|
|
764
|
+
buttons_params.push({
|
|
765
|
+
type: "payload",
|
|
766
|
+
payload: value
|
|
767
|
+
});
|
|
768
|
+
} else {
|
|
769
|
+
buttons_params.push({
|
|
770
|
+
type: "text",
|
|
771
|
+
text: value
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
continue;
|
|
750
776
|
}
|
|
751
777
|
}
|
|
752
778
|
|
|
@@ -757,6 +783,19 @@ const path = require('path');
|
|
|
757
783
|
return receiver;
|
|
758
784
|
})
|
|
759
785
|
}
|
|
786
|
+
|
|
787
|
+
detectMediaType(value) {
|
|
788
|
+
if (!value.startsWith("http")) return "text";
|
|
789
|
+
|
|
790
|
+
const lower = value.toLowerCase();
|
|
791
|
+
|
|
792
|
+
if (lower.match(/\.(jpg|jpeg|png|gif|webp)$/)) return "image";
|
|
793
|
+
if (lower.match(/\.(mp4|mov|avi|mkv)$/)) return "video";
|
|
794
|
+
if (lower.match(/\.(pdf|doc|docx|xls|xlsx|ppt|pptx)$/)) return "document";
|
|
795
|
+
|
|
796
|
+
// default: immagine (come fa WhatsApp)
|
|
797
|
+
return "text";
|
|
798
|
+
}
|
|
760
799
|
/*
|
|
761
800
|
*************************************
|
|
762
801
|
********* WHATSAPP BUSINESS *********
|