Telegram Notifications In Octobercms Plugin

I would like to send a telegram message to a specific user at 17:00 using laravel's Telegram notification channel, I however can't seem to get it going. I currently use a cmd command for testing, but keep getting errors and don't know what to do.

Here are my files for the command and notification:



namespace Rogier\Lab\Console;

use Illuminate\Console\Command;
use Rogier\Lab\Notifications\DailyTelegram;

   class SendNotifications extends Command

    protected $name = 'lab:notifications:send';
    protected $description = 'Send notifications';
    protected $userid = 919871501;

     * Execute the console command.
     * @return void
    public function handle()
        $this->output->writeln('Sending notifications');
        $notification =  new DailyTelegram($this->userid);


and DailyTelegram.php


namespace Rogier\Lab\Notifications;

use NotificationChannels\Telegram\TelegramChannel;
use NotificationChannels\Telegram\TelegramMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Notifiable;

class DailyTelegram extends Notification

    protected $userid = 919871501;

    public function via()
        return [TelegramChannel::class];

    public function toTelegram()
        return TelegramMessage::create()
            // Optional recipient user id.
            // Markdown supported.
            ->content("Hello there!\nYour invoice has been *PAID*");

I currently get the error "Call to a member function toTelegram() on array", but I feel like I tried everything, maybe I'm doing it completely wrong. Does anyone know how I should do it?

thanks in advance



Yes, you are doing it wrong. Notifiables have notify() method, you should use it:

$user->notify(new DailyTelegram);

In this example $user is App\User instance (which is notifiable out of the box).

You should check out both Laravel's sending notifications and laravel-notification-channels/telegram docs.