How to integrate WhatsApp Business into your Laravel system

· Laravel · 1 min read

Connecting WhatsApp to your own system is easier than it looks if you separate three things: sending, receiving and the channel’s rules.

1. Receiving with webhooks

The platform notifies a URL of yours when a message arrives or the status of a sent one changes. In Laravel it is best for that route to validate the request signature, answer fast and leave the real work to a queued job.

2. Sending with queues

Never send messages inside the user’s request. Put the sending in a queue, record the status and retry with increasing waits if the provider fails.

3. The channel’s rules

  • To start a conversation outside the 24-hour support window you use approved templates.
  • Inside that window you can reply with free-form messages.
  • The statuses (sent, delivered, read) arrive by webhook and have to be stored.

4. What usually goes wrong

  • Not storing the message identifier the provider gives you, and later being unable to match the statuses.
  • Sending without controlling the pace and having the provider limit the account.
  • Mixing the channel’s logic with the business logic.

With that you end up with a separate messaging service that the rest of the system uses without knowing the provider’s details.

Do you need to integrate WhatsApp into your system? Let’s talk.