@tiledesk/tiledesk-whatsapp-connector 0.1.32 → 0.1.33
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 +9 -5
- package/package.json +1 -1
- package/tiledesk/TiledeskBotTester.js +2 -2
package/index.js
CHANGED
|
@@ -510,7 +510,7 @@ router.post('/tiledesk', async (req, res) => {
|
|
|
510
510
|
execute(commands[0]);
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
-
else if (tiledeskChannelMessage.text) {
|
|
513
|
+
else if (tiledeskChannelMessage.text || tiledeskChannelMessage.metadata) {
|
|
514
514
|
|
|
515
515
|
let whatsappJsonMessage = await tlr.toWhatsapp(tiledeskChannelMessage, whatsapp_receiver);
|
|
516
516
|
console.log("🟢 whatsappJsonMessage", JSON.stringify(whatsappJsonMessage))
|
|
@@ -580,11 +580,15 @@ router.post("/webhook/:project_id", async (req, res) => {
|
|
|
580
580
|
// Initialize conversation with chatbot
|
|
581
581
|
if (whatsappChannelMessage.text && whatsappChannelMessage.text.body.startsWith("#td")) {
|
|
582
582
|
|
|
583
|
+
console.log("\nwhatsappChannelMessage.text.body: ", whatsappChannelMessage.text.body)
|
|
584
|
+
let code = whatsappChannelMessage.text.body.split(' ')[0];
|
|
585
|
+
console.log("code: ", code)
|
|
586
|
+
|
|
583
587
|
const bottester = new TiledeskBotTester({project_id: projectId, redis_client: redis_client, db: db, tdChannel: tdChannel, tlr: tlr});
|
|
584
|
-
bottester.startBotConversation(req.body).then((result) => {
|
|
585
|
-
|
|
588
|
+
bottester.startBotConversation(req.body, code).then((result) => {
|
|
589
|
+
console.log("(whatsapp) startBotConversation result: ", result);
|
|
586
590
|
}).catch((err) => {
|
|
587
|
-
|
|
591
|
+
console.log("(whatsapp) startBotConversation result: ", err);
|
|
588
592
|
})
|
|
589
593
|
|
|
590
594
|
// Standard message
|
|
@@ -699,7 +703,7 @@ router.get("/webhook/:project_id", async (req, res) => {
|
|
|
699
703
|
*This will be the Verify Token value when you set up webhook
|
|
700
704
|
**/
|
|
701
705
|
console.log("\n(whatsapp) Verify the webhook... ");
|
|
702
|
-
console.log("
|
|
706
|
+
console.log("(whatsapp) req.query: ", req.query);
|
|
703
707
|
|
|
704
708
|
// Parse params from the webhook verification request
|
|
705
709
|
let mode = req.query["hub.mode"];
|
package/package.json
CHANGED
|
@@ -47,7 +47,7 @@ class TiledeskBotTester {
|
|
|
47
47
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
async startBotConversation(body) {
|
|
50
|
+
async startBotConversation(body, code) {
|
|
51
51
|
|
|
52
52
|
return new Promise( async (resolve, reject) => {
|
|
53
53
|
console.log("\n/startBotConversation()");
|
|
@@ -61,7 +61,7 @@ class TiledeskBotTester {
|
|
|
61
61
|
|
|
62
62
|
let whatsappContact = body.entry[0].changes[0].value.contacts[0];
|
|
63
63
|
|
|
64
|
-
let key = "bottest:" +
|
|
64
|
+
let key = "bottest:" + code.substring(3);
|
|
65
65
|
console.log("(testitout) key: ", key);
|
|
66
66
|
|
|
67
67
|
let test_info;
|