PHPackages                             osa-eg/laravel-teams-notification - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. osa-eg/laravel-teams-notification

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

osa-eg/laravel-teams-notification
=================================

A Laravel package to send notifications to Microsoft Teams

v2.1.4(1y ago)71257.5k↓10.7%9[1 issues](https://github.com/osa-eg/laravel-teams-notification/issues)1MITPHPPHP &gt;=7.0

Since Jul 29Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/osa-eg/laravel-teams-notification)[ Packagist](https://packagist.org/packages/osa-eg/laravel-teams-notification)[ RSS](/packages/osa-eg-laravel-teams-notification/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (8)Used By (1)

Laravel Teams Notification
==========================

[](#laravel-teams-notification)

Laravel Teams Notification is a package for sending notifications to Microsoft Teams using the "Post to a channel when a webhook request is received" workflow webhook. It supports sending normal messages, exception messages with trace, and messages with additional details or JSON blocks, following the JSON structure required by Microsoft Teams adaptive cards. The package also includes custom logging functionality for Laravel, making it easy to integrate with your existing Laravel applications and log important events directly to Microsoft Teams channels.

 [![Image 2](assets/images/1.jpg)](assets/images/1.jpg)

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Publishing Files](#publishing-files)
    - [Config](#config)
- [Usage](#usage)
    - [Sending a Normal Message](#sending-a-normal-message)
    - [Sending a Normal Message with Additional Details and Color](#sending-a-normal-message-with-additional-details-and-color)
    - [Sending a Success Message](#sending-a-success-message)
    - [Sending a Warning Message](#sending-a-warning-message)
    - [Sending an Error Message with Trace and Default Attention Color](#sending-an-error-message-with-trace-and-default-attention-color)
    - [Sending a Message with Array as JSON Block and Custom Color](#sending-a-message-with-array-as-json-block-and-custom-color)
- [Custom Logging](#custom-logging)
- [Methods](#methods)
- [Learn More](#Learn-More)
- [License](#license)

Features
--------

[](#features)

- **Send Normal Messages**: Send simple text notifications to Teams.
- **Send Messages with Additional Details**: Include extra details in the notification.
- **Send Success Messages**: Highlight successful operations with a green color.
- **Send Warning Messages**: Indicate warnings with an orange color.
- **Send Error Messages**: Report errors with a red color and optional stack trace.
- **Send Messages with JSON Blocks**: Include formatted JSON data in the message.
- **Custom Logging**: Log messages directly to Microsoft Teams using Laravel’s logging system.
- **Configurable Message Colors**: Set custom colors for messages with predefined options.

Installation
------------

[](#installation)

To install the package, you need PHP 7.0 or higher and Laravel 5.5 or later. Use Composer:

```
composer require osa-eg/laravel-teams-notification
```

Then, add your Microsoft Teams webhook URL to your `.env` file:

```
TEAMS_WEBHOOK_URL=your_teams_webhook_url
```

Publishing Files
----------------

[](#publishing-files)

### Config

[](#config)

To publish the config file included with this package to your Laravel project, run:

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

Usage
-----

[](#usage)

### Sending a Normal Message

[](#sending-a-normal-message)

To send a normal message, use the `sendMessage` method:

```
use Osama\LaravelTeamsNotification\TeamsNotification;

$notification = new TeamsNotification();
$message = "System Notification";
$notification->sendMessage($message);
```

### Sending a Normal Message with Additional Details and Color

[](#sending-a-normal-message-with-additional-details-and-color)

To send a normal message with additional details, use the `sendMessage` method with the second parameter:

```
use Osama\LaravelTeamsNotification\TeamsNotification;

$notification = new TeamsNotification();
$message = "System Notification";
$details = [
    'Server' => 'Production',
    'Status' => 'Running',
    'Uptime' => '24 days'
];
$notification->sendMessage($message, $details);
```

### Sending a Success Message

[](#sending-a-success-message)

To send a success message, use the `success` method:

```
use Osama\LaravelTeamsNotification\TeamsNotification;

$notification = new TeamsNotification();
$message = "Operation completed successfully!";
$details = [
    'Duration' => '2 seconds',
    'Processed Items' => '150'
];
$notification->success()->sendMessage($message, $details);
```

### Sending a Warning Message

[](#sending-a-warning-message)

To send a warning message, use the `warning` method:

```
use Osama\LaravelTeamsNotification\TeamsNotification;

$notification = new TeamsNotification();
$message = "Warning: High Memory Usage Detected";
$details = [
    'Memory Usage' => '95%',
    'Server' => 'Production'
];
$notification->warning()->sendMessage($message, $details);
```

### Sending an Error Message with Trace and Default Attention Color

[](#sending-an-error-message-with-trace-and-default-attention-color)

To send an error message with trace, use the `error` method and `bindTrace` method:

```
use Osama\LaravelTeamsNotification\TeamsNotification;

try {
    // Code that may throw an exception
} catch (\Exception $exception) {
    $notification = new TeamsNotification();
    $notification->bindTrace()->error()->sendException($exception);
}
```

### Sending a Message with Array as JSON Block and Custom Color

[](#sending-a-message-with-array-as-json-block-and-custom-color)

To send a message with an array as a JSON block, use the `sendJsonMessage` method:

```
use Osama\LaravelTeamsNotification\TeamsNotification;

$notification = new TeamsNotification();
$message = "Data Update";
$data = [
    'user_id' => 12345,
    'action' => 'update',
    'status' => 'success',
    'timestamp' => date('Y-m-d H:i:s')
];
$notification->success()->sendJsonMessage($message, $data);
```

Custom Logging
--------------

[](#custom-logging)

The package also supports custom logging to Microsoft Teams. To set up custom logging, follow these steps:

1. **Configure Logging in Your Laravel Project:**

    In `config/logging.php`, add the following configuration:

    ```
    'channels' => [
        // Other channels...

        'teams' => [
            'driver' => 'custom',
             'via' => \Osama\LaravelTeamsNotification\Logging\TeamsLoggingChannel::class,
             'webhook_url' => env('TEAMS_WEBHOOK_URL'),
             'level' => env('TEAMS_LOG_LEVEL', 'critical') ,
         ],
    ```
2. **Use the Custom Log Channel:**

    To log messages to Teams, use the `teams` log channel:

    ```
    Log::channel('teams')->info('This is an info message');
    Log::channel('teams')->error('This is an error message');
    ```

Methods
-------

[](#methods)

- **setColor(string $color)**: Sets the color of the message. Valid colors are "default", "dark", "light", "accent", "good", "warning", "attention".
- **success()**: Sets the message color to "good".
- **warning()**: Sets the message color to "warning".
- **error()**: Sets the message color to "attention".
- **sendMessage($message, array $details = \[\])**: Sends a normal message with additional details.
- **sendException(\\Exception $exception)**: Sends an exception message with optional trace details.
- **bindTrace()**: Includes the trace in the exception message.
- **sendJsonMessage($message, array $data)**: Sends a message with an array as a JSON block.

Learn More
----------

[](#learn-more)

For a detailed guide on integrating Microsoft Teams notifications with your Laravel application, check out my Medium article:

[Streamlining Laravel Notifications with Microsoft Teams Workflow Integration](https://medium.com/@osama.96.eg/streamlining-laravel-notifications-with-microsoft-teams-workflow-integration-99b0e52cafe4)

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance69

Regular maintenance activity

Popularity49

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Recently: every ~45 days

Total

7

Last Release

448d ago

Major Versions

v1.0.0 → v2.0.02024-07-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/825b6655f6531092c23fc440fcc15222385f7a41b3a2804cd17c3d23e1d760f4?d=identicon)[osa-eg](/maintainers/osa-eg)

---

Top Contributors

[![osa-eg](https://avatars.githubusercontent.com/u/76439995?v=4)](https://github.com/osa-eg "osa-eg (64 commits)")[![rjorel](https://avatars.githubusercontent.com/u/12407789?v=4)](https://github.com/rjorel "rjorel (2 commits)")[![danielrona](https://avatars.githubusercontent.com/u/1699775?v=4)](https://github.com/danielrona "danielrona (1 commits)")[![devNoiseConsulting](https://avatars.githubusercontent.com/u/1700471?v=4)](https://github.com/devNoiseConsulting "devNoiseConsulting (1 commits)")[![edikurniawan-dev](https://avatars.githubusercontent.com/u/50087198?v=4)](https://github.com/edikurniawan-dev "edikurniawan-dev (1 commits)")[![lipfreitas](https://avatars.githubusercontent.com/u/21109081?v=4)](https://github.com/lipfreitas "lipfreitas (1 commits)")

---

Tags

laravellaravel-loggingmicrosoftmicrosoft-teamsnotificationsphp-librarylaravelloggingnotificationTeamsteams-workflowteams-connectoradaptive-cardteams\_loggingmicrosoft-teams-workflowteams-webhock

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/osa-eg-laravel-teams-notification/health.svg)

```
[![Health](https://phpackages.com/badges/osa-eg-laravel-teams-notification/health.svg)](https://phpackages.com/packages/osa-eg-laravel-teams-notification)
```

###  Alternatives

[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
