PHPackages                             shahil/msgraph - 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. [API Development](/categories/api)
4. /
5. shahil/msgraph

ActiveLibrary[API Development](/categories/api)

shahil/msgraph
==============

A Laravel package for Microsoft Graph API Teams Message integration.

1.0.5(1y ago)057↓95.8%MITPHPPHP &gt;=8.0

Since Nov 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/shahil-nissam/ms-graph)[ Packagist](https://packagist.org/packages/shahil/msgraph)[ RSS](/packages/shahil-msgraph/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

MS Graph Integration for Laravel
================================

[](#ms-graph-integration-for-laravel)

**shahil/ms-graph** is a Laravel package that simplifies the integration with Microsoft's Graph API, enabling you to send messages, manage chats, send group messages, and utilize Adaptive Cards in your Laravel application effortlessly.

Features
--------

[](#features)

- Fetch and manage OAuth tokens for Microsoft Graph API.
- Retrieve user details using email addresses.
- Create one-on-one or group chats dynamically.
- Send text messages or Adaptive Cards to users or groups via Microsoft Teams.

---

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

[](#installation)

### Requirements

[](#requirements)

- PHP 8.0+
- Laravel 8.0+
- A registered Azure AD application with required permissions for Microsoft Graph API.

### Steps

[](#steps)

1. Install the package via Composer:

    ```
    composer require shahil/msgraph
    ```
2. Publish the configuration file:

    ```
    php artisan vendor:publish --tag=msgraph-config
    ```
3. Update the `.env` file with your Azure AD application credentials:

    ```
    MICROSOFT_CLIENT_ID=your_client_id
    MICROSOFT_CLIENT_SECRET=your_client_secret
    MICROSOFT_TENANT_ID=your_tenant_id
    MICROSOFT_SCOPE=https://graph.microsoft.com/.default
    MICROSOFT_USERNAME=your_admin_email@example.com
    MICROSOFT_PASSWORD=your_admin_password
    ```

### Configuration

[](#configuration)

The package provides a configuration file (`config/msgraph.php`) for customizing default values:

```
return [
    'client_id' => env('MICROSOFT_CLIENT_ID'),
    'client_secret' => env('MICROSOFT_CLIENT_SECRET'),
    'tenant_id' => env('MICROSOFT_TENANT_ID'),
    'scope' => env('MICROSOFT_SCOPE'),
    'username' => env('MICROSOFT_USERNAME'),
    'password' => env('MICROSOFT_PASSWORD'),
];
```

---

Usage
-----

[](#usage)

1. **Retrieve User ID by Email**

    ```
    use Shahil\MSGraph\Facades\MSGraph;

    $userId = MSGraph::getUserId('user@example.com');
    ```
2. **Send a Simple Message**

    ```
    use Shahil\MSGraph\Facades\MSGraph;

    MSGraph::sendMessageToUser('user@example.com', 'Hello from Laravel!');
    ```
3. **Send a Message to a Group**

    ```
    use Shahil\MSGraph\Facades\MSGraph;

    // Retrieve the group chat ID by its name
    $chatId = MSGraph::getChatIdByGroupName('Your Group Name');

    // Send a message to the group
    MSGraph::sendMessageToGroup($chatId, 'Hello group members!');
    ```
4. **Send an Adaptive Card**

    ```
    use Shahil\MSGraph\Facades\MSGraph;

    $adaptiveCardPayload = [
        'type' => 'AdaptiveCard',
        'version' => '1.4',
        'body' => [
            ['type' => 'TextBlock', 'text' => 'Welcome to MS Graph Integration!']
        ],
        'actions' => [
            ['type' => 'Action.OpenUrl', 'title' => 'Learn More', 'url' => 'https://learn.microsoft.com/graph/']
        ]
    ];

    MSGraph::sendAdaptiveCardToUser('user@example.com', $adaptiveCardPayload);
    ```
5. **Get Chat ID for Group by Name**

    ```
    use Shahil\MSGraph\Facades\MSGraph;

    $chatId = MSGraph::getChatIdByGroupName('Your Group Name');
    ```
6. **Get Chat ID for One-on-One Chat**

    ```
    use Shahil\MSGraph\Facades\MSGraph;

    $targetUserId = MSGraph::getUserId('user@example.com');
    $chatId = MSGraph::getChatId($targetUserId);
    ```

---

Examples in Controllers
-----------------------

[](#examples-in-controllers)

Here’s an example of sending a group message inside a controller:

```
namespace App\Http\Controllers;

use Shahil\MSGraph\Facades\MSGraph;

class TeamsController extends Controller
{
    public function sendGroupMessage()
    {
        try {
            $chatId = MSGraph::getChatIdByGroupName('Your Group Name');
            MSGraph::sendMessageToGroup($chatId, 'Hello, team!');
            return response()->json(['success' => 'Message sent to the group successfully.']);
        } catch (\Exception $e) {
            return response()->json(['error' => $e->getMessage()]);
        }
    }
}
```

---

Testing
-------

[](#testing)

Run unit tests for the package:

```
php artisan test
```

---

Contributing
------------

[](#contributing)

Contributions are welcome! Please fork this repository, create a feature branch, and submit a pull request.

---

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

---

Contact
-------

[](#contact)

For issues, questions, or feedback, please contact Shahil via GitHub or open an issue in this repository.

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~17 days

Total

4

Last Release

577d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1008840?v=4)[shahil](/maintainers/shahil)[@shahil](https://github.com/shahil)

---

Top Contributors

[![shahil-nissam](https://avatars.githubusercontent.com/u/189874179?v=4)](https://github.com/shahil-nissam "shahil-nissam (1 commits)")

### Embed Badge

![Health badge](/badges/shahil-msgraph/health.svg)

```
[![Health](https://phpackages.com/badges/shahil-msgraph/health.svg)](https://phpackages.com/packages/shahil-msgraph)
```

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

818355.4k3](/packages/defstudio-telegraph)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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