PHPackages                             eclaboratorio/mattermost-bot - 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. eclaboratorio/mattermost-bot

ActiveLibrary[API Development](/categories/api)

eclaboratorio/mattermost-bot
============================

Collection of classes to implement Incomming Webhooks, Outgoing Webhooks and Slash commandas for mattermost using PHP

298PHP

Since Sep 20Pushed 7y ago2 watchersCompare

[ Source](https://github.com/ECLaboratorio/mattermost-bot)[ Packagist](https://packagist.org/packages/eclaboratorio/mattermost-bot)[ RSS](/packages/eclaboratorio-mattermost-bot/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Mattermost PHP
==============

[](#mattermost-php)

Mattermost PHP is a compilation of tools to help you develop Bots, webhooks or other applications for Mattermost. It provides code to easily send complex messages to MM with Attachments, actions (buttons)... receive and parse webhooks and a simple wrapper to make bots. Also there is an API connector under development (any help is appreciated via Pull request)

Requirements and Install
------------------------

[](#requirements-and-install)

MattermostBot could be installed via composser. `$ composer require eclaboratorio/mattermost-bot`

It requires php&lt;=7.1

How to use Mattermost Bot
=========================

[](#how-to-use-mattermost-bot)

Here you could find some easy examples

Send a message to Mattermost
----------------------------

[](#send-a-message-to-mattermost)

[![Image of Yaktocat](docs/message_example.png)](docs/message_example.png)

```
//Webhook url provided when you create a new slash command
$webhookUrl = 'https://yourMMserver.com/wooks/xxxxxxx';
$response = new \MattermostBot\Response();
$response->setText("This is an example text");
$response->setUsername("I'm a Bot");
$response->setChannel("@isoria");
//Create the attachment with it's options
$attachment = new \MattermostBot\Attachment();
$attachment->setTitle("I'm an attachment");
$attachment->setText("I'm the content of the attachment");
$attachment->setTitleLink("https://www.elconfidencial.com");
$attachment->setColor("#ff0000");
$attachment->addFieldByText("One Field","With it's value",true);
$attachment->addFieldByText("Second","yeah!",true);
//Add a button
$action = new \MattermostBot\AttachmentAction();
//The callback could be parsed with IncomingAction class
$action->setUrl("https://example.com/webhookUrl/called-when-pressed");
$action->setName("Press me!");
//Values attached to context are sent to the button webhook and parsed by IncomingAction
$action->attachToContext("param1",'value1');
$action->attachToContext("another_param",'asdf');
//Add the button to the attachment
$attachment->addAction($action);
//Attach the attachment and send
$response->addAttachment($attachment);
$response->sendIncomming($webhookUrl);
```

Receive a slash command
-----------------------

[](#receive-a-slash-command)

To parse a Incoming slash message just create a new IncomingSlash

```
$message = new \MattermostBot\IncomingSlash();
```

VarValueText$message-&gt;getText()Token$message-&gt;getToken()UserName$message-&gt;getUserName()Command$message-&gt;getCommand()ChannelId$message-&gt;getChannelId()ChannelName$message-&gt;getChannelName()TeamDomain$message-&gt;getTeamDomain()UserId$message-&gt;getUserId()Make a simple slash command bot
-------------------------------

[](#make-a-simple-slash-command-bot)

To simplify the development and implement some security good practices there's a bot wrapper

### Your webhook url

[](#your-webhook-url)

```
$message = new \MattermostBot\IncomingSlash();
$allowedTokens = ['1ifucdyn1pb1cdz1bk8dmkiqjc'];
//Empty array means everybody could call the bot
//The usernames wothout the @
$allowedUsers = ['myuser'];
$bot = new TestBot($message, $allowedTokens, $allowedUsers);
if ($bot->execute() === false) {
	echo "Bot execution fails";
} else {
	echo "It works!";
}
```

### Bot File

[](#bot-file)

```
class TestBot extends \MattermostBot\BaseBot
{
//Any bot should implement a process function.
//It is call after checking the user is allowed to run the command
protected function process()
{
   $response = new \MattermostBot\Response();
   $response->setResponseType(\MattermostBot\Response::RESPONSE_IN_CHANNEL);
   $response->setUsername("TestBot");
   $msg = "| Var | Value |
    | :------------ |:---------------|
    | Text | {$this->message->getText()} |
    | Token | {$this->message->getToken()} |
    | UserName | {$this->message->getUserName()} |
    | Command | {$this->message->getCommand()} |
    | ChannelId | {$this->message->getChannelId()} |
    | ChannelName | {$this->message->getChannelName()} |
    | TeamDomain | {$this->message->getTeamDomain()} |
    | UserId | {$this->message->getUserId()} |";

   $response->setText($msg);
   $this->sendMessage($response);
}
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

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.

### Community

Maintainers

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

---

Top Contributors

[![inakivb](https://avatars.githubusercontent.com/u/8626495?v=4)](https://github.com/inakivb "inakivb (3 commits)")

### Embed Badge

![Health badge](/badges/eclaboratorio-mattermost-bot/health.svg)

```
[![Health](https://phpackages.com/badges/eclaboratorio-mattermost-bot/health.svg)](https://phpackages.com/packages/eclaboratorio-mattermost-bot)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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