{"id":18390436,"url":"https://github.com/netflie/laravel-notification-whatsapp","last_synced_at":"2025-04-04T16:17:00.441Z","repository":{"id":64462042,"uuid":"576005059","full_name":"netflie/laravel-notification-whatsapp","owner":"netflie","description":"Laravel notification channel for Whatsapp Cloud API","archived":false,"fork":false,"pushed_at":"2024-09-01T21:10:20.000Z","size":59,"stargazers_count":134,"open_issues_count":6,"forks_count":35,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-13T01:36:42.643Z","etag":null,"topics":["laravel-notification-channel","laravel-whatsapp","php","sdk","whatsapp","whatsapp-api","whatsapp-business-api","whatsappcloudapi"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netflie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["aalbarca"]}},"created_at":"2022-12-08T19:42:31.000Z","updated_at":"2025-02-15T06:24:31.000Z","dependencies_parsed_at":"2023-02-19T11:00:55.876Z","dependency_job_id":"5be0b473-34dd-48f9-a860-8664ff9382af","html_url":"https://github.com/netflie/laravel-notification-whatsapp","commit_stats":{"total_commits":38,"total_committers":8,"mean_commits":4.75,"dds":"0.42105263157894735","last_synced_commit":"0cb435f203c97b5d19e5109e8a505983d7578d4a"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netflie%2Flaravel-notification-whatsapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netflie%2Flaravel-notification-whatsapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netflie%2Flaravel-notification-whatsapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netflie%2Flaravel-notification-whatsapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netflie","download_url":"https://codeload.github.com/netflie/laravel-notification-whatsapp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208190,"owners_count":20901570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel-notification-channel","laravel-whatsapp","php","sdk","whatsapp","whatsapp-api","whatsapp-business-api","whatsappcloudapi"],"created_at":"2024-11-06T01:47:46.071Z","updated_at":"2025-04-04T16:17:00.423Z","avatar_url":"https://github.com/netflie.png","language":"PHP","funding_links":["https://github.com/sponsors/aalbarca"],"categories":[],"sub_categories":[],"readme":"\n# WhatsApp notification channel for Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/netflie/laravel-notification-whatsapp.svg?style=flat-square)](https://packagist.org/packages/netflie/laravel-notification-whatsapp/)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/github/workflow/status/netflie/laravel-notification-whatsapp/Tests.svg?style=flat-square)](https://github.com/netflie/laravel-notification-whatsapp/actions)\n[![StyleCI](https://github.styleci.io/repos/576005059/shield)](hhttps://github.styleci.io/repos/576005059)\n[![Quality Score](https://img.shields.io/scrutinizer/g/netflie/laravel-notification-whatsapp.svg?style=flat-square)](https://scrutinizer-ci.com/g/netflie/laravel-notification-whatsapp)\n[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/netflie/laravel-notification-whatsapp/main.svg?style=flat-square)](https://scrutinizer-ci.com/g/netflie/laravel-notification-whatsapp?branch=main)\n[![Total Downloads](https://img.shields.io/packagist/dt/netflie/laravel-notification-whatsapp.svg?style=flat-square)](https://packagist.org/packages/netflie/laravel-notification-whatsapp/)\n\nThis package makes it easy to send notifications using [WhatsApp Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api/) with Laravel.\n\nThis 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.\n\n## Contents\n\n- [Installation](#installation)\n\t- [Setting up the WhatsApp service](#setting-up-the-WhatsApp-service)\n- [Usage](#usage)\n\t- [Available Message methods](#available-message-methods)\n- [Changelog](#changelog)\n- [Testing](#testing)\n- [Security](#security)\n- [Contributing](#contributing)\n- [Credits](#credits)\n- [License](#license)\n\n\n## Installation\n\nYou can install the package via composer:\n```\ncomposer require netflie/laravel-notification-whatsapp\n```\n### Setting up the WhatsApp Cloud API\n\nCreate 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:\n```php\n\u003c?php\n\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Third Party Services\n    |--------------------------------------------------------------------------\n    |\n    | This file is for storing the credentials for third party services such\n    | as Mailgun, Postmark, AWS and more. This file provides the de facto\n    | location for this type of information, allowing packages to have\n    | a conventional file to locate the various service credentials.\n    |\n    */\n\n    // Other third-party config...\n\n    'whatsapp' =\u003e [\n        'from-phone-number-id' =\u003e env('WHATSAPP_FROM_PHONE_NUMBER_ID'),\n        'token' =\u003e env('WHATSAPP_TOKEN'),\n    ],\n\n];\n```\n\n## Usage\n\nThe 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.\n\nWhatsapp 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).\n\n### WhatsApp templates sections\n\nA 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.\n\n### Components\n\nYou 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:\n\n```php\n\u003c?php\n\nuse NotificationChannels\\WhatsApp\\Component;\n\nComponent::currency($amount, $code = 'EUR');\nComponent::dateTime($dateTime, $format = 'Y-m-d H:i:s');\nComponent::document($link);\nComponent::image($link);\nComponent::video($link);\nComponent::text($text);\nComponent::urlButton($array_of_urls);\nComponent::quickReplyButton($array_of_payloads);\nComponent::flowButton($flow_token, $array_of_data);\n```\nComponents supported by Whatsapp template sections:\n\n - Header: image, video, document and text (the text accepts currency, datetime and text variables)\n - Body: currency, datetime and text\n - Buttons: url and quick reply, \n\n### Send a notification from a template\n\nTo use this package, you need to create a notification class, like `MovieTicketPaid` from the example below, in your Laravel application. Make sure to check out [Laravel's documentation](https://laravel.com/docs/master/notifications) for this process.\n\n```php\n\u003c?php\n\nnamespace App\\Notifications;\n\nuse Illuminate\\Notifications\\Notification;\nuse NotificationChannels\\WhatsApp\\Component;\nuse NotificationChannels\\WhatsApp\\WhatsAppChannel;\nuse NotificationChannels\\WhatsApp\\WhatsAppTemplate;\n\nclass MovieTicketPaid extends Notification\n{\n    /**\n     * Get the notification's delivery channels.\n     *\n     * @param  mixed  $notifiable\n     * @return array\n     */\n    public function via($notifiable)\n    {\n        return [WhatsAppChannel::class];\n    }\n\n    public function toWhatsapp($notifiable)\n    {\n        return WhatsAppTemplate::create()\n            -\u003ename('sample_movie_ticket_confirmation') // Name of your configured template\n            -\u003eheader(Component::image('https://lumiere-a.akamaihd.net/v1/images/image_c671e2ee.jpeg'))\n            -\u003ebody(Component::text('Star Wars'))\n            -\u003ebody(Component::dateTime(new \\DateTimeImmutable))\n            -\u003ebody(Component::text('Star Wars'))\n            -\u003ebody(Component::text('5'))\n            -\u003ebuttons(Component::quickReplyButton(['Thanks for your reply!']))\n            -\u003ebuttons(Component::urlButton(['reply/01234'])) // List of url suffixes\n            -\u003eto('34676010101');\n    }\n}\n```\n\n### Send a text message\n\nYou can only send a text message after you've send a template and the user responded.\n\n```php\n\u003c?php\n\nnamespace App\\Notifications;\n\nuse Illuminate\\Notifications\\Notification;\nuse NotificationChannels\\WhatsApp\\Component;\nuse NotificationChannels\\WhatsApp\\WhatsAppChannel;\nuse NotificationChannels\\WhatsApp\\WhatsAppTextMessage;\n\nclass MovieTicketPaid extends Notification\n{\n    /**\n     * Get the notification's delivery channels.\n     *\n     * @param  mixed  $notifiable\n     * @return array\n     */\n    public function via($notifiable)\n    {\n        return [WhatsAppChannel::class];\n    }\n\n    public function toWhatsapp($notifiable)\n    {\n        return WhatsAppTextMessage::create()\n            -\u003emessage('Hello, this is a test message')\n            -\u003eto('34676010101');\n    }\n}\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Security\n\nIf you discover any security related issues, please email hola@netflie.es instead of using the issue tracker.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Credits\n\n- [Álex Albarca](https://github.com/netflie)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetflie%2Flaravel-notification-whatsapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetflie%2Flaravel-notification-whatsapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetflie%2Flaravel-notification-whatsapp/lists"}