@tiledesk/tiledesk-whatsapp-connector 0.1.43 → 0.1.45

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 CHANGED
@@ -10,7 +10,7 @@ const pjson = require('./package.json');
10
10
  const { v4: uuidv4 } = require('uuid');
11
11
  const cors = require('cors');
12
12
  var winston = require('./winston');
13
- const url = require('url');
13
+ const url = require('url');
14
14
 
15
15
  // tiledesk clients
16
16
  //const { TiledeskClient } = require('@tiledesk/tiledesk-client');
@@ -73,7 +73,7 @@ router.get('/detail', async (req, res) => {
73
73
  const tdChannel = new TiledeskChannel({ settings: { project_id: project_id, token: token }, API_URL: API_URL })
74
74
  let isAvailable = await tdChannel.getProjectDetail();
75
75
  winston.debug("(wab) app is available: ", isAvailable);
76
-
76
+
77
77
  const appClient = new TiledeskAppsClient({ APPS_API_URL: APPS_API_URL });
78
78
  let installation = await appClient.getInstallations(project_id, app_id);
79
79
 
@@ -117,14 +117,14 @@ router.post('/install', async (req, res) => {
117
117
  winston.debug("(wab) installation response: " + installation);
118
118
 
119
119
  res.redirect(url.format({
120
- pathname:"/detail",
121
- query: {
120
+ pathname: "/detail",
121
+ query: {
122
122
  "project_id": project_id,
123
123
  "app_id": app_id,
124
124
  "token": token
125
125
  }
126
126
  }));
127
-
127
+
128
128
  }).catch((err) => {
129
129
  winston.error("(wab) installation error: " + err.data)
130
130
  res.send("An error occurred during the installation");
@@ -145,8 +145,8 @@ router.post('/uninstall', async (req, res) => {
145
145
  winston.debug("(wab) uninstallation response: " + response);
146
146
 
147
147
  res.redirect(url.format({
148
- pathname:"/detail",
149
- query: {
148
+ pathname: "/detail",
149
+ query: {
150
150
  "project_id": project_id,
151
151
  "app_id": app_id,
152
152
  "token": token
@@ -163,65 +163,79 @@ router.get('/configure', async (req, res) => {
163
163
 
164
164
  winston.verbose("(wab) /configure");
165
165
 
166
- let projectId = "";
167
- let token = "";
168
-
169
- projectId = req.query.project_id;
170
- token = req.query.token;
171
-
172
- let proxy_url = BASE_URL + "/webhook/" + projectId;
173
-
174
- let CONTENT_KEY = "whatsapp-" + projectId;
175
-
176
- let settings = await db.get(CONTENT_KEY);
177
- winston.debug("(wab) settings: " + settings);
178
-
179
- // get departments
180
- const tdChannel = new TiledeskChannel({ settings: { project_id: projectId, token: token }, API_URL: API_URL })
181
- let departments = await tdChannel.getDepartments(token);
182
- winston.debug("(wab) found " + departments.length + " departments")
183
-
184
- if (settings) {
166
+ let project_id = req.query.project_id;
167
+ let token = req.query.token;
185
168
 
186
- readHTMLFile('/configure.html', (err, html) => {
169
+ if (!project_id || !token) {
170
+ let error_message = "Query params project_id and token are required."
171
+ readHTMLFile('/error.html', (err, html) => {
187
172
  var template = handlebars.compile(html);
173
+
188
174
  var replacements = {
189
175
  app_version: pjson.version,
190
- project_id: projectId,
191
- token: token,
192
- proxy_url: proxy_url,
193
- wab_token: settings.wab_token,
194
- verify_token: settings.verify_token,
195
- subscription_id: settings.subscriptionId,
196
- department_id: settings.department_id,
197
- departments: departments
176
+ error_message: error_message
198
177
  }
199
178
  var html = template(replacements);
200
- res.send(html);
201
-
179
+ return res.send(html);
202
180
  })
203
181
 
204
182
  } else {
205
183
 
206
- readHTMLFile('/configure.html', (err, html) => {
184
+ let proxy_url = BASE_URL + "/webhook/" + project_id;
207
185
 
208
- if (err) {
209
- winston.error("(wab) error read html file: " + err);
210
- }
186
+ let CONTENT_KEY = "whatsapp-" + project_id;
211
187
 
212
- var template = handlebars.compile(html);
213
- var replacements = {
214
- app_version: pjson.version,
215
- project_id: projectId,
216
- token: token,
217
- proxy_url: proxy_url,
218
- departments: departments
219
- }
220
- var html = template(replacements);
221
- res.send(html);
188
+ let settings = await db.get(CONTENT_KEY);
189
+ winston.debug("(wab) settings: " + settings);
222
190
 
223
- })
191
+ // get departments
192
+ const tdChannel = new TiledeskChannel({ settings: { project_id: project_id, token: token }, API_URL: API_URL })
193
+ let departments = await tdChannel.getDepartments(token);
194
+ winston.debug("(wab) found " + departments.length + " departments")
195
+
196
+ if (settings) {
197
+
198
+ readHTMLFile('/configure.html', (err, html) => {
199
+ var template = handlebars.compile(html);
200
+ var replacements = {
201
+ app_version: pjson.version,
202
+ project_id: project_id,
203
+ token: token,
204
+ proxy_url: proxy_url,
205
+ wab_token: settings.wab_token,
206
+ verify_token: settings.verify_token,
207
+ subscription_id: settings.subscriptionId,
208
+ department_id: settings.department_id,
209
+ departments: departments
210
+ }
211
+ var html = template(replacements);
212
+ res.send(html);
213
+
214
+ })
215
+
216
+ } else {
217
+
218
+ readHTMLFile('/configure.html', (err, html) => {
219
+
220
+ if (err) {
221
+ winston.error("(wab) error read html file: " + err);
222
+ }
223
+
224
+ var template = handlebars.compile(html);
225
+ var replacements = {
226
+ app_version: pjson.version,
227
+ project_id: project_id,
228
+ token: token,
229
+ proxy_url: proxy_url,
230
+ departments: departments
231
+ }
232
+ var html = template(replacements);
233
+ res.send(html);
234
+
235
+ })
236
+ }
224
237
  }
238
+
225
239
  })
226
240
 
227
241
  router.post('/update', async (req, res) => {
@@ -394,6 +408,7 @@ router.post('/tiledesk', async (req, res) => {
394
408
  winston.verbose("(wab) Message received from Tiledesk")
395
409
 
396
410
  var tiledeskChannelMessage = req.body.payload;
411
+ //winston.verbose("(wab) tiledeskChannelMessage: ", tiledeskChannelMessage)
397
412
  var projectId = req.body.payload.id_project;
398
413
 
399
414
  // get settings from mongo
@@ -426,15 +441,52 @@ router.post('/tiledesk', async (req, res) => {
426
441
  }
427
442
 
428
443
  let recipient_id = tiledeskChannelMessage.recipient;
444
+ let sender = tiledeskChannelMessage.sender;
429
445
  let whatsapp_receiver = recipient_id.substring(recipient_id.lastIndexOf("-") + 1);
430
446
  let phone_number_id = recipient_id.substring(recipient_id.lastIndexOf("wab-") + 4, recipient_id.lastIndexOf("-"));
431
447
 
448
+ /*
449
+ if (settings.expired &&
450
+ settings.expired === true) {
451
+ winston.info("settings expired: " + settings.expired);
452
+ return res.status(200).send({ success: 'false', message: "plan expired"})
453
+
454
+ */
455
+
456
+ // Return an info message option
457
+ if (settings.expired &&
458
+ settings.expired === true) {
459
+
460
+ winston.verbose("settings expired: " + settings.expired);
461
+ let tiledeskJsonMessage = {
462
+ text: 'Expired. Upgrade Plan.',
463
+ sender: sender,
464
+ senderFullname: "System",
465
+ attributes: {
466
+ subtype: 'info'
467
+ },
468
+ channel: { name: 'whatsapp'}
469
+ }
470
+ let message_info = {
471
+ channel: "whatsapp",
472
+ whatsapp: {
473
+ from: whatsapp_receiver,
474
+ phone_number_id: phone_number_id
475
+ }
476
+ }
477
+
478
+ const tdChannel = new TiledeskChannel({ settings: settings, API_URL: API_URL })
479
+ const response = await tdChannel.send(tiledeskJsonMessage, message_info, settings.department_id);
480
+ winston.verbose("(wab) Expiration message sent to Tiledesk")
481
+ return res.sendStatus(200);
482
+ }
483
+
432
484
  winston.debug("(wab) text: " + text);
433
485
  winston.debug("(wab) attributes: " + attributes)
434
486
  winston.debug("(wab) tiledesk sender_id: " + sender_id);
435
487
  winston.debug("(wab) recipient_id: " + recipient_id);
436
488
  winston.debug("(wab) whatsapp_receiver: " + whatsapp_receiver);
437
- winston.debug("(wab) phone_number_id: " + phone_number_id)
489
+ winston.debug("(wab) phone_number_id: " + phone_number_id);
438
490
 
439
491
  const messageHandler = new MessageHandler({ tiledeskChannelMessage: tiledeskChannelMessage });
440
492
  const tlr = new TiledeskWhatsappTranslator();
@@ -529,7 +581,7 @@ router.post("/webhook/:project_id", async (req, res) => {
529
581
  ) {
530
582
 
531
583
  if (req.body.entry[0].changes[0].value.messages[0].type == "system") {
532
- winston.verbos("(wab) Skip system message")
584
+ winston.verbose("(wab) Skip system message")
533
585
  return res.sendStatus(200);
534
586
  }
535
587
 
@@ -750,32 +802,37 @@ async function startApp(settings, callback) {
750
802
  winston.info("(wab) Starting Whatsapp App")
751
803
 
752
804
  if (!settings.MONGODB_URL) {
753
- throw new Error("settings.MONGODB_URL is mandatory");
805
+ winston.error("(wab) MONGODB_URL is mandatory. Exit...");
806
+ return callback('Missing parameter: MONGODB_URL');
754
807
  }
755
808
 
756
809
  if (!settings.API_URL) {
757
- throw new Error("settings.API_URL is mandatory");
810
+ winston.error("(wab) API_URL is mandatory. Exit...");
811
+ return callback('Missing parameter: API_URL');
758
812
  } else {
759
813
  API_URL = settings.API_URL;
760
814
  winston.info("(wab) API_URL: " + API_URL);
761
815
  }
762
816
 
763
817
  if (!settings.BASE_URL) {
764
- throw new Error("settings.BASE_URL is mandatory");
818
+ winston.error("(wab) BASE_URL is mandatory. Exit...");
819
+ return callback('Missing parameter: BASE_URL');
765
820
  } else {
766
821
  BASE_URL = settings.BASE_URL;
767
822
  winston.info("(wab) BASE_URL: " + BASE_URL);
768
823
  }
769
824
 
770
825
  if (!settings.GRAPH_URL) {
771
- throw new Error("settings.GRAPH_URL is mandatory");
826
+ winston.error("(wab) GRAPH_URL is mandatory. Exit...");
827
+ return callback('Missing parameter: GRAPH_URL');
772
828
  } else {
773
829
  GRAPH_URL = settings.GRAPH_URL;
774
830
  winston.info("(wab) GRAPH_URL: " + GRAPH_URL);
775
831
  }
776
832
 
777
833
  if (!settings.APPS_API_URL) {
778
- throw new Error("settings.APPS_API_URL is mandatory");
834
+ winston.error("(wab) APPS_API_URL is mandatory. Exit...");
835
+ return callback('Missing parameter: APPS_API_URL');
779
836
  } else {
780
837
  APPS_API_URL = settings.APPS_API_URL;
781
838
  winston.info("(wab) APPS_API_URL: " + APPS_API_URL);
@@ -794,7 +851,7 @@ async function startApp(settings, callback) {
794
851
  winston.info("(wab) KVBaseMongo successfully connected.");
795
852
 
796
853
  if (callback) {
797
- callback();
854
+ callback(null);
798
855
  }
799
856
  })
800
857
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-whatsapp-connector",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "description": "Tiledesk Whatsapp connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -67,7 +67,7 @@
67
67
  <div class="header-content">
68
68
  <div class="logo-title">
69
69
  <div class="logo-container">
70
- <img src="https://www.clipartmax.com/png/full/205-2058823_whatsapp-ios-icon-whatsapp-ios-icon-png.png" width="60px" height="60px">
70
+ <img src="https://user-images.githubusercontent.com/45603238/200829081-e6a9c7a0-9d8c-431c-a477-4880a8fd752f.png" width="60px" height="60px">
71
71
  </div>
72
72
  <div class="title-version">
73
73
  <p class="title">WhatsApp Business Connector</p>
@@ -300,6 +300,6 @@
300
300
  console.error('Async: Could not copy text: ', err);
301
301
  }
302
302
  }
303
- </script>
303
+ </script>
304
304
 
305
305
  </body>
@@ -0,0 +1,67 @@
1
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
2
+
3
+
4
+ body {
5
+ padding: 20px 0px;
6
+ }
7
+
8
+ .header {
9
+ width: 100%;
10
+ display: flex;
11
+ justify-content: center;
12
+ }
13
+
14
+ .header-content {
15
+ width: 50%;
16
+ display: flex;
17
+ flex-direction: row;
18
+ align-items: center;
19
+ justify-content: space-between;
20
+ }
21
+
22
+ .logo-title {
23
+ display: flex;
24
+ flex-direction: row;
25
+ align-items: center;
26
+ }
27
+
28
+ .title {
29
+ margin-bottom: 0px;
30
+ font-size: 22px;
31
+ }
32
+
33
+ .title-version {
34
+ display: flex;
35
+ flex-direction: column;
36
+ align-items: flex-start;
37
+ }
38
+
39
+ .logo-container {
40
+ margin: 0px 20px 0px 0px;
41
+ }
42
+
43
+ .logo-title {
44
+ display: flex;
45
+ flex-direction: row;
46
+ align-items: center;
47
+ }
48
+
49
+ .error {
50
+ width: 100%;
51
+ display: flex;
52
+ justify-content: center;
53
+ margin-top: 60px;
54
+ }
55
+
56
+ .error-box {
57
+ width: 50%;
58
+ background-color: #f79a9a;
59
+ min-height: 100px;
60
+ border-radius: 8px;
61
+ padding: 10px 10px;
62
+ }
63
+
64
+ .error-title {
65
+ font-size: 18px;
66
+ font-weight: 500;
67
+ }
@@ -207,39 +207,39 @@
207
207
  </div>
208
208
  </div>
209
209
  </div>
210
-
211
-
210
+ </div>
211
+
212
212
  <hr style="margin-top: 20px; margin-bottom: 20px">
213
213
 
214
214
  <p style="font-size: 18px;"><b>What's new?</b></p>
215
215
 
216
- <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
217
- <div>
218
- <p style="margin-bottom: 0px">Added possibility to select a department for Whatsapp conversations.</p>
219
- <p style="margin-bottom: 0px">Bug fixes and minor improvements</p>
220
- <!--<p>Bug fixes and performance improvements</p>-->
221
- </div>
222
- <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.34</b></p>
216
+ <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
217
+ <div>
218
+ <p style="margin-bottom: 0px">Bug fixes and minor improvements</p>
219
+ <!--<p>Bug fixes and performance improvements</p>-->
223
220
  </div>
221
+ <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.45</b></p>
222
+ </div>
224
223
 
225
- <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
224
+ <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
226
225
  <div>
227
- <p style="margin-bottom: 0px">Bug Fixes</p>
228
- <p style="margin-bottom: 0px">Minor improvements</p>
226
+ <p style="margin-bottom: 0px">Added possibility to select a department for Whatsapp conversations.</p>
227
+ <p style="margin-bottom: 0px">Bug fixes and minor improvements</p>
229
228
  <!--<p>Bug fixes and performance improvements</p>-->
230
229
  </div>
231
- <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.31</b></p>
230
+ <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.34</b></p>
232
231
  </div>
233
232
 
234
233
  <div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
235
234
  <div>
236
- <p style="margin-bottom: 0px">Added support for Test-it-out</p>
235
+ <p style="margin-bottom: 0px">Bug Fixes</p>
237
236
  <p style="margin-bottom: 0px">Minor improvements</p>
238
237
  <!--<p>Bug fixes and performance improvements</p>-->
239
238
  </div>
240
- <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.24</b></p>
239
+ <p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.31</b></p>
241
240
  </div>
242
241
 
242
+
243
243
  <hr style="margin-top: 50px; margin-bottom: 20px">
244
244
 
245
245
  </body>
@@ -0,0 +1,91 @@
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="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
28
+ <link rel="stylesheet" href="./css/error.css">
29
+
30
+ <style>
31
+ body {
32
+ font-family: 'Poppins', serif;
33
+ }
34
+ </style>
35
+
36
+ </head>
37
+
38
+
39
+ <body>
40
+
41
+ <!-- Success modal -->
42
+ <!--
43
+ {{#if show_success_modal}}
44
+ <div id="success-update-modal" class="success-modal">
45
+ <div class="modal-content">
46
+ <img src="https://www.pngall.com/wp-content/uploads/9/Green-Tick-Vector-PNG-Images.png" width="80" height="auto" />
47
+ <p class="modal-text" style="margin-top: 20px; margin-bottom: 20px;">Configuration updated successfully</p>
48
+ <button class="btn cancel-btn" onclick="document.getElementById('success-update-modal').style.display='none'">Close</button>
49
+ </div>
50
+ </div>
51
+ {{/if}}
52
+ -->
53
+
54
+ <!-- Error modal -->
55
+ <!--
56
+ {{#if show_error_modal}}
57
+ <div id="error-update-modal" class="error-modal">
58
+ <div class="modal-content">
59
+ <img src="https://cdn-icons-png.flaticon.com/512/148/148766.png" width="80" height="auto" />
60
+ <p style="margin-top: 20px; margin-bottom: 20px;">An error occurred while updating the configuration</p>
61
+ <button class="btn cancel-btn" onclick="document.getElementById('error-update-modal').style.display='none'">Close</button>
62
+ </div>
63
+ </div>
64
+ {{/if}}
65
+ -->
66
+
67
+ <!-- HEADER -->
68
+ <div class="header">
69
+ <div class="header-content">
70
+ <div class="logo-title">
71
+ <div class="logo-container">
72
+ <img src="https://user-images.githubusercontent.com/45603238/200829081-e6a9c7a0-9d8c-431c-a477-4880a8fd752f.png" width="60px" height="60px">
73
+ </div>
74
+ <div class="title-version">
75
+ <p class="title">WhatsApp Business Connector</p>
76
+ <div class="status-box" style="padding: 0px 8px; letter-spacing: 1px; height: 18px;">
77
+ <p style="margin-bottom: 0px;">{{ app_version }}</p>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>
82
+ </div>
83
+
84
+ <div class="error">
85
+ <div class="error-box">
86
+ <p class="error-title">Ops! Something went wrong.</p>
87
+ <p>{{ error_message }}</p>
88
+ </div>
89
+ </div>
90
+
91
+ </body>
@@ -1,206 +0,0 @@
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>
32
-
33
- <div style="padding: 100px 230px; background-color: #efefef; min-width: 800px; display: flex; justify-content: center;" >
34
-
35
- <div style="background-color: white; border-radius: 8px; padding: 20px; box-shadow: 0px 0px 5px 0px #cfcfcf; min-width: 800px;">
36
-
37
- <div>
38
-
39
- <div style="display: flex; flex-direction: row; align-items: center;">
40
-
41
- <div style="margin-right: 80px;">
42
- <img width="130" height="auto" style="margin-top: 6px;" src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/WhatsApp.svg/479px-WhatsApp.svg.png" alt="..." class="img-rounded">
43
- </div>
44
-
45
- <div>
46
-
47
- <h1 style="margin-top: 0px; margin-bottom: 2px; min-width: 500px;">WhatsApp Business</h1>
48
- <div style="display: flex; flex-direction: row; align-items: flex-end;">
49
- <h7 style="color: rgb(140, 140, 140); margin-right: 10px;">by Tiledesk</h7>
50
- <div class="version">
51
- <a class="npm-link" href="https://www.npmjs.com/package/@tiledesk/tiledesk-whatsapp-connector" target="_blank">{{ app_version }}</a>
52
- </div>
53
- </div>
54
-
55
- {{#if wab_token}}
56
- <div style="margin-top: 20px;">
57
- <h7 style="color: rgb(140, 140, 140);">The Whatsapp Business App is configured on your Tildesk project.</h7>
58
- <form action="./disconnect" method="post">
59
- <input type="hidden" name="project_id" value="{{ project_id }}">
60
- <input type="hidden" name="token" value="{{ token }}">
61
- <input type="hidden" name="subscription_id" value="{{ subscription_id }}">
62
- <input type="submit" class="btn btn-danger" style="margin-top: 10px; width: 160px;" value="Disconnect">
63
- </form>
64
- </div>
65
- {{/if}}
66
-
67
- </div>
68
- </div>
69
-
70
- <!--
71
- <button onClick="javascript:window.open('https://gethelp.tiledesk.com/articles/telegram/', '_blank');" class="btn btn- primary">View Documentation</button>
72
- -->
73
-
74
- <div style="margin-top: 40px; padding: 20px; background-color: aliceblue; border-radius: 8px; min-width: 600px;">
75
- <h7>Receive Whatsapp bot conversations in your Tiledesk dashboard. Seamlessly Chat with your targeted audience on Whatsapp right from the Tiledesk dashboard.</h7>
76
- <ul>
77
- <li>
78
- <h7>Integrate your Whatsapp number with Tiledesk.</h7>
79
- </li>
80
- <li>
81
- <h7>Once a chat is initiated on your Whatsapp number, receive an alert on your Tiledesk account.</h7>
82
- </li>
83
- <li>
84
- <h7>Enable instant messaging and answer multiple conversations - everything from Tiledesk account.</h7>
85
- </li>
86
- </ul>
87
- </div>
88
-
89
- <div style="margin-top: 10px;">
90
- <a href="https://gethelp.tiledesk.com/categories/whatsapp-business/" target="_blank">View documentation</a>
91
- </div>
92
-
93
-
94
- <hr>
95
-
96
-
97
- <div>
98
- <h4>Your Configuration</h4>
99
-
100
- <div style="min-width: 600px">
101
- <form action="./update" method="post">
102
-
103
- <div class="form-group" style="width: 490px;">
104
- <label for="proxy_url">Webhook Endpoint
105
- <span style="margin-left: 10px;">
106
- <i class="fa fa-question-circle custom-tooltip" style="color: #337ab7;">
107
- <span class="custom-tooltiptext">This is the endpoint to be reached by WhatsApp. Copy it to the Facebook Developer console in "Callback URL" in Whatsapp Configuration. See documention for more info.</span>
108
- </i>
109
- </span>
110
- </label>
111
- <!--<p style="margin-bottom: 5px; font-size: 12px; color: #a7a7a7;">Copy this URL in the Facebook Developer Dashboad. See documentation for more info.</p> -->
112
- <div style="display: flex; flex-direction: row; justify-content: space-between">
113
- <div style="width: 400px;">
114
- <input type="text" readonly class="form-control" name="proxy_url" id="proxy_url"
115
- value="{{ proxy_url}}">
116
- </div>
117
- <div style="width: 80px;">
118
- <!--
119
- <input type="button" class="btn btn-primary" style="width: 100%;"
120
- onclick="copyTextToClipboard(this, document.getElementById('proxy_url').value)"
121
- value="Copy"></input>
122
- -->
123
- <input type="button" id="copy-btn" class="btn btn-primary" style="width: 100%;"
124
- onclick="copyTextToClipboard()"
125
- value="Copy"></input>
126
- </div>
127
-
128
- </div>
129
- </div>
130
-
131
- <div class="form-group" style="width: 400px;">
132
- <label for="wab_token">Whatsapp Token
133
- <span style="margin-left: 10px;">
134
- <i class="fa fa-question-circle custom-tooltip" style="color: #337ab7;">
135
- <span class="custom-tooltiptext">Paste it the permanent WhatsApp Business token. See documention for more info.</span>
136
- </i>
137
- </span>
138
- </label>
139
- <input type="text" class="form-control" name="wab_token" value="{{ wab_token }}"
140
- placeholder="Enter the Whatsapp Token">
141
- </div>
142
-
143
- <div class="form-group" style="width: 400px;">
144
- <label for="verify_token">Verify Token
145
- <span style="margin-left: 10px;">
146
- <i class="fa fa-question-circle custom-tooltip" style="color: #337ab7;">
147
- <span class="custom-tooltiptext">This is a verification token of your choice. Copy it to the Facebook Developer console in "Verify Token" in Whatsapp Configuration.
148
- See documention for more info.</span>
149
- </i>
150
- </span>
151
- </label>
152
- <input type="password" class="form-control" name="verify_token" value="{{ verify_token }}"
153
- placeholder="Enter your Verify Token">
154
- </div>
155
-
156
- <input type="hidden" name="project_id" value="{{ project_id }}" />
157
- <input type="hidden" name="token" value="{{ token }}" />
158
-
159
- {{#if wab_token}}
160
- <div style="width: 400px; text-align: right;">
161
- <input type="submit" class="btn btn-primary" style="width: 35%;" value="Update">
162
- </div>
163
- {{else}}
164
- <div style="width: 400px; text-align: right;">
165
- <input type="submit" class="btn btn-primary" style="width: 35%;" value="Connect">
166
- </div>
167
- {{/if}}
168
-
169
- </form>
170
-
171
-
172
- </div>
173
- </div>
174
-
175
- </div>
176
-
177
- </div>
178
- </div>
179
-
180
- <script>
181
-
182
- function copyTextToClipboard2(btn, text) {
183
- console.log("Button clicked")
184
- btn.value = "Copied!"
185
- navigator.clipboard.writeText(text).then(function () {
186
- console.log('Async: Copied to clipboard!');
187
- }, function (err) {
188
- console.error('Async: Could not copy text: ', err);
189
- });
190
- }
191
-
192
- function copyTextToClipboard() {
193
- const proxyUrl = document.getElementById('proxy_url').select()
194
- try {
195
- document.execCommand('copy');
196
- console.log('Async: Copied to clipboard!');
197
- let btn = document.getElementById('copy-btn');
198
- btn.value = "Copied!";
199
- } catch (err) {
200
- console.error('Async: Could not copy text: ', err);
201
- }
202
- }
203
- </script>
204
-
205
-
206
- </body>