@tiledesk/tiledesk-whatsapp-connector 0.1.51 → 0.1.52
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/logs/app.log +0 -4
- package/package.json +1 -1
- package/template/configure.html +17 -3
- package/template/detail.html +17 -10
- package/tiledesk/TiledeskWhatsappTranslator.js +18 -5
package/logs/app.log
CHANGED
package/package.json
CHANGED
package/template/configure.html
CHANGED
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
<label class="input-label" for="wab_token">Whatsapp Token
|
|
200
200
|
</label>
|
|
201
201
|
<div style="display: flex; flex-direction: row; align-items: center;">
|
|
202
|
-
<input type="text" required class="form-control custom-input" name="wab_token" value="{{ wab_token }}" placeholder="Enter the Whatsapp Token">
|
|
202
|
+
<input id="tkn" type="text" required class="form-control custom-input" name="wab_token" value="{{ wab_token }}" placeholder="Enter the Whatsapp Token">
|
|
203
203
|
<span style="margin-left: 10px;">
|
|
204
204
|
<i class="fa fa-question-circle custom-tooltip">
|
|
205
205
|
<span class="custom-tooltiptext">This is the permanent WhatsApp Business token.</span>
|
|
@@ -264,7 +264,8 @@
|
|
|
264
264
|
</div>
|
|
265
265
|
{{else}}
|
|
266
266
|
<div style="width: 500px; text-align: right;">
|
|
267
|
-
<input type="submit" class="btn" style="width: 200px; background-color: #0ba2dc; color: white; font-weight: 500;" value="Connect"
|
|
267
|
+
<input type="submit" class="btn" style="width: 200px; background-color: #0ba2dc; color: white; font-weight: 500;" value="Connect"
|
|
268
|
+
onclick="postMessage('connectWhatsapp')">
|
|
268
269
|
</div>
|
|
269
270
|
{{/if}}
|
|
270
271
|
</form>
|
|
@@ -289,7 +290,7 @@
|
|
|
289
290
|
<input type="hidden" name="project_id" value="{{ project_id }}">
|
|
290
291
|
<input type="hidden" name="token" value="{{ token }}">
|
|
291
292
|
<input type="hidden" name="subscription_id" value="{{ subscription_id }}">
|
|
292
|
-
<input type="submit" class="btn disconnect-button" style="margin-top: 10px; width: 160px;" value="Disconnect">
|
|
293
|
+
<input type="submit" class="btn disconnect-button" style="margin-top: 10px; width: 160px;" value="Disconnect" onclick="postMessage('disconnectWhatsapp')">
|
|
293
294
|
</form>
|
|
294
295
|
</div>
|
|
295
296
|
{{else}}
|
|
@@ -332,6 +333,19 @@
|
|
|
332
333
|
console.error('Async: Could not copy text: ', err);
|
|
333
334
|
}
|
|
334
335
|
}
|
|
336
|
+
|
|
337
|
+
function postMessage(action) {
|
|
338
|
+
|
|
339
|
+
const tkn = document.getElementById('tkn').value;
|
|
340
|
+
let connected = false;
|
|
341
|
+
if (tkn) {
|
|
342
|
+
connected = true;
|
|
343
|
+
}
|
|
344
|
+
const msg = { action: action, calledBy: 'whatsapp_proxy', connected: connected}
|
|
345
|
+
window.parent.postMessage(msg, '*');
|
|
346
|
+
}
|
|
347
|
+
|
|
335
348
|
</script>
|
|
349
|
+
|
|
336
350
|
|
|
337
351
|
</body>
|
package/template/detail.html
CHANGED
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
<input type="hidden" name="project_id" value="{{ project_id }}" />
|
|
108
108
|
<input type="hidden" name="app_id" value="{{ app_id }}" />
|
|
109
109
|
<input type="hidden" name="token" value="{{ token }}" />
|
|
110
|
-
<input type="submit" class="btn uninstall-button" value="Yes, uninstall">
|
|
110
|
+
<input type="submit" class="btn uninstall-button" value="Yes, uninstall" onclick="postMessage('uninstallWhatsapp')">
|
|
111
111
|
</form>
|
|
112
112
|
</div>
|
|
113
113
|
</div>
|
|
@@ -138,7 +138,8 @@
|
|
|
138
138
|
<input type="hidden" name="project_id" value="{{ project_id }}" />
|
|
139
139
|
<input type="hidden" name="app_id" value="{{ app_id }}" />
|
|
140
140
|
<input type="hidden" name="token" value="{{ token }}" />
|
|
141
|
-
<input type="submit" class="btn install-button" value="Install">
|
|
141
|
+
<input type="submit" class="btn install-button" value="Install" onclick="postMessage('installWhatsapp')">
|
|
142
|
+
<!--<input type="submit" class="btn install-button" value="Install" onclick="postMessage('installWhatsapp')">-->
|
|
142
143
|
</form>
|
|
143
144
|
</div>
|
|
144
145
|
</div>
|
|
@@ -213,6 +214,13 @@
|
|
|
213
214
|
|
|
214
215
|
<p style="font-size: 18px;"><b>What's new?</b></p>
|
|
215
216
|
|
|
217
|
+
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|
|
218
|
+
<div>
|
|
219
|
+
<p>Bug fixes and performance improvements</p>
|
|
220
|
+
</div>
|
|
221
|
+
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.52</b></p>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
216
224
|
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|
|
217
225
|
<div>
|
|
218
226
|
<p style="margin-bottom: 0px">Bug fixes</p>
|
|
@@ -238,14 +246,13 @@
|
|
|
238
246
|
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.48</b></p>
|
|
239
247
|
</div>
|
|
240
248
|
|
|
241
|
-
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|
|
242
|
-
<div>
|
|
243
|
-
<p style="margin-bottom: 0px">Bug fixes and minor improvements</p>
|
|
244
|
-
<!--<p>Bug fixes and performance improvements</p>-->
|
|
245
|
-
</div>
|
|
246
|
-
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.45</b></p>
|
|
247
|
-
</div>
|
|
248
|
-
|
|
249
249
|
<hr style="margin-top: 50px; margin-bottom: 20px">
|
|
250
|
+
|
|
251
|
+
<script>
|
|
252
|
+
function postMessage(action) {
|
|
253
|
+
const msg = { action: action, calledBy: 'whatsapp_proxy' }
|
|
254
|
+
window.parent.postMessage(msg, '*');
|
|
255
|
+
}
|
|
256
|
+
</script>
|
|
250
257
|
|
|
251
258
|
</body>
|
|
@@ -446,9 +446,17 @@ const path = require('path');
|
|
|
446
446
|
return data;
|
|
447
447
|
}
|
|
448
448
|
|
|
449
|
+
else if (whatsappChannelMessage.type == 'button') {
|
|
450
|
+
var tiledeskMessage = {
|
|
451
|
+
text: whatsappChannelMessage.button.text, // or whatsappChannelMessage.button.payload (?)
|
|
452
|
+
senderFullname: from,
|
|
453
|
+
channel: { name: TiledeskWhatsappTranslator.CHANNEL_NAME }
|
|
454
|
+
}
|
|
455
|
+
return tiledeskMessage;
|
|
456
|
+
}
|
|
449
457
|
|
|
450
458
|
// interactive message
|
|
451
|
-
if (whatsappChannelMessage.type == 'interactive') {
|
|
459
|
+
else if (whatsappChannelMessage.type == 'interactive') {
|
|
452
460
|
|
|
453
461
|
// list reply
|
|
454
462
|
if (whatsappChannelMessage.interactive.type == 'list_reply') {
|
|
@@ -506,7 +514,7 @@ const path = require('path');
|
|
|
506
514
|
}
|
|
507
515
|
|
|
508
516
|
// media message - image
|
|
509
|
-
if (whatsappChannelMessage.type == 'image') {
|
|
517
|
+
else if (whatsappChannelMessage.type == 'image') {
|
|
510
518
|
|
|
511
519
|
let text = "Image attached"
|
|
512
520
|
if (whatsappChannelMessage.image.caption) {
|
|
@@ -526,7 +534,7 @@ const path = require('path');
|
|
|
526
534
|
}
|
|
527
535
|
|
|
528
536
|
// media message - video
|
|
529
|
-
if (whatsappChannelMessage.type == 'video') {
|
|
537
|
+
else if (whatsappChannelMessage.type == 'video') {
|
|
530
538
|
|
|
531
539
|
let text = "Video attached"
|
|
532
540
|
if (whatsappChannelMessage.video.caption) {
|
|
@@ -548,7 +556,7 @@ const path = require('path');
|
|
|
548
556
|
}
|
|
549
557
|
|
|
550
558
|
// media message - document
|
|
551
|
-
if (whatsappChannelMessage.type == 'document') {
|
|
559
|
+
else if (whatsappChannelMessage.type == 'document') {
|
|
552
560
|
|
|
553
561
|
let text = "Document attached"
|
|
554
562
|
if (whatsappChannelMessage.document.caption) {
|
|
@@ -570,7 +578,7 @@ const path = require('path');
|
|
|
570
578
|
}
|
|
571
579
|
|
|
572
580
|
// media message - audio
|
|
573
|
-
if (whatsappChannelMessage.type == 'audio') {
|
|
581
|
+
else if (whatsappChannelMessage.type == 'audio') {
|
|
574
582
|
|
|
575
583
|
let text = "Audio attached"
|
|
576
584
|
/*if (whatsappChannelMessage.document.caption) {
|
|
@@ -590,6 +598,11 @@ const path = require('path');
|
|
|
590
598
|
}
|
|
591
599
|
return tiledeskMessage;
|
|
592
600
|
}
|
|
601
|
+
|
|
602
|
+
else {
|
|
603
|
+
winston.verbose("(wab) [Translator] unsupported whatsapp messsage type");
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
593
606
|
}
|
|
594
607
|
|
|
595
608
|
async fillParams(params, rcv_option) {
|