@tiledesk/tiledesk-whatsapp-connector 0.1.17 → 0.1.19
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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const express = require("express");
|
|
3
|
-
const app = express();
|
|
4
3
|
const router = express.Router();
|
|
5
4
|
const bodyParser = require("body-parser");
|
|
6
5
|
const appRoot = require('app-root-path');
|
|
@@ -174,7 +173,7 @@ router.get('/configure', async (req, res) => {
|
|
|
174
173
|
let token = "";
|
|
175
174
|
|
|
176
175
|
projectId = req.query.project_id;
|
|
177
|
-
token = req.query.token
|
|
176
|
+
token = req.query.token;
|
|
178
177
|
|
|
179
178
|
let CONTENT_KEY = "whatsapp-" + projectId;
|
|
180
179
|
|
|
@@ -650,13 +649,22 @@ router.get("/webhook/:project_id", async (req, res) => {
|
|
|
650
649
|
* UPDATE YOUR VERIFY TOKEN
|
|
651
650
|
*This will be the Verify Token value when you set up webhook
|
|
652
651
|
**/
|
|
652
|
+
console.log("\nVerify the webhook: ", req);
|
|
653
|
+
console.log("\req.query: ", req.query);
|
|
653
654
|
|
|
654
655
|
// Parse params from the webhook verification request
|
|
655
656
|
let mode = req.query["hub.mode"];
|
|
656
657
|
let token = req.query["hub.verify_token"];
|
|
657
658
|
let challenge = req.query["hub.challenge"];
|
|
659
|
+
|
|
660
|
+
console.log("**********")
|
|
661
|
+
console.log("mode: ", mode)
|
|
662
|
+
console.log("token: ", token)
|
|
663
|
+
console.log("challenge: ", challenge)
|
|
664
|
+
console.log("**********")
|
|
658
665
|
|
|
659
666
|
let CONTENT_KEY = "whatsapp-" + req.params.project_id;
|
|
667
|
+
console.log("\CONTENT_KEY: ", CONTENT_KEY);
|
|
660
668
|
|
|
661
669
|
let settings = await db.get(CONTENT_KEY);
|
|
662
670
|
|
|
@@ -666,17 +674,25 @@ router.get("/webhook/:project_id", async (req, res) => {
|
|
|
666
674
|
} else {
|
|
667
675
|
let VERIFY_TOKEN = settings.verify_token;
|
|
668
676
|
|
|
677
|
+
console.log("token: ", token);
|
|
678
|
+
console.log("verify token: ", VERIFY_TOKEN);
|
|
679
|
+
|
|
669
680
|
// Check if a token and mode were sent
|
|
670
681
|
if (mode && token) {
|
|
671
682
|
// Check the mode and token sent are correct
|
|
672
683
|
if (mode === "subscribe" && token === VERIFY_TOKEN) {
|
|
684
|
+
|
|
673
685
|
// Respond with 200 OK and challenge token from the request
|
|
674
686
|
console.log("WEBHOOK_VERIFIED");
|
|
675
687
|
res.status(200).send(challenge);
|
|
676
688
|
} else {
|
|
677
689
|
// Responds with '403 Forbidden' if verify tokens do not match
|
|
690
|
+
console.error("mode is not 'subscribe' or token do not match");
|
|
678
691
|
res.sendStatus(403);
|
|
679
692
|
}
|
|
693
|
+
} else {
|
|
694
|
+
console.error("mode or token undefined");
|
|
695
|
+
res.status(400).send("impossible to verify the webhook: mode or token undefined.")
|
|
680
696
|
}
|
|
681
697
|
|
|
682
698
|
}
|
package/package.json
CHANGED
package/template/detail.html
CHANGED
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
<div>
|
|
161
|
-
<h7>Receive Whatsapp
|
|
161
|
+
<h7>Receive Whatsapp conversations in your Tiledesk dashboard. Seamlessly Chat with your targeted audience on Whatsapp right from the Tiledesk dashboard.</h7>
|
|
162
162
|
|
|
163
163
|
<ul style="margin-top: 10px; padding: 0px;">
|
|
164
164
|
<div class="list-element">
|
|
@@ -213,29 +213,29 @@
|
|
|
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:
|
|
216
|
+
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|
|
217
217
|
<div>
|
|
218
218
|
<p style="margin-bottom: 0px;">New User Interface!</p>
|
|
219
219
|
<p style="margin-bottom: 0px">Added support for tdImage</p>
|
|
220
220
|
<p style="margin-bottom: 0px">Bug Fixes</p>
|
|
221
221
|
<!--<p>Bug fixes and performance improvements</p>-->
|
|
222
222
|
</div>
|
|
223
|
-
<p style="font-size: 12px; color: #676767">Version <b>0.1.
|
|
223
|
+
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.18</b></p>
|
|
224
224
|
</div>
|
|
225
225
|
|
|
226
|
-
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom:
|
|
226
|
+
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|
|
227
227
|
<div>
|
|
228
228
|
<p style="margin-bottom: 0px;">Graphics improvements</p>
|
|
229
229
|
</div>
|
|
230
|
-
<p style="font-size: 12px; color: #676767">Version <b>0.1.16</b></p>
|
|
230
|
+
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.16</b></p>
|
|
231
231
|
</div>
|
|
232
232
|
|
|
233
|
-
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom:
|
|
233
|
+
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|
|
234
234
|
<div>
|
|
235
235
|
<p style="margin-bottom: 0px;">Add support for pdf from Tiledesk</p>
|
|
236
236
|
<p>Bug fixes</p>
|
|
237
237
|
</div>
|
|
238
|
-
<p style="font-size: 12px; color: #676767">Version <b>0.1.14</b></p>
|
|
238
|
+
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.14</b></p>
|
|
239
239
|
</div>
|
|
240
240
|
|
|
241
241
|
<!--
|
|
@@ -275,19 +275,6 @@
|
|
|
275
275
|
|
|
276
276
|
<hr style="margin-top: 50px; margin-bottom: 20px">
|
|
277
277
|
|
|
278
|
-
<p>ciao</p>
|
|
279
|
-
|
|
280
|
-
<div class="tooltip">Hover over me
|
|
281
|
-
<span class="tooltiptext">Tooltip text</span>
|
|
282
|
-
</div>
|
|
283
|
-
|
|
284
|
-
<i class="fa fa-question-circle tooltip">
|
|
285
|
-
<span class="tooltiptext">This is a verification token chosen by you. Copy it to the Facebook Developer console in "Verify Token" in Whatsapp Configuration.</span>
|
|
286
|
-
</i>
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
</div>
|
|
290
|
-
|
|
291
278
|
<!--
|
|
292
279
|
<script>
|
|
293
280
|
function getParent() {
|
|
@@ -8,7 +8,6 @@ class TiledeskSubscriptionClient {
|
|
|
8
8
|
* @example
|
|
9
9
|
* const { TiledeskSubscriptionClient } = require('tiledesk-subscription-client');
|
|
10
10
|
* const tdClient = new TiledeskSubscriptionClient({API_URL: tiledeskApiUrl, token: jwt_token, log: log});
|
|
11
|
-
*
|
|
12
11
|
* @param {Object} config JSON configuration.
|
|
13
12
|
* @param {string} config.API_URL Mandatory. The Tiledesk api url.
|
|
14
13
|
* @param {string} config.token Optional. Token required for authentication.
|
|
@@ -73,17 +73,17 @@ const path = require('path');
|
|
|
73
73
|
if ((tiledeskChannelMessage.metadata.type && tiledeskChannelMessage.metadata.type.startsWith('image')) || tiledeskChannelMessage.type.startsWith('image')) {
|
|
74
74
|
|
|
75
75
|
var imgUrl = tiledeskChannelMessage.metadata.src;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
whatsapp_message.type = 'image'
|
|
77
|
+
whatsapp_message.image = {
|
|
78
|
+
link: imgUrl,
|
|
79
|
+
caption: text
|
|
80
|
+
}
|
|
81
|
+
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
85
84
|
|
|
86
|
-
|
|
85
|
+
|
|
86
|
+
else if ((tiledeskChannelMessage.metadata.type && tiledeskChannelMessage.metadata.type.startsWith('video')) || tiledeskChannelMessage.type.startsWith('video')) {
|
|
87
87
|
//if (tiledeskChannelMessage.metadata.type.startsWith('video/')) {
|
|
88
88
|
var videoUrl = tiledeskChannelMessage.metadata.src;
|
|
89
89
|
whatsapp_message.type = 'video'
|
|
Binary file
|
|
Binary file
|