Search code examples
pythonapiserverwebhookswhatsapp

Python: WhatsApp Cloud API webhook


I have a WhatsApp business account with a number linked to it. I want some way to receive messages using python from it. I couldn't find a solution that doesn't require online hosting(heroku, glitch, twilio ect.).


Solution

  • Whatsapp cloud API will request you a webhook to post the messages received on the number you linked to the business account.

    You can expose a webhook listener selfhosted without the need to use a hosting provider. For obvious reasons, you should consider hosting it when you move your development into production.

    I would recommend using ngrok or a cloudflare tunnel (both are free) during development.

    Here's an example of each, the use-case is testing a webhook:

    NGROK: https://www.youtube.com/watch?v=7FHbfo-wRtY

    Cloudflare tunnels: https://www.youtube.com/watch?v=mMyoH4-mOiA