A Plug that handles incoming WhatsApp webhook requests.
This Plug handles two types of requests:
GET - Meta's webhook verification challenge. Compares the
hub.verify_tokenquery parameter against the configured verify token and returns thehub.challengevalue.POST - Incoming webhook events. Verifies the
x-hub-signature-256header, parses the payload, and dispatches events to the configured handler.
Usage
In a Phoenix router:
forward "/webhook/whatsapp", Anu.Webhook.Plug, handler: MyApp.WhatsAppHandlerIn a plain Plug router:
forward "/webhook/whatsapp", to: Anu.Webhook.Plug, init_opts: [handler: MyApp.WhatsAppHandler]Options
:handler(required) - a module implementingAnu.Webhook.Handler:secret- app secret for signature verification; falls back toAnu.Config.app_secret/0:verify_token- token for the GET verification challenge; falls back toAnu.Config.verify_token/0
Multi-app setups (several WABAs in one node) can mount one forward per
app, each with its own :secret and :verify_token.