PHPackages                             rocketfellows/ms-teams-webhook-message-sender - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. rocketfellows/ms-teams-webhook-message-sender

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rocketfellows/ms-teams-webhook-message-sender
=============================================

v1.0.0(2y ago)17MITPHPPHP &gt;=7.4

Since Mar 17Pushed 2y agoCompare

[ Source](https://github.com/rocketfellows/ms-teams-webhook-message-sender)[ Packagist](https://packagist.org/packages/rocketfellows/ms-teams-webhook-message-sender)[ RSS](/packages/rocketfellows-ms-teams-webhook-message-sender/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Microsoft Teams webhook message sender.
=======================================

[](#microsoft-teams-webhook-message-sender)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHPStan Badge](https://camo.githubusercontent.com/7a8a54e7ee075f9a33edda53b4e146cabdd7b14478a2ca64d17080aaff0f3b3d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230352d627269676874677265656e2e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/7a8a54e7ee075f9a33edda53b4e146cabdd7b14478a2ca64d17080aaff0f3b3d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230352d627269676874677265656e2e7376673f7374796c653d666c6174)[![Code Coverage Badge](./badge.svg)](./badge.svg)

This package is designed for sending messages to Microsoft Teams (MS Teams) channels using webhooks (incoming webhook or connector). For more information about sending messages to MS Teams channels using web hooks see .

Installation.
-------------

[](#installation)

```
composer require rocketfellows/ms-teams-webhook-message-sender
```

Dependencies.
-------------

[](#dependencies)

Current implementation dependencies:

- guzzle client -  - using for http request to webhook.

MS Teams webhook message sender description.
--------------------------------------------

[](#ms-teams-webhook-message-sender-description)

### Basic package types.

[](#basic-package-types)

#### Connector.

[](#connector)

`rocketfellows\MSTeamsWebhookMessageSender\configs\Connector` - a class that encapsulates the connection configuration for sending a message.

Class description:

- `incomingWebhookUrl` - ***string*** - link to a webhook (connector) for sending a message;
- `create` - ***static function*** - static factory function that returns a value of type `Connector`;
- `getIncomingWebhookUrl` - ***function*** - getter that returns the value of the `incomingWebhookUrl` attribute.

#### Message.

[](#message)

`rocketfellows\MSTeamsWebhookMessageSender\models\Message` - a class that encapsulates message data to be sent via a webhook and implements the `JsonSerializable` interface.

Class description:

- `text` - ***string*** - message text to send;
- `title` - ***string | null*** - message title to send;
- `create` - ***static function*** - static factory function returning a value of type `Message`;
- `convertToJson` - ***function*** - function, returns a representation of a `Message` type value as a json string;
- `jsonSerialize` - ***function*** - implementation of the `JsonSerializable` interface;
- `getText` - ***function*** - getter returning `text` attribute value;
- `getTitle` - ***function*** - getter returning `title` attribute value.

### Interfaces.

[](#interfaces)

#### MSTeamsWebhookMessageSenderInterface.

[](#msteamswebhookmessagesenderinterface)

`rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookMessageSenderInterface` - interface for sending a message via a webhook uses a `Connector` type value as a connection, and a `Message` type value as a message.

```
public function sendMessage(Connector $connector, Message $message): void;
```

Interface exceptions:

- `EmptyIncomingWebhookUrlException` - thrown if the link to the webhook is an empty string.
- `InvalidIncomingWebhookUrlException` - thrown if the link to the webhook is not valid (for example, the link is not an url).
- `EmptyMessageException` - thrown if the message text is an empty string.
- `ConnectorException` - thrown if an error occurred when sending a message (for example, if the HTTP response code is not 200).

##### Usage examples.

[](#usage-examples)

Send message with title:

```
$sender->sendMessage(Connector::create(INCOMING_WEBHOOK_URL), Message::create('Hello world!', 'Hello!'));
```

Result:

[![Send message with title result](/readme/src/img.png)](/readme/src/img.png)

Send message without title:

```
$sender->sendMessage(Connector::create(INCOMING_WEBHOOK_URL), Message::create('Hello world!'));
```

Result:

[![Send message without title result](/readme/src/img_0.png)](/readme/src/img_0.png)

#### MSTeamsWebhookTextSenderInterface.

[](#msteamswebhooktextsenderinterface)

`rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookTextSenderInterface` - interface for sending a message via a webhook uses a value of type `Connector` as a connection, and a value of type string (message text) as a message.

```
public function sendText(Connector $connector, string $text): void;
```

Interface exceptions:

- `EmptyIncomingWebhookUrlException` - thrown if the link to the webhook is an empty string.
- `InvalidIncomingWebhookUrlException` - thrown if the link to the webhook is not valid (for example, the link is not an url).
- `EmptyMessageException` - thrown if the message text is an empty string.
- `ConnectorException` - thrown if an error occurred when sending a message (for example, if the HTTP response code is not 200).

##### Usage examples.

[](#usage-examples-1)

Send text:

```
$sender->sendText(Connector::create(INCOMING_WEBHOOK_URL), 'Hello world!');
```

Result:

[![Send text result](/readme/src/img_1.png)](/readme/src/img_1.png)

#### MSTeamsWebhookArrayMessageSenderInterface.

[](#msteamswebhookarraymessagesenderinterface)

`rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookArrayMessageSenderInterface` - interface for sending a message via a webhook uses a `Connector` type value as a connection, and an array type value as a message.

```
public function sendMessageFromArray(Connector $connector, array $messageData): void;
```

Interface exceptions:

- `EmptyIncomingWebhookUrlException` - thrown if the link to the webhook is an empty string.
- `InvalidIncomingWebhookUrlException` - thrown if the link to the webhook is not valid (for example, the link is not an url).
- `EmptyMessageDataException` - thrown if the array with message data is empty.
- `ConnectorException` - thrown if an error occurred when sending a message (for example, if the HTTP response code is not 200).

##### Usage examples.

[](#usage-examples-2)

Send message with title:

```
$sender->sendMessageFromArray(
    Connector::create(INCOMING_WEBHOOK_URL),
    [
        'text' => 'Hello world!',
        'title' => 'Hello!',
    ]
);
```

Result:

[![Send message with title result](/readme/src/img_2.png)](/readme/src/img_2.png)

Send message without title:

```
$sender->sendMessageFromArray(
    Connector::create(INCOMING_WEBHOOK_URL),
    [
        'text' => 'Hello world!',
    ]
);
```

Result:

[![Send message without title result](/readme/src/img_3.png)](/readme/src/img_3.png)

Send message with section:

```
$sender->sendMessageFromArray(
    Connector::create(INCOMING_WEBHOOK_URL),
    [
        'text' => 'Hello world!',
        'sections' => [
            [
                "activityTitle" => "Larry Bryant created a new task",
                "activitySubtitle" => "On Project Tango",
                "activityImage" => "https://adaptivecards.io/content/cats/3.png",
                "facts" => [
                    [
                        "name" => "Assigned to",
                        "value" => "Unassigned",
                    ],
                    [
                        "name" => "Due date",
                        "value" => "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
                    ],
                    [
                        "name" => "Status",
                        "value" => "Not started"
                    ]
                ],
                "markdown" => true,
            ]
        ],
    ]
);
```

Result:

[![Send message with section result](/readme/src/img_4.png)](/readme/src/img_4.png)

#### MSTeamsWebhookJsonMessageSenderInterface.

[](#msteamswebhookjsonmessagesenderinterface)

`rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookJsonMessageSenderInterface` - interface for sending a message via a webhook uses a value of type `Connector` as a connection, and a value of type string (a json string with message data) as a message.

```
public function sendJsonMessage(Connector $connector, string $jsonMessage): void;
```

Interface exceptions:

- `EmptyIncomingWebhookUrlException` - thrown if the link to the webhook is an empty string.
- `InvalidIncomingWebhookUrlException` - thrown if the link to the webhook is not valid (for example, the link is not an url).
- `EmptyMessageDataException` - thrown if the array with message data is empty.
- `InvalidJsonMessageException` - thrown if the json string with the message data is not valid (not valid from the point of view of the json format).
- `ConnectorException` - thrown if an error occurred when sending a message (for example, if the HTTP response code is not 200).

##### Usage examples.

[](#usage-examples-3)

Send message with title:

```
$sender->sendJsonMessage(
    Connector::create(INCOMING_WEBHOOK_URL),
    '{"text": "Hello world!", "title": "Hello!"}'
);
```

Result:

[![Send message with title result](/readme/src/img_5.png)](/readme/src/img_5.png)

Send message without title:

```
$sender->sendJsonMessage(
    Connector::create(INCOMING_WEBHOOK_URL),
    '{"text": "Hello world!"}'
);
```

Result:

[![Send message without title result](/readme/src/img_6.png)](/readme/src/img_6.png)

Send message with sections:

```
$sender->sendJsonMessage(
    Connector::create(INCOMING_WEBHOOK_URL),
    '{
        "text": "Hello world!",
        "sections": [
            {
                "activityTitle": "Larry Bryant created a new task",
                "activitySubtitle": "On Project Tango",
                "activityImage": "https://adaptivecards.io/content/cats/3.png",
                "facts": [
                    {
                        "name": "Assigned to",
                        "value": "Unassigned"
                    },
                    {
                        "name": "Due date",
                        "value": "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
                    },
                    {
                        "name": "Status",
                        "value": "Not started"
                    }
                ],
                "markdown": true
            }
        ]
    }'
);
```

Result:

[![Send message with sections result](/readme/src/img_7.png)](/readme/src/img_7.png)

### Interfaces implementation.

[](#interfaces-implementation)

#### MSTeamsWebhookMessageSender.

[](#msteamswebhookmessagesender)

`rocketfellows\MSTeamsWebhookMessageSender\senders\MSTeamsWebhookMessageSender` - service for sending messages via a webhook.

Sender implements the following interfaces:

- `rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookMessageSenderInterface`;
- `rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookTextSenderInterface`;
- `rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookArrayMessageSenderInterface`;
- `rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookJsonMessageSenderInterface`.

GuzzleHttp `Client` is used to send a request with a message.

##### Usage examples.

[](#usage-examples-4)

Sending a `Message` without a title:

```
$sender = new MSTeamsWebhookMessageSender(new \GuzzleHttp\Client());
$sender->sendMessage(Connector::create(INCOMING_WEBHOOK_URL), Message::create('Hello world!'));
```

Result:

[![Sending a Message without a title](/readme/src/img_8.png)](/readme/src/img_8.png)

Sending a `Message` with a title:

```
$sender = new MSTeamsWebhookMessageSender(new \GuzzleHttp\Client());
$sender->sendMessage(
    Connector::create(INCOMING_WEBHOOK_URL),
    Message::create('Hello world!', 'Hello!')
);
```

Result:

[![Sending a Message with a title](/readme/src/img_9.png)](/readme/src/img_9.png)

Sending a message as a string:

```
$sender = new MSTeamsWebhookMessageSender(new \GuzzleHttp\Client());
$sender->sendText(
    Connector::create(INCOMING_WEBHOOK_URL),
    'Hello world!'
);
```

Result:

[![Sending a message as a string](/readme/src/img_10.png)](/readme/src/img_10.png)

Sending a message as an array:

```
$sender = new MSTeamsWebhookMessageSender(new \GuzzleHttp\Client());
$sender->sendMessageFromArray(
    Connector::create(INCOMING_WEBHOOK_URL),
    [
	    'title' => 'Message title',
        'text' => 'Hello world!',
    ]
);
```

Result:

[![Sending a message as an array string](/readme/src/img_11.png)](/readme/src/img_11.png)

Sending a message as a json string:

```
$sender = new MSTeamsWebhookMessageSender(new \GuzzleHttp\Client());
$sender->sendJsonMessage(
    Connector::create(INCOMING_WEBHOOK_URL),
    '{"title": "Message title", "text": "Hello world!"}'
);
```

Result:

[![Sending a message as a json string result](/readme/src/img_12.png)](/readme/src/img_12.png)

Contributing.
-------------

[](#contributing)

Welcome to pull requests. If there is a major changes, first please open an issue for discussion.

Please make sure to update tests as appropriate.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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

Unknown

Total

1

Last Release

785d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/81402dcd0a07ad550b7f80f5871e7c302770b29d4c73a52fc35ba697f702d56e?d=identicon)[arslanim](/maintainers/arslanim)

---

Top Contributors

[![arslanim](https://avatars.githubusercontent.com/u/22678154?v=4)](https://github.com/arslanim "arslanim (248 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (31 commits)")

---

Tags

ms-teamsms-teams-channelms-teams-incoming-webhookms-teams-incoming-webhook-message-php-senderms-teams-webhook-message-php-senderms-teams-webhook-message-senderphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rocketfellows-ms-teams-webhook-message-sender/health.svg)

```
[![Health](https://phpackages.com/badges/rocketfellows-ms-teams-webhook-message-sender/health.svg)](https://phpackages.com/packages/rocketfellows-ms-teams-webhook-message-sender)
```

###  Alternatives

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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