Download the PHP package missael-anda/laravel-whatsapp without Composer
On this page you can find all versions of the php package missael-anda/laravel-whatsapp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-whatsapp
Whatsapp Business Cloud API for Laravel
A Laravel package for the Whatsapp Business Cloud API.
- Installation
- Configuration
- Usage
- Media
- Business profile
- Notification Channel
- License
Installation
Configuration
You will need to set the WHATSAPP_TOKEN
and WHATSAPP_NUMBER_ID
values in your .env.
For further configuration, please see config/whatsapp.php. You can modify the configuration
by copying it to your local config
directory or by defining the environment variables used in the config file:
Usage
You can send a messages to a single or multiple clients.
You can also respond to other messages in the conversation with any message type (except reaction message):
and you can mark messages as read:
By default the messages will be sent from the default_number_id
, if you want to use other you can use Whatsapp::numberId()
or add the alias to the config's numbers
list and use Whatsapp::numberName()
.
Also you can set the token manually with Whatsapp::token()
or you can set both the token and numberId you can use Whatsapp::client()
Supported messages
- [x] Text Message
- [x] Media Message
- [x] Template Message
- [x] Reaction Message
- [ ] Contacts Message
- [ ] Interactive Message
- [ ] Location Message
Media
You can also manage media with:
Business Profile
There are also two ways to manage the number's business profile:
Webhooks
Whatsapp allows you to subscribe to webhooks to receive notifications and most importantly messages from your customers. Both subscriptions and notifications are handled out of the box in the route whatsapp/webhook (you can change the path with the WHATSAPP_WEBHOOK_PATH env variable).
When a you register the webhook meta will send a subscription, this requires a verification token that you set, you will need to set it with WHATSAPP_WEBHOOK_VERIFY_TOKEN env setting.
When receiving a subscription intent a MissaelAnda\Whatsapp\Events\SubscriptionIntentReceived
event will be fired, if the request is successful the MissaelAnda\Whatsapp\Events\SuccessfullySubscribed
event will fire too.
On the other hand notifications will trigger a MissaelAnda\Whatsapp\Events\WebhookReceived
event with all the payload, if you want to protect this route verifying the sha256 signature you must set the WHATSAPP_WEBHOOK_SIGNATURE_VERIFY to true and the WHATSAPP_SECRET to your whatsapp's app secret.
If the payload is invalid a MissaelAnda\Whatsapp\Events\UnprocessableWebhookPayload
event will be fired with the exception describing the error.
If you want to know when a specific notification is fired you can subscribe to this events:
MissaelAnda\Whatsapp\Events\WebhookEntry
generic entryMissaelAnda\Whatsapp\Events\MessagesReceived
for themessages
entry
Notification Channel
This library has support for channel notification, just add the routeNotificationForWhatsapp()
function to the Notifiable user (it can return a single whatsapp_id or an array of them):
Now just create a notification that implements the toWhatsapp()
function:
Now you can send whatsapp notifications:
Configuration file
Missing features
- Register/deregister/validate new phone numbers
License
This project is licensed under the MIT License.
All versions of laravel-whatsapp with dependencies
illuminate/contracts Version ^9.0 || ^10.0 || ^11.0
illuminate/support Version ^9.0 || ^10.0 || ^11.0
illuminate/http Version ^9.0 || ^10.0 || ^11.0
illuminate/routing Version ^9.0 || ^10.0 || ^11.0
illuminate/events Version ^9.0 || ^10.0 || ^11.0