We’ll discover how to use Laravel 9 to send Telegram

Step:1 Install the Telegram notification channel first.
You must install the Telegram notification channel using Composer before you may deliver notifications using Telegram.
Step:2 Create your Telegram bot in step two.
Open Telegram and say hi to the BotFather bot there.


Step:3 In the config/service.php section, add the Telegram
# config/services.php
Fill up the environment file with your
Step:4 Get your groupId after
choose a new group

Put your bot in the group.

Choose a group name.

Group IDBot with this.


Gather your team. Id


Step: 5 Make and set up a notification
Each notification in Laravel is represented by a single class, which is normally kept in the directory app/Notifications. If you run the make command, a directory will be created for you even if you don’t see it in your application. notification artisan’s order:
following configure file app/Notification/SendNotification
<?php
namespace App\Notifications;use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use NotificationChannels\Telegram\TelegramMessage;class SendNotification extends Notification
{
use Queueable; public function __construct()
{
//
}
public function via($notifiable)
{
return ['telegram'];
}public function toTelegram($notifiable)
{
return TelegramMessage::create()
->to('-794197572')
->content('Enviando nuestro primer mensaje con Telegram');
}}
Step:6 Send Message
You can deliver notifications using the notify trait or, as an alternative, the Notification façade. When you need to notify numerous notifiable entities, such as a group of users, this strategy can be helpful.
notify trait
use App\Notifications\SendNotification;$user->notify(new SendNotification($invoice));
Notification facade
use Illuminate\Support\Facades\Notification;Notification::send($users, new SendNotification($invoice));