PHPackages                             nopolabs/yabot - 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. nopolabs/yabot

ActivePackage

nopolabs/yabot
==============

Yet Another Bot

32191[2 issues](https://github.com/nopolabs/yabot/issues)PHP

Since Jun 2Pushed 6y ago2 watchersCompare

[ Source](https://github.com/nopolabs/yabot)[ Packagist](https://packagist.org/packages/nopolabs/yabot)[ RSS](/packages/nopolabs-yabot/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

Yet Another Bot (yabot)
=======================

[](#yet-another-bot-yabot)

[![Build Status](https://camo.githubusercontent.com/41a9a11d554af0cb7dc63591e27838dea682954cc3cdc1edd629dc1ef9cc735e/68747470733a2f2f7472617669732d63692e6f72672f6e6f706f6c6162732f7961626f742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nopolabs/yabot)[![Code Climate](https://camo.githubusercontent.com/b7b4489fed5541b4a487fa2ffb57629120382d9af995d86f2d2e4b86acf1c4ba/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6e6f706f6c6162732f7961626f742f6261646765732f6770612e737667)](https://codeclimate.com/github/nopolabs/yabot)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/26bc4ad3b59676e440a171ecb229b8f24298a8c4b4b4353ff8e9fa7376121196/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e6f706f6c6162732f7961626f742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nopolabs/yabot/?branch=master)[![License](https://camo.githubusercontent.com/7668538bfbb92927f2fd3966553199b888c6c2934b20516055ba4075a24eb191/68747470733a2f2f706f7365722e707567782e6f72672f6e6f706f6c6162732f7961626f742f6c6963656e7365)](https://packagist.org/packages/nopolabs/yabot)[![Latest Stable Version](https://camo.githubusercontent.com/cbe10f729cc5a8111cd54900973099d83a13da3b93dd425b58ce9279bcbc1b22/68747470733a2f2f706f7365722e707567782e6f72672f6e6f706f6c6162732f7961626f742f762f737461626c65)](https://packagist.org/packages/nopolabs/yabot)

yabot is a slack chat bot written in php.

Quick start
-----------

[](#quick-start)

See [tabot-template](https://github.com/nopolabs/yabot-template)for a discussion of how to build your own bot functionality using yabot.

Architecture
------------

[](#architecture)

I gave a presentation at the 2017-07-17 PHPdx user group: [PDF](Yabot-PHPdx-2017-07-18.pdf)

Configuration
-------------

[](#configuration)

Yabot uses a [Symfony dependency-injection](http://symfony.com/doc/current/components/dependency_injection.html)container for configuration.

`yabot.php` loads three configuration files: `vendor/nopolabs/yabot/config/yabot.xml`, `config/plugins.yml`, and `config.php`.

`vendor/nopolabs/yabot/config/yabot.xml` defines core services used by Yabot and available for plugins to get from the container. You should not need to modify this file.

`config/plugins.yml` provides a place to configure plugins and shared services for your Yabot application. See the discussion of [plugins](#plugins) below.

`config.php` provides a place to set or override runtime settings.

[Importing configuration files](http://symfony.com/doc/current/service_container/import.html)

Logging
-------

[](#logging)

Logging is configured in config.php:

```
'log.file' => 'logs/bot.log',
'log.name' => 'bot',
'log.level' => 'DEBUG',

```

Setting 'log.file' to 'php://stdout' can be useful during development to direct logging information to the terminal where you have started yabot.

Plugins
-------------------------------------------

[](#plugins-)

See [yabot-plugins](https://github.com/nopolabs/yabot-plugins) for examples.

Yabot uses plugins to know what to listen for and how to respond.

There are examples in `src/Examples`, `src/Reservations`, and `src/Queue`.

Minimally a plugin must implement `Nopolabs\Yabot\Bot\PluginInterface`.

Plugins declared in `plugins.yml` with the tag `yabot.plugin` will be loaded automatically:

```
services:
    plugin.help:
        class: Nopolabs\Yabot\Bot\HelpPlugin
        arguments:
            - '@logger'
            - '@yabot'
        tags:
            - { name: yabot.plugin }

```

### Theory of operation

[](#theory-of-operation)

Yabot uses Slack's [Real Time Messaging API](https://api.slack.com/rtm).

Message events are dispatched to each plugin in the order in which they were loaded.

Plugins have an opportunity to react to the messages they receive, e.g. by replying, and may optionally mark a message as handled to interrupt further dispatching.

Plugin configuration is used to select which messages a plugin will react to and how it will react.

### Plugin config

[](#plugin-config)

Plugins built using `PluginTrait` provide a default configuration which may be overridden in `config.php`, e.g.:

```
'plugin.help' => [
    'priority' => PluginManager::DEFAULT_PRIORITY, // optional, higher priority is dispatched sooner
    'prefix' => PluginManager::AUTHED_USER_PREFIX, // optional, string
    'isBot' => false,                              // optional, true, false, or null
    'channels' => [],                              // optional, array of strings
    'users' => [],                                 // optional, array of strings
    'matchers' => [
        'yabotHelp' => [
            'isBot' => null,                          // optional, true, false, or null
            'channels' => [],                         // optional, array of strings
            'users' => [],                            // optional, array of strings
            'pattern' => "/^help (?'topic'\\w+)\\b/", // pattern applied by preg_match()
            'method' => 'help',                       // method called to handle accepted messages
        ],
    ],
],

```

Matcher shorthand syntax:

```
// shorthand:
'help' => "/^help (?'topic'\\w+)\\b/",

// expands to:
'help' => [
    'isBot' => null,   // null matches bot or non-bot
    'channels => [],   // empty array matches any channel
    'users' => [],     // empty array matches any user
    'pattern => "/^help (?'topic'\\w+)\\b/",
    'method' => 'help',
],

```

If the pattern matches the method on the plugin object gets called with the message and any fields captured by the matcher pattern.

Responding to a Message
-----------------------

[](#responding-to-a-message)

#### Replying in the same channel as the message

[](#replying-in-the-same-channel-as-the-message)

```
// assuming: 'help' => "/^help (?'topic'\\w+)\\b/"
public function help(MessageInterface $msg, array $matches)
{
    $topic = $matches[1];
    $msg->reply("you want help with $topic");
}

```

#### In a Thread

[](#in-a-thread)

```
    $msg->thread("here are the details...");

```

#### In a specific channel

[](#in-a-specific-channel)

```
    $msg->say("lunchtime!", 'general');

```

Users and Channels
------------------

[](#users-and-channels)

Slack messages use ids to reference users and channels, e.g.:

DisplayedMessage textWhy not join #tech-chat?Why not join &lt;#C024BE7LR&gt;?Hey @alice, did you see my file?Hey &lt;@U024BE7LH&gt;, did you see my file?`Slack\Client` manages `Slack\Users` and `Slack\Channels` objects and provides methods to help map user and channel names to ids and ids to names.

Message formatting and attachments
----------------------------------

[](#message-formatting-and-attachments)

Yabot uses the Slack REST API to post messages because the web socket API doesn't support formatting and attachments. See: [Slack API Messages](https://api.slack.com/docs/messages)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.2% 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://www.gravatar.com/avatar/43542f25be45fad052ea355eff9050bf02c770e28a88458708d718d553c5724d?d=identicon)[nopolabs](/maintainers/nopolabs)

---

Top Contributors

[![nopolabs](https://avatars.githubusercontent.com/u/815864?v=4)](https://github.com/nopolabs "nopolabs (56 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

### Embed Badge

![Health badge](/badges/nopolabs-yabot/health.svg)

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

PHPackages © 2026

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