rubensk

Whatsapp Webhook

Sep 2nd, 2025
150
0
Never
11
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. /*
  2. * Starter Project for WhatsApp Echo Bot Tutorial
  3. *
  4. * Remix this as the starting point for following the WhatsApp Echo Bot tutorial
  5. *
  6. */
  7.  
  8. "use strict";
  9.  
  10. // Access token for your app
  11. // (copy token from DevX getting started page
  12. // and save it as environment variable into the .env file)
  13. const token = process.env.WHATSAPP_TOKEN;
  14.  
  15. // Imports dependencies and set up http server
  16. const request = require("request"),
  17. express = require("express"),
  18. body_parser = require("body-parser"),
  19. axios = require("axios").default,
  20. app = express().use(body_parser.json()); // creates express http server
  21.  
  22. // Sets server port and logs message on success
  23. app.listen(process.env.PORT || 1337, () => console.log("webhook is listening"));
  24.  
  25. // Accepts POST requests at /webhook endpoint
  26. app.post("/webhook", (req, res) => {
  27. // Parse the request body from the POST
  28. let body = req.body;
  29.  
  30. // Check the Incoming webhook message
  31. console.log(JSON.stringify(req.body, null, 2));
  32.  
  33. // info on WhatsApp text message payload: https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/payload-examples#text-messages
  34. if (req.body.object) {
  35. if (
  36. req.body.entry &&
  37. req.body.entry[0].changes &&
  38. req.body.entry[0].changes[0] &&
  39. req.body.entry[0].changes[0].value.messages &&
  40. req.body.entry[0].changes[0].value.messages[0]
  41. ) {
  42. let phone_number_id =
  43. req.body.entry[0].changes[0].value.metadata.phone_number_id;
  44. let from = req.body.entry[0].changes[0].value.messages[0].from; // extract the phone number from the webhook payload
  45. let msg_body = req.body.entry[0].changes[0].value.messages[0].text.body; // extract the message text from the webhook payload
  46. axios({
  47. method: "POST", // Required, HTTP method, a string, e.g. POST, GET
  48. url:
  49. "https://graph.facebook.com/v12.0/" +
  50. phone_number_id +
  51. "/messages?access_token=" +
  52. token,
  53. data: {
  54. messaging_product: "whatsapp",
  55. to: from,
  56. text: { body: "Este WhatsApp é usado apenas para enviar mensagens. Para entrar em contato, verifique os canais em https://registro.br/contato " },
  57. },
  58. headers: { "Content-Type": "application/json" },
  59. });
  60. }
  61. res.sendStatus(200);
  62. } else {
  63. // Return a '404 Not Found' if event is not from a WhatsApp API
  64. res.sendStatus(404);
  65. }
  66. });
  67.  
  68. // Accepts GET requests at the /webhook endpoint. You need this URL to setup webhook initially.
  69. // info on verification request payload: https://developers.facebook.com/docs/graph-api/webhooks/getting-started#verification-requests
  70. app.get("/webhook", (req, res) => {
  71. /**
  72. * UPDATE YOUR VERIFY TOKEN
  73. *This will be the Verify Token value when you set up webhook
  74. **/
  75. const verify_token = process.env.VERIFY_TOKEN;
  76.  
  77. // Parse params from the webhook verification request
  78. let mode = req.query["hub.mode"];
  79. let token = req.query["hub.verify_token"];
  80. let challenge = req.query["hub.challenge"];
  81.  
  82. // Check if a token and mode were sent
  83. if (mode && token) {
  84. // Check the mode and token sent are correct
  85. if (mode === "subscribe" && token === verify_token) {
  86. // Respond with 200 OK and challenge token from the request
  87. console.log("WEBHOOK_VERIFIED");
  88. res.status(200).send(challenge);
  89. } else {
  90. // Responds with '403 Forbidden' if verify tokens do not match
  91. res.sendStatus(403);
  92. }
  93. }
  94. });
  95.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Fenrimwo
    28 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Ectorki
    25 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Hakonew
    10 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=nusghmkvhd
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment