{"id":26784148,"url":"https://github.com/craftsys/msg91-laravel-notification-channel","last_synced_at":"2025-09-14T07:06:40.697Z","repository":{"id":35171317,"uuid":"216613266","full_name":"craftsys/msg91-laravel-notification-channel","owner":"craftsys","description":"Laravel Notification Channel for Msg91 SMS apis","archived":false,"fork":false,"pushed_at":"2024-10-17T06:42:08.000Z","size":69,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-02T03:58:30.335Z","etag":null,"topics":["laravel","msg91","notification-cha","otp","php","sms"],"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/craftsys.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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}},"created_at":"2019-10-21T16:21:23.000Z","updated_at":"2024-10-17T06:42:11.000Z","dependencies_parsed_at":"2024-04-25T13:01:40.693Z","dependency_job_id":null,"html_url":"https://github.com/craftsys/msg91-laravel-notification-channel","commit_stats":{"total_commits":51,"total_committers":3,"mean_commits":17.0,"dds":0.6274509803921569,"last_synced_commit":"5a65c061fc28f7914d14f4aa93ee94464d188841"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/craftsys/msg91-laravel-notification-channel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftsys%2Fmsg91-laravel-notification-channel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftsys%2Fmsg91-laravel-notification-channel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftsys%2Fmsg91-laravel-notification-channel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftsys%2Fmsg91-laravel-notification-channel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/craftsys","download_url":"https://codeload.github.com/craftsys/msg91-laravel-notification-channel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftsys%2Fmsg91-laravel-notification-channel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275072251,"owners_count":25400569,"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","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","msg91","notification-cha","otp","php","sms"],"created_at":"2025-03-29T10:18:04.055Z","updated_at":"2025-09-14T07:06:40.674Z","avatar_url":"https://github.com/craftsys.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Notification Channels For Msg91 SMS Notifications\n\n\n\u003cp\u003e\n\u003ca href=\"https://packagist.org/packages/craftsys/msg91-laravel-notification-channel\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/craftsys/msg91-laravel-notification-channel\" alt=\"Total Downloads\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/craftsys/msg91-laravel-notification-channel\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/craftsys/msg91-laravel-notification-channel?label=version\" alt=\"Latest Stable Version\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/craftsys/msg91-laravel-notification-channel\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/craftsys/msg91-laravel-notification-channel\" alt=\"License\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/craftsys/msg91-laravel-notification-channel/actions/workflows/tests.yml\"\u003e\u003cimg src=\"https://github.com/craftsys/msg91-laravel-notification-channel/actions/workflows/tests.yml/badge.svg\" alt=\"Status\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\n\nLaravel notification channel for Msg91 API (wrapper around [Laravel Msg91 Client][client-laravel])\n\n## Table of Contents\n\n-   [Installation](#installation)\n-   [Configuration](#configuration)\n-   [Usage](#usage)\n    -   [SMS](#sms)\n    -   [OTP](#otp)\n    -   [Verify OTP](#verify-otp)\n    -   [Routing SMS Notifications](#routing-sms-notifications)\n    -   [Advanced Usage](#advanced-usage)\n-   [Related](#related)\n-   [Acknowledgements](#acknowledgements)\n\n## Installation\n\n**prerequisite**\n\n-   php^7.1\n-   laravel^5|^6|^7|^8|^9|^10\n\nThe package is tested for 5.8+,^6.0,^7.0,^8.0,^9.0,^10.0 only. If you find any bugs for laravel (5.0\u003c \u003e5.8), please file an issue.\n\n```bash\ncomposer require craftsys/msg91-laravel-notification-channel\n```\n\n\u003e If you just want to integrate Msg91 api in Laravel without notification channel, please use [Msg91 Laravel][client-laravel] instead.\n\n## Configuration\n\nNext, you will need to add a few configuration options to your `config/services.php` configuration file. You may copy the example configuration below to get started:\n\n```php\n// along with other services\n'msg91' =\u003e [\n    'key' =\u003e env(\"MSG91_KEY\")\n]\n```\n\nAll available configuration can be found at [msg91-php client's configuration page][client-configuration]\n\n## Usage\n\nIf a notification supports being sent as an SMS, you should define a `toMsg91` method on the notification class. This method will receive a `$notifiable` entity and should return a `Craftsys\\Notifications\\Messages\\Msg91SMS` or `Craftsys\\Notifications\\Messages\\Msg91OTP` instance based on your need to sending message or sending an OTP.\n\n**NOTE**: Phone number must be in international format i.e. it must include the country code.\n\n\n```php\n\u003c?php\n\nnamespace App\\Notifications;\n\nuse Illuminate\\Notifications\\Notification;\nuse Craftsys\\Notifications\\Messages\\Msg91SMS\n\nclass OrderPicked 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    // add \"msg91\" channel to the channels array\n    return ['msg91'];\n  }\n\n  /**\n   * Get the Msg91 / SMS representation of the notification.\n   *\n   * @param  mixed  $notifiable\n   * @return \\Craftsys\\Notifications\\Messages\\Msg91SMS\n   */\n  public function toMsg91($notifiable)\n  {\n    return (new Msg91SMS)\n      -\u003eflow('your_flow_id_here')\n      // you can also set variable's values for your flow template\n      // assuming you have ##order_id## variable in the flow\n      -\u003evariable('order_id', $notifiable-\u003elatestOrder-\u003eid);\n  }\n\n}\n```\n\n### SMS\n\n```php\n// your Notification\npublic function toMsg91($notifiable)\n{\n    return (new \\Craftsys\\Notifications\\Messages\\Msg91SMS)\n        -\u003eflow(\"your_flow_id\");\n}\n\n// with variables\npublic function toMsg91($notifiable)\n{\n    return (new \\Craftsys\\Notifications\\Messages\\Msg91SMS)\n        -\u003eflow(\"your_flow_id\")\n        -\u003evariable('name', $notifiable-\u003ename)\n        -\u003evariable('status', \"Overdue\");\n}\n```\n\n### OTP\n\n```php\n// your Notification\npublic function toMsg91($notifiable)\n{\n    return (new \\Craftsys\\Notifications\\Messages\\Msg91OTP)\n        -\u003efrom('12123');\n        // -\u003eotp(12123) // set a custom otp\n        // -\u003eresend() // if this is a resend otp notification\n}\n```\n\n### Verify OTP\n\nThis package include the [Laravel Msg91 Client][client-laravel], so you can use all the api provided by that package\nlike verify an OTP, sending otp without using notification channel etc.\n\nYou can access the client using `Msg91` facade as follows:\n\n```php\n$otp_to_verify = 112312;\nMsg91::otp($otp_to_verify)-\u003eto(919999999998)-\u003everify();\n```\n\n### Routing SMS Notification\n\nWhen sending notifications via the `msg91` channel, the notification system will automatically look for a\n`phone_number` attribute on the notifiable entity. If you would like to customize the phone number the notification\nis delivered to, define a `routeNotificationForMsg91` method on the entity as suggested on [laravel\ndocs](https://laravel.com/docs/5.8/notifications#routing-sms-notifications).\n\n```php\nclass User {\n    use Notifiable;\n    /**\n     * Route notifications for the Msg91 channel.\n     *\n     * @param  \\Illuminate\\Notifications\\Notification  $notification\n     * @return string\n     */\n    public function routeNotificationForMsg91 ($notification) {\n        return $this-\u003ephone;\n    }\n}\n```\n\nYou can also set the recipient(s) when composing your message in the `toMsg91` method of your notification as\nfollows:\n\n```php\npublic function toMsg91($notifiable)\n{\n    return (new \\Craftsys\\Notifications\\Messages\\Msg91SMS)\n        -\u003eto(91992123123) // you can also pass an array for bulk notifications\n        -\u003eflow('your_flow_id');\n}\n```\n\n### Advanced Usage\n\nThese messages `Msg91SMS` and `Msg91OTP` extend `\\Craftsys\\Msg91\\SMS\\Options` and `\\Craftsys\\Msg91\\OTP\\Options`, so all configuration methods are available when crafting your notification message. These are all optional and you can use them in any order. e.g.\n\n```php\npublic function toMsg91($notifiable)\n{\n    return (new \\Craftsys\\Notifications\\Messages\\Msg91OTP)\n        -\u003edigits(6) // set the digits in otp message\n        -\u003eexpiresInMinutes(1) // change the expiry time\n        -\u003efrom(\"SNCBD\"); // set a custom sender id\n}\n```\n\n## Related\n\n-   [Msg91 Php Client](https://github.com/craftsys/msg91-php)\n-   [Msg91 Laravel](https://github.com/craftsys/msg91-laravel)\n-   [Msg91 Api Docs](https://docs.msg91.com/collection/msg91-api-integration/5/pages/139)\n\n## Acknowledgements\n\n-   [Nexmo Laravel Notification Channel](https://github.com/laravel/nexmo-notification-channel)\n\n[client]: https://github.com/craftsys/msg91-php\n[client-configuration]: https://github.com/craftsys/msg91-php#configuration\n[client-laravel]: https://github.com/craftsys/msg91-laravel\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftsys%2Fmsg91-laravel-notification-channel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcraftsys%2Fmsg91-laravel-notification-channel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftsys%2Fmsg91-laravel-notification-channel/lists"}