@tiledesk/tiledesk-whatsapp-connector 0.1.47 → 0.1.48
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 +22 -14
- package/package.json +1 -1
- package/template/detail.html +1 -1
package/index.js
CHANGED
|
@@ -434,7 +434,7 @@ router.get('/direct/tiledesk', async (req, res) => {
|
|
|
434
434
|
text: "Ciao, benvenuto sull'ambiente di sviluppo di Tiledesk! Questo messaggio serve ad aprire una nuova conversazione. Ha funzionato?"
|
|
435
435
|
}
|
|
436
436
|
*/
|
|
437
|
-
|
|
437
|
+
|
|
438
438
|
let tiledeskChannelMessage = {
|
|
439
439
|
text: "Sample text",
|
|
440
440
|
attributes: {
|
|
@@ -457,15 +457,15 @@ router.get('/direct/tiledesk', async (req, res) => {
|
|
|
457
457
|
winston.verbose("(wab) Message sent to WhatsApp! " + response.status + " " + response.statusText);
|
|
458
458
|
}).catch((err) => {
|
|
459
459
|
winston.error("(wab) error send message: ", err);
|
|
460
|
-
return res.status(400).send({success: false, error: err});
|
|
460
|
+
return res.status(400).send({ success: false, error: err });
|
|
461
461
|
})
|
|
462
462
|
|
|
463
463
|
res.status(200).send("Message sent");
|
|
464
|
-
|
|
464
|
+
|
|
465
465
|
})
|
|
466
466
|
|
|
467
467
|
router.post('/tiledesk', async (req, res) => {
|
|
468
|
-
|
|
468
|
+
|
|
469
469
|
winston.verbose("(wab) Message received from Tiledesk")
|
|
470
470
|
|
|
471
471
|
var tiledeskChannelMessage = req.body.payload;
|
|
@@ -552,7 +552,7 @@ router.post('/tiledesk', async (req, res) => {
|
|
|
552
552
|
const messageHandler = new MessageHandler({ tiledeskChannelMessage: tiledeskChannelMessage });
|
|
553
553
|
const tlr = new TiledeskWhatsappTranslator();
|
|
554
554
|
|
|
555
|
-
|
|
555
|
+
|
|
556
556
|
if (commands) {
|
|
557
557
|
let i = 0;
|
|
558
558
|
async function execute(command) {
|
|
@@ -609,12 +609,12 @@ router.post('/tiledesk', async (req, res) => {
|
|
|
609
609
|
twClient.sendMessage(phone_number_id, whatsappJsonMessage).then((response) => {
|
|
610
610
|
winston.verbose("(wab) Message sent to WhatsApp! " + response.status + " " + response.statusText);
|
|
611
611
|
}).catch((err) => {
|
|
612
|
-
res.status(400).send({success: false, error: "il template non esiste"});
|
|
612
|
+
res.status(400).send({ success: false, error: "il template non esiste" });
|
|
613
613
|
winston.error("(wab) error send message: ", err);
|
|
614
614
|
})
|
|
615
615
|
|
|
616
616
|
} else {
|
|
617
|
-
res.status(400).send({success: false, error: "il template non esiste"});
|
|
617
|
+
res.status(400).send({ success: false, error: "il template non esiste" });
|
|
618
618
|
winston.error("(wab) Whatsapp Json Message is undefined!")
|
|
619
619
|
}
|
|
620
620
|
|
|
@@ -942,7 +942,7 @@ router.get("/templates/:project_id", async (req, res) => {
|
|
|
942
942
|
let tm = new TemplateManager({ token: settings.wab_token, business_account_id: settings.business_account_id, GRAPH_URL: GRAPH_URL })
|
|
943
943
|
let templates = await tm.getTemplates();
|
|
944
944
|
|
|
945
|
-
|
|
945
|
+
|
|
946
946
|
|
|
947
947
|
readHTMLFile('/templates.html', (err, html) => {
|
|
948
948
|
var template = handlebars.compile(html);
|
|
@@ -972,17 +972,25 @@ router.get("/ext/templates/:project_id", async (req, res) => {
|
|
|
972
972
|
let settings = await db.get(CONTENT_KEY);
|
|
973
973
|
|
|
974
974
|
if (settings) {
|
|
975
|
-
let tm = new TemplateManager({ token: settings.wab_token, business_account_id: settings.business_account_id, GRAPH_URL: GRAPH_URL })
|
|
976
|
-
let templates = await tm.getTemplates();
|
|
977
975
|
|
|
978
|
-
if (
|
|
979
|
-
|
|
976
|
+
if (settings.business_account_id) {
|
|
977
|
+
let tm = new TemplateManager({ token: settings.wab_token, business_account_id: settings.business_account_id, GRAPH_URL: GRAPH_URL })
|
|
978
|
+
let templates = await tm.getTemplates();
|
|
979
|
+
|
|
980
|
+
winston.info("(wab) ext templates: ", templates);
|
|
981
|
+
|
|
982
|
+
if (templates) {
|
|
983
|
+
res.status(200).send(templates.data);
|
|
984
|
+
} else {
|
|
985
|
+
res.status(500).send({ success: false, code: '02', message: "A problem occurred while getting templates from WhatsApp" })
|
|
986
|
+
}
|
|
987
|
+
|
|
980
988
|
} else {
|
|
981
|
-
res.status(500).send({ success: false, code: '
|
|
989
|
+
res.status(500).send({ success: false, code: '03', message: "Missing parameter 'WhatsApp Business Account ID'. Please update your app."})
|
|
982
990
|
}
|
|
983
991
|
|
|
984
992
|
} else {
|
|
985
|
-
res.status(400).send({ success: false, code: '01', message: "
|
|
993
|
+
res.status(400).send({ success: false, code: '01', message: "WhatsApp not installed for the project_id " + project_id })
|
|
986
994
|
}
|
|
987
995
|
|
|
988
996
|
})
|
package/package.json
CHANGED
package/template/detail.html
CHANGED
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
<p style="margin-bottom: 0px">Added support for WhatsApp templates</p>
|
|
219
219
|
<!--<p>Bug fixes and performance improvements</p>-->
|
|
220
220
|
</div>
|
|
221
|
-
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.
|
|
221
|
+
<p style="font-size: 12px; color: #676767; margin-bottom: 0px;">Version <b>0.1.48</b></p>
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div style="width: 100%; display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 15px;">
|