ohffs/laravel-msteams-alerts is a Laravel package for send a message to ms teams.
It currently has 1 GitHub stars and 304 downloads on Packagist (latest version 1.3.0).
Install it with composer require ohffs/laravel-msteams-alerts.
Discover more Laravel packages by ohffs
or browse all Laravel packages to compare alternatives.
Last updated
This package can quickly send alerts to Microsoft Teams. You can use this to notify yourself of any noteworthy events happening in your Laravel app. This is a fork of Spatie's laravel-slack-alerts so all thanks to them for doing the main bulk of the work. I've pretty much just changed 'Slack' to 'MSTeams'.
use Ohffs\MSTeamsAlerts\Facades\MSTeamsAlert;
MSTeamsAlert::message("You have a new subscriber to the {$newsletter->name} newsletter!");
Under the hood, a job is used to communicate with MS Teams. This prevents your app from failing in case Teams is down.
Want to send alerts to Discord or Slack instead? Check out laravel-discord-alerts and laravel-slack-alerts.
You can install the package via composer:
composer require ohffs/laravel-msteams-alerts
You can set a MSTEAMS_ALERT_WEBHOOK env variable containing a valid Teams webhook URL. You can learn how to get a webhook URL in the Teams docs.
Alternatively, you can publish the config file with:
php artisan vendor:publish --tag="msteams-alerts-config"
This is the contents of the published config file:
return [
/*
* The webhook URLs that we'll use to send a message to Teams.
*/
'webhook_urls' => [
'default' => env('MSTEAMS_ALERT_WEBHOOK'),
],
/*
* This job will send the message to Teams. You can extend this
* job to set timeouts, retries, etc...
*/
'job' => Ohffs\MSTeamsAlerts\Jobs\SendToMSTeamsChannelJob::class,
];
To send a message to Teams, simply call MSTeamsAlert::message() and pass it any message you want.
MSTeamsAlert::message("You have a new subscriber to the {$newsletter->name} newsletter!");
You can also use an alternative webhook, by specify extra ones in the config file.
// in config/msteams-alerts.php
'webhook_urls' => [
'default' => 'https://hooks.office.com/services/XXXXXX',
'marketing' => 'https://hooks.office.com/services/YYYYYY',
],
The webhook to be used can be chosen using the to function.
use Ohffs\MSTeamsAlerts\Facades\MSTeamsAlert;
MSTeamsAlert::to('marketing')->message("You have a new subscriber to the {$newsletter->name} newsletter!");
The to function also supports custom webhook urls.
use Ohffs\MSTeamsAlerts\Facades\MSTeamsAlert;
MSTeamsAlert::to('https://custom-url.com')->message("You have a new subscriber to the {$newsletter->name} newsletter!");
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.