https://github.com/netflie/laravel-notification-whatsapp
Laravel notification channel for Whatsapp Cloud API
https://github.com/netflie/laravel-notification-whatsapp
laravel-notification-channel laravel-whatsapp php sdk whatsapp whatsapp-api whatsapp-business-api whatsappcloudapi
Last synced: about 1 month ago
JSON representation
Laravel notification channel for Whatsapp Cloud API
- Host: GitHub
- URL: https://github.com/netflie/laravel-notification-whatsapp
- Owner: netflie
- License: mit
- Created: 2022-12-08T19:42:31.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-01T21:10:20.000Z (9 months ago)
- Last Synced: 2025-03-13T01:36:42.643Z (2 months ago)
- Topics: laravel-notification-channel, laravel-whatsapp, php, sdk, whatsapp, whatsapp-api, whatsapp-business-api, whatsappcloudapi
- Language: PHP
- Homepage:
- Size: 57.6 KB
- Stars: 134
- Watchers: 8
- Forks: 35
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# WhatsApp notification channel for Laravel
[](https://packagist.org/packages/netflie/laravel-notification-whatsapp/)
[](LICENSE.md)
[](https://github.com/netflie/laravel-notification-whatsapp/actions)
[](hhttps://github.styleci.io/repos/576005059)
[](https://scrutinizer-ci.com/g/netflie/laravel-notification-whatsapp)
[](https://scrutinizer-ci.com/g/netflie/laravel-notification-whatsapp?branch=main)
[](https://packagist.org/packages/netflie/laravel-notification-whatsapp/)This package makes it easy to send notifications using [WhatsApp Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api/) with Laravel.
This package uses the [whatsapp-cloud-api](https://github.com/netflie/whatsapp-cloud-api) library that will allow you to send messages via the WhatsApp Cloud API from any type of project and framework written in PHP.
## Contents
- [Installation](#installation)
- [Setting up the WhatsApp service](#setting-up-the-WhatsApp-service)
- [Usage](#usage)
- [Available Message methods](#available-message-methods)
- [Changelog](#changelog)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)## Installation
You can install the package via composer:
```
composer require netflie/laravel-notification-whatsapp
```
### Setting up the WhatsApp Cloud APICreate a new Meta application and get your Whatsapp `application token` and `phone number id` following the ["Get Started"](https://developers.facebook.com/docs/whatsapp/cloud-api/get-started?locale=en_US#set-up-developer-assets) guide. Place them inside your `.env` file. To load them, add this to your `config/services.php` file:
```php
[
'from-phone-number-id' => env('WHATSAPP_FROM_PHONE_NUMBER_ID'),
'token' => env('WHATSAPP_TOKEN'),
],];
```## Usage
The Whatsapp API only allows you to start conversations if you send a template message. This means that you will only be able to send template notifications from this package.
Whatsapp forces you to configure your templates before using them. You can learn how to configure your templates by following Meta's official guide on ["How to create templates"](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates).
### WhatsApp templates sections
A template is divided into 4 sections: header, body, footer and buttons. The header, body and buttons accept variables. The footer doesn't accept variables. You can only send variables from this package for the header and body.
### Components
You have available several components that can be used to add context (variables) to your templates. The different components can be created with the component factory:
```php
name('sample_movie_ticket_confirmation') // Name of your configured template
->header(Component::image('https://lumiere-a.akamaihd.net/v1/images/image_c671e2ee.jpeg'))
->body(Component::text('Star Wars'))
->body(Component::dateTime(new \DateTimeImmutable))
->body(Component::text('Star Wars'))
->body(Component::text('5'))
->buttons(Component::quickReplyButton(['Thanks for your reply!']))
->buttons(Component::urlButton(['reply/01234'])) // List of url suffixes
->to('34676010101');
}
}
```### Send a text message
You can only send a text message after you've send a template and the user responded.
```php
message('Hello, this is a test message')
->to('34676010101');
}
}
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Testing
``` bash
$ composer test
```## Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Credits
- [Álex Albarca](https://github.com/netflie)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.