Microsoft Teams Laravel Notification Channel

composer require laravel-notification-channels/microsoft-teams
// config/app.php
'providers' => [
// ...
NotificationChannels\MicrosoftTeams\MicrosoftTeamsServiceProvider::class,
],
// config/services.php
...
'teams' => [
'webhook_url' => env('TEAMS_WEBHOOK_URL'),
],
...
// config/services.php
...
'teams' => [
'main_url' => env('TEAMS_MAIN_WEBHOOK_URL'),
'test_url' => env('TEAMS_TEST_WEBHOOK_URL'),
],
...

Usage

The usage is fairly simple, you can use the channel in your via() method inside the notification class.

use Illuminate\Notifications\Notification;
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsChannel;
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;

class OrderProcessed extends Notification
{
public function via($notifiable)
{
return [MicrosoftTeamsChannel::class];
}

public function toMicrosoftTeams($notifiable)
{
return MicrosoftTeamsMessage::create()
->to(config('services.teams.webhook_url'))
->type('success')
->title('Order Processed')
->content('You order has been processed successfully.')
->button('Check User', 'https://xyz.abc/users/123');
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bakary Diarra

Bakary Diarra

Full stack developer and Tech enthusiast, experienced with PHP, MySQL, Laravel and VueJS. Love reading and writing 😊