LogoLogo
Become a PartnerStatus Page
  • get started
    • Welcome to 360Dialog
    • Quickstarts
      • Register as a Meta Tech Provider
      • Add a WhatsApp Number
      • Set up Integrated Onboarding
      • Create a Message Template
      • Send a Message
      • (temp title) Getting started as a partner
    • Pricing & Billing
      • Payment Methods for BR: Pix & Boleto
      • Month Closing Invoice (MCI)
    • Get API Access
    • Tech Provider Program
      • Understanding the Meta Tech Provider Program
      • Becoming a Meta Tech Provider: A Step-by-Step Guide
  • MM Lite Beta Program
    • Onboarding
    • Sending Messages
    • Expected Errors & Programming Languages
    • MM Lite Sandbox Testing
      • Sending Messages using MM Lite Sandbox
      • Expected Erros & Programming Languages
  • Partner & Account Management
    • Solutions for Partners
      • Benefits for Partners
      • Partner Hub
      • WABA Management
    • Account Setup & Management
      • Prerequisites and best practices for account creation
      • Account Structure
      • Account Creation
  • Integrations & API Development
    • Webhook Events & Setup
      • Webhook Events (Partner & Messaging API)
      • Webhook Configuration & Management
    • Integration Best Practices
      • Architecture and Security
      • Best Practices for Designing Integrations
        • Design a Stable Webhook Receiving Endpoint
      • Sizing Your Environment Based on Expected Throughput
      • Design a Resilient Message Sending Service
      • Integrated Onboarding
        • Basic Integrated Onboarding
        • Custom Integrated Onboarding
        • Host Your Own Embedded Signup
      • API Key Authentication for the Partner API
  • API Reference
    • Messaging API
    • Messaging Health Status
    • Sandbox (Test API Key)
    • Differences Between Cloud API and On-Premise API for Partners
      • [will be deprecated] Messaging with On-Premise API
    • Partner API
  • WABA Management
    • Managing WABA Accounts
      • Using the Partner Hub to manage Clients and Channels
      • Using the Partner API to manage Clients and Channels
      • Partner Permission to Generate API Key
      • Checking Usage & Statistics
    • Phone Number & Hosting
      • Migrating a Phone Number
        • Migrate number from Meta or alternate BSP to 360Dialog
        • Migrate a phone number to a new WABA
        • Migrate a phone number to a new WABA to change messaging Currency
      • WhatsApp Coexistence
        • Coexistence Onboarding
        • Coexistence Webhooks
      • Hosting type Change (On-premise API to Cloud API)
    • WABA Profile & Compliance
      • Display Name Guidelines
      • WABA Profile Info
      • WABA Policy Enforcement
      • Business Account Verification
    • Partner change (between 360Dialog Partners)
    • WhatsApp Flows
    • Accelerated Onboarding
    • Business Account Verification
  • Messaging
    • Sending & Receiving Messages
      • Conversations
      • Receiving messages
      • Before sending a message
    • Message Types
      • Conversational Components
      • Checklist for Message Broadcasts and Campaigns
      • Text messages
      • Interactive messages
        • Single and Multi Product Messages
        • Location Request Messages
        • Address Messages (India and Singapore only)
      • Contacts & Location Messages
    • Template Messages
      • Template Library
      • Template Elements
      • Sending Template Messages
      • Authentication Templates
        • Zero-Tap Authentication Templates
        • One-Tap Autofill Authentication Templates
        • Copy Code Authentication Templates
      • Catalog Templates
      • Product Card Carousel Templates
      • Single-Product Message Templates
      • Coupon Code Templates
      • Limited-Time Offer Templates
      • Multi-Product Templates
    • Media Messages
      • Upload, retrieve or delete media
    • Messaging Health & Troubleshooting
      • Messaging Limits & Quality Rating
      • Errors While Messaging
      • Messages statuses
  • Commerce & Payments
    • Payments (India Only)
      • Receive WhatsApp Payments via Payments Gateway
      • Receive WhatsApp Payments via Payment Links
      • Order Details Template Message
    • Payments (Singapore Only)
      • Receive WhatsApp Payments via Stripe
    • Products and Catalogs
      • India Businesses: Compliance for Commerce
  • Support & Updates
    • Help & Troubleshooting
      • FAQ
      • Error Code Reference
      • User Support Documentation
        • Tutorials
          • Page How to Troubleshoot Login Issues in the 360dialog Hub
          • How to Report an Issue
          • How to Contact Support
        • How-To Guides
          • Raise a support request
          • Requesting a Status Update for Business Verification
        • Reference
          • Troubleshooting Embedded Signup Issues
          • Commerce Policy Checks for WhatsApp API Access
          • Support Availability & SLAs
          • Incident Issue Prioritization
          • Case Types Table
        • Explanation
          • Why Business Verification Takes Time
          • Why Some Issues Are Not Emergencies
          • Understanding the Support Process
      • Support with Meta
    • Imprint & Data Privacy
    • Product Updates & News
      • How to ensure your Template Messages will be received
      • Integrated Onboarding new look and Campaigns Best Practices
Powered by GitBook
On this page
  • WhatsApp Webhook Notifications
  • WhatsApp Web-hook Response Requirements
  • The risk of synchronously handling Webhook Notifications
  • Asynchronous Handling of Webhook Notifications

Was this helpful?

  1. Integrations & API Development
  2. Integration Best Practices
  3. Best Practices for Designing Integrations

Design a Stable Webhook Receiving Endpoint

Ensure your service quickly responds to Web-hook Notifications

PreviousBest Practices for Designing IntegrationsNextSizing Your Environment Based on Expected Throughput

Last updated 1 year ago

Was this helpful?

In order to send and receive messages using 360dialog's API, you will need to set up a server that handles Web-hook Notifications from WhatsApp.

A web-hook is a mechanism that enables communication between two different applications or systems in real-time. With a web-hook, an application can send a notification (usually in the form of an HTTP POST request) to another application whenever a particular event occurs. This allows for the automatic exchange of information between the two applications without the need for continuous polling or user intervention.

WhatsApp Webhook Notifications

The WhatsApp Business API Client sends Web-hook Notifications to the .

For further information, review our on receiving messages via webhook.

WhatsApp Web-hook Response Requirements

For a Webhook Notification to be considered by WhatsApp to be 'successfully delivered', the client must respond to the with a '200' status code.

If any other status code is returned, or if the client fails to correctly set up the endpoint to accept Notifications, the WhatsApp Business API Client considers it to be a 'failed delivery' and adds the Notification to its callback queue. 360dialog also has a hard limit rule of 5 seconds for the client to return a 200 status code, after which it will register as a failed delivery.

Important: We recommend designing your service to respond as quickly as possible, or as close to your network speed to avoid any issues. Furthermore, the service should be scalable, and capable of performing well under high load/messaging volume, as an increased latency may lead to your WABA number being disconnected.

For further advice on designing your service for scale,

Webhooks can be handled synchronously or asynchronously. We would recommend following the asynchronous approach for the reasons below.

The risk of synchronously handling Webhook Notifications

Designing a synchronous Webhook Notification handler typically involves these steps:

1) The Server receives the Webhook Notification.

2) The Server begins to process the Notification payload.

3) The Sever finishes processing the Notification payload.

4) The Server returns a 200 'status' response.

The problem with this design is that the response time is blocked by the processing time (step 2) , which may not be consistently achievable under higher loads, especially if step 2 is complex (such as making a complex SQL query, or a call to another API).

To solve this problem, it is advisable to decouple the storage of the webhook from the processing of the payload by implementing an asynchronous flow.

Asynchronous Handling of Webhook Notifications

Asynchronous refers to a computing process or communication method in which tasks or requests are executed independently and in a non-blocking manner, allowing the system to perform certain tasks simultaneously. In an asynchronous system, tasks or events can be initiated and run independently of one another, without having to wait for the previous task to complete before starting the next one.

An asynchronous approach for the Webhook Notification Handler may involve the following steps:

1) The Server receives Webhook Notification.

2) The Server adds the Notification payload to a message queue.

3) The Server returns a 200 status response.

4) (Asynchronously) The Server processes the stored Notification.

Because the payload processing is conducted in a non-blocking manner, the server can send the response to WhatsApp almost immediately after storing the payload. This guarantees a consistent response time, improving the stability of the WhatsApp number.

Pseudocode Example of an Asynchronous Webhook Notification Handler

When a request is received, the webhook_handler function will simply add the request to the message queue, and return a 200 status response.

from aiohttp import web
import message_queue

async def webhook_handler(request):
    message_queue.add(request.json)
    return web.Response(status=200)

app = web.Application()
app.add_routes([web.get('/webhook_handler', webhook_handler)])
web.run_app(app)

A separate, non-blocking component retrieves messages from the queue and processes them, without the pressure of any time limits.

import message_queue

async def process_payload(message):
    print("Processing payload...")
    # processing ...
    print("Payload processed: ", message)

def main():
    for message in message_queue.get():
        process_payload(message)
client-designated webhook URL
guide
designated endpoint
review our page on sizing your environment based on expected throughput.