laravel-teams-notification/laravel-teams-notification

A Laravel package that integrates Microsoft Teams notification.

v1.0.2 2023-04-09 05:50 UTC

This package is auto-updated.

Last update: 2024-05-30 01:06:08 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Installation

You can install the package via composer:

composer require laravel-teams-notification/laravel-teams-notification

You can publish the config file with:

php artisan vendor:publish --tag="laravel-teams-notification-config"

This is the contents of the published config file:

return [
    /*
    |--------------------------------------------------------------------------
    | Webhook URL
    |--------------------------------------------------------------------------
    |
    | The webhook URL where we post a request
    | You can generate test webhook URL in https://typedwebhook.tools/ 
    | or through MS Teams Incoming WebHook
    |
    */
    'webhook_url' => env('WEBHOOK_URL', 'your_webhook_url'),
];

Then, you can add WEBHOOK_URL in your .env file. More information about how to setup webhook in MS teams in this link.

Usage

TeamsNotification::create()
    ->webHookUrl('your_webhook_url')
    ->payload([
        'type' => 'MessageCard',
        'context' => 'https://schema.org/extensions',
        'themeColor' => '0076D7',
        'summary' => 'Hello, World',
        'sections' => [
            [
                'activityTitle' => 'Hello, World!',
            ]
        ]
    ])
    ->dispatch();

Screenshot

More samples and screenshot of how the message should look can be found in screenshots folder.

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.