Download the PHP package alimousavi/telenotify without Composer
On this page you can find all versions of the php package alimousavi/telenotify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alimousavi/telenotify
More information about alimousavi/telenotify
Files in alimousavi/telenotify
Package telenotify
Short Description A Laravel package for sending notifications via Telegram.
License MIT
Homepage https://github.com/alimousavidev/telenotify
Informations about the package telenotify
TeleNotify
TeleNotify is a Laravel notification channel for sending messages via Telegram bots.
Installation
You can install the package via composer:
Optionally, you can publish the configuration file:
This will publish a configuration file named telenotify.php
where you can set your Telegram bot API token.
Usage
Step 1: Add Telegram Bot Token
Add your Telegram bot token to your .env
file:
Step 2: Implement TeleNotifiable Interface
Your notifiable model (e.g., User, Employee) should implement the TeleNotifiable
interface and provide a method getTelegramChatId()
:
Note: Using TeleNotifiable Trait
If your notifiable model already has a telegram_chat_id
property, you can simplify implementation by using the TeleNotifiable
trait:
Using the trait is optional but recommended if your notifiable model includes the telegram_chat_id
property to adhere to the TeleNotifiableInterface
requirements.
Step 3: Use TelegramChannel in Notifications
In your notification class, use the TelegramChannel::class
in the via()
method and implement toTelegram()
method:
I highly recommend implementing ShouldQueue
and using the Queueable
trait to optimize performance and enhance the responsiveness of your notification system by leveraging Laravel's queueing capabilities.
Step 4: Example Messages
Example 1: Simple Text Message
Example 2: Message with Parse Mode
Example 3: Message with Disable Notification
For more customization options, refer to Telegram Bot API documentation.
Contributing
Contributions are welcome!
License
This package is open-sourced software licensed under the MIT license.