{"id":22085587,"url":"https://github.com/nexmo/laravel-notification","last_synced_at":"2025-07-24T17:31:24.097Z","repository":{"id":53014862,"uuid":"159178908","full_name":"Nexmo/laravel-notification","owner":"Nexmo","description":"Example package for using the (still under development) Messages API from Nexmo as a notification channel in Laravel","archived":false,"fork":false,"pushed_at":"2021-02-02T13:32:40.000Z","size":9,"stargazers_count":51,"open_issues_count":1,"forks_count":9,"subscribers_count":19,"default_branch":"main","last_synced_at":"2024-11-20T09:13:46.253Z","etag":null,"topics":["beta","developer-destination","laravel","nexmo","notifications","php","vonage"],"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/Nexmo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-26T14:03:45.000Z","updated_at":"2023-11-12T02:28:11.000Z","dependencies_parsed_at":"2022-08-23T16:11:06.779Z","dependency_job_id":null,"html_url":"https://github.com/Nexmo/laravel-notification","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Flaravel-notification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Flaravel-notification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Flaravel-notification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Flaravel-notification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nexmo","download_url":"https://codeload.github.com/Nexmo/laravel-notification/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227463798,"owners_count":17778465,"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":["beta","developer-destination","laravel","nexmo","notifications","php","vonage"],"created_at":"2024-12-01T01:15:09.964Z","updated_at":"2024-12-01T01:15:10.807Z","avatar_url":"https://github.com/Nexmo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nexmo / Laravel Notifications\n\n\u003cimg src=\"https://developer.nexmo.com/assets/images/Vonage_Nexmo.svg\" height=\"48px\" alt=\"Nexmo is now known as Vonage\" /\u003e\n\nAlthough Nexmo is [available in Laravel](https://laravel.com/docs/5.8/notifications#sms-notifications) as the default SMS provider, the next generation of Nexmo APIs will offer more communication channels. This package adds the ability to send notifications to WhatsApp, Facebook Messenger and Viber via Nexmo.\n\n*Note that the [Messages API](https://developer.nexmo.com/messages/overview) that this package uses has not yet had its stable release so both the API and this library are subject to change*\n\n## Usage\n\nTo use this package, run `composer require nexmo/laravel-notification`. Once it completes, you can implement the following methods on your notification:\n\n* `toNexmoWhatsApp`\n* `toNexmoFacebook`\n* `toNexmoViberServiceMessage`\n* `toNexmoSms`\n\nSee [examples/Notification/MerryChristmas.php](examples/Notification/MerryChristmas.php) for a complete example.\n\nTo send a notification, specify the channel you'd like to use:\n\n```php\n// To a user\n$user-\u003enotify(new \\App\\Notifications\\MerryChristmas());\n\n// To any person\nNotification::route(\n    'nexmo-whatsapp',\n    'YOUR_NUMBER'\n)-\u003enotify(new \\App\\Notifications\\MerryChristmas());\n```\n\nThe available channels are:\n\n* `nexmo-sms`\n* `nexmo-whatsapp`\n* `nexmo-facebook`\n* `nexmo-viber_service_msg`\n\nAs each notification receives a `$notifiable` (usually a user) it can decide how best to route the information. In this case, it checks the `via_whatsapp` property on the user and sends via WhatsApp if it's true. Otherwise it falls back to email\n\n```\npublic function via($notifiable)\n{\n    return $notifiable-\u003evia_whatsapp ? ['nexmo-whatsapp'] : ['mail'];\n}\n```\n\n### Message Types\n\nNexmo supports multiple message types, depending on the channel that you're sending to. The `Text` type is the safest if you want to deliver to all channels:\n\n```\npublic function toNexmoWhatsApp($notifiable)\n{\n    return (new \\Nexmo\\Notifications\\Message\\Text)\n        -\u003econtent('This is a message being sent to WhatsApp');\n}\n```\n\n### Caveats\n\nFor some channels you need to send a templated message before you can send a free text message due to spam control rules. Here's an example of how to use a preapproved template intended for two-factor authentication purposes:\n\n```\npublic function toNexmoWhatsApp($notifiable)\n{\n    return (new \\Nexmo\\Notifications\\Message\\Template)\n        -\u003ename(\"whatsapp:hsm:technology:nexmo:verify\")\n        -\u003eparameters([\n            [\"default\" =\u003e \"Your Brand\"],\n            [\"default\" =\u003e \"64873\"],\n            [\"default\" =\u003e \"10\"],\n        ]);\n}\n```\n\nIf the recipient replies to your message, you can send them `Text` type messages without any issues\n\n## Configuration\n\n### Authentication\n\nThis notifications package is built on top of [nexmo/laravel](https://github.com/Nexmo/nexmo-laravel) and uses the Nexmo client from there.\n\nFor this to work, you need to set your application ID and path to your private key in the `.env` file:\n\n```\nNEXMO_APPLICATION_ID=my_application_id\nNEXMO_PRIVATE_KEY=./private.key\n```\n\n### Setting the `from` address\n\nYou can set a `from `address via the `.env` file. This package will look for provider specific entries before falling back to `NEXMO_FROM`.\n\n```\nNEXMO_FROM_SMS=\"\"\nNEXMO_FROM_WHATSAPP=\"\"\nNEXMO_FROM_MESSENGER=\"\"\nNEXMO_FROM_VIBER_SERVICE_MSG=\"\"\nNEXMO_FROM=\"\" # This is the default if any of the above aren't set\n```\n\nAlternatively, you can set a `from` address for a single notification by calling the `-\u003efrom()` method on a message:\n\n```php\npublic function toNexmoViberServiceMessage($notifiable)\n{\n    return (new Text)-\u003econtent('Merry Christmas Viber!')-\u003efrom(\"YOUR_ID\");\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexmo%2Flaravel-notification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnexmo%2Flaravel-notification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexmo%2Flaravel-notification/lists"}