Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver [NotificationChannels\Telegram\TelegramChannel] not supported for Queued Notification #73

Closed
mauronex opened this issue May 26, 2020 · 5 comments

Comments

@mauronex
Copy link

mauronex commented May 26, 2020

Hello everybody,
i installed the notification channel following the instructions provided.

I receive the following errors:
Driver [NotificationChannels\Telegram\TelegramChannel] not supported. {"exception":"[object] (InvalidArgumentException(code: 0): Driver [NotificationChannels\Telegram\TelegramChannel] not supported. at /home/mauro/www/queuey/vendor/laravel/framework/src/Illuminate/Support/Manager.php:119)

What i'm trying to do is to send a simple notification when a form is filled.

`
namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

use NotificationChannels\Telegram\TelegramChannel;
use NotificationChannels\Telegram\TelegramMessage;

use Illuminate\Notifications\Notification;

Use Log;

class MerchantLead extends Notification implements ShouldQueue
{
    use Queueable;
    
    protected $message;
    /**
    * Create a new notification instance.
    *
    * @return void
    */
    public function __construct($message)
    {
        $this->message = $message;
    }
    
    /**
    * Get the notification's delivery channels.
    *
    * @param  mixed  $notifiable
    * @return array
    */
    public function via($notifiable)
    {
        return [TelegramChannel::class];
    }
    
    /**
    * Get the mail representation of the notification.
    *
    * @param  mixed  $notifiable
    * @return \Illuminate\Notifications\Messages\MailMessage
    */
    public function toMail($notifiable)
    {
        Log::info('[MERCHANT-LEAD] '. json_encode($this->message));
        return (new MailMessage)
        ->subject('Nuova Richiesta di Contatto da un esercente')
        ->line($this->message['firstname'] . ' ' . $this->message['lastname'] .' ha richiesto informazioni su QApp')
        ->line('Email: ' . $this->message['email'])
        ->line('Phone: ' . $this->message['phone'])
        ->line('Messaggio: ' . $this->message['text']);
        
        
    }
    
    public function toTelegram($notifiable)
    {
        
        $message = "<b>{$this->message['firstname']} {$this->message['lastname']}</b> ha richiesto informazioni su QApp\n";
        $message .= "Email: " . $this->message['email'] ."\n";
        $message .= 'Phone: ' . $this->message['phone']."\n";
        $message .= 'Messaggio: ' . $this->message['text']."\n";
        
        return TelegramMessage::create()
        ->options(['parse_mode' => 'HTML'])
        ->to(env('TELEGRAM_BOT_NOTIFICATION_GROUP_ID'))
        ->content($message);
    }
    
    /**
    * Get the array representation of the notification.
    *
    * @param  mixed  $notifiable
    * @return array
    */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}
`

if i remove the "implement ShouldQueue" the message is sent properly, while if i set the queue the exception above is thrown.

Somebody had a similar problem or an advise on this?

@irazasyed
Copy link
Member

Hi,

I just tried this in my code and it works fine with or without the queues.

Maybe share your other code that invokes this notification? Could be an issue there.

@ulul
Copy link

ulul commented Mar 9, 2021

I have the same problem in Laravel 8, how you solve this problem?

@mauronex
Copy link
Author

mauronex commented Mar 9, 2021

I have the same problem in Laravel 8, how you solve this problem?

In my case, since i was using Horizon to dispatch jobs i had to just terminate and re-start the worker.
It should be also for the queue worker even if you are not using Horizon

@j33tmane
Copy link

j33tmane commented Mar 9, 2021

I have the same problem in Laravel 8, how you solve this problem?

use NotificationChannels\Telegram\TelegramChannel;
use NotificationChannels\Telegram\TelegramMessage;

copy these lines to your notification under App/Notifications/YourNotification.php

@Yeleup
Copy link

Yeleup commented Nov 20, 2023

I have the same problem in Laravel 10, how you solve this problem?

php artisan queue:restart did not help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants