PHPackages                             kaecyra/chatbot - 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. kaecyra/chatbot

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

kaecyra/chatbot
===============

General purpose extensible chat bot for Instant Messaging.

v0.8.2(5y ago)020[1 PRs](https://github.com/kaecyra/chatbot/pulls)MITPHPPHP &gt;=7.3

Since Jun 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kaecyra/chatbot)[ Packagist](https://packagist.org/packages/kaecyra/chatbot)[ RSS](/packages/kaecyra-chatbot/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (10)Versions (17)Used By (0)

ChatBot
=======

[](#chatbot)

[![Packagist Version](https://camo.githubusercontent.com/f4a6cef30ab1e79d406026a041a18af468dce7c583fe28694af8c704e5385c64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6165637972612f63686174626f742e7376673f7374796c653d666c6174)](https://packagist.org/packages/kaecyra/chatbot)[![MIT License](https://camo.githubusercontent.com/a0b25af7c2651913de3a7f352c7bd649b6af0d97c8c1b200c3d3a6f06320e2ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b6165637972612f63686174626f742e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/a0b25af7c2651913de3a7f352c7bd649b6af0d97c8c1b200c3d3a6f06320e2ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b6165637972612f63686174626f742e7376673f7374796c653d666c6174)

`chatbot` is a PHP powered asynchronous robot designed to join company instant messaging rooms and provide useful and humorous commands and responses.

ChatBot is extensible, having the ability to load modules that modify and extend core functionality by intercepting events thrown using a simple event manager.

Table of Contents
=================

[](#table-of-contents)

1. [Installation](#installation)
2. [HipChat Integration](#hipchat-integration)
3. [Usage](#usage)
4. [Core Commands](#core-commands)
    1. Report
    2. List Modules
    3. Load Module
    4. Unload Module
5. [Extending ChatBot](#extending-chatbot)
    1. Module Initialization
    2. Hooks
    3. Permissions
    4. Core Events

Installation
============

[](#installation)

*ChatBot requires PHP 7.0 or higher and an open port 5222.*

Installing ChatBot is as simple as checking out this github repository, or downloading the zip file. Thereafter, copy `conf/config.json.tpl` to `conf/config.json` and make changes as needed.

A good place to start is probably adding `xmpp.jid` and `xmpp.pass`, and changing the bot's nickname.

HipChat Integration
===================

[](#hipchat-integration)

1. Create a new admin account and sign in to hipchat.com with it.
2. Go to {yoursite}.hipchat.com/account/xmpp
3. Use the Jabber ID (jid) and nick on this page in your bot config.
4. Start ChatBot. He should connect to your group.
5. Message ChatBot: `join room #room`.

Usage
=====

[](#usage)

Once the bot is configured, start it using `./chatbot.php start`. When the bot is running, you can shut it down by running `./chatbot.php stop`. Simple!

ChatBot writes fairly aggressively to a log file, available by default at `log/chatbot.log`. Logs are rotated after 10mb automatically. Only 1 previous log file is retained.

Core Commands
=============

[](#core-commands)

ChatBot has a core module called `base` that contains his "core" commands. These facilitate loading and unloading of modules.

Report
------

[](#report)

*Challenge/response method for testing connectivity.*

#### Syntax

[](#syntax)

> `chatbot report`

#### Response

[](#response)

> `: Reporting in, sir`

List Modules
------------

[](#list-modules)

*List all available modules.*

Specifying either **active** or **enabled** somewhere in the line will cause the response to be limited to enabled modules only.

#### Syntax

[](#syntax-1)

> `chatbot list [active|enabled] modules`

#### Response

[](#response-1)

> ```
> , there are 14 modules enabled
>  base v1.0 by Tim Gunter  - Base Commands
>  xmpp v1.0 by Tim Gunter  - XMPP Module
>  xmppmuc v1.0 by Tim Gunter  - XMPP Multi User Chat module
>
> ```

Load Module
-----------

[](#load-module)

*Load and activate an available module.*

Successfully loading a module causes it to be saved to the config file. It will be loaded automatically in the future whenever ChatBot is restarted.

#### Syntax

[](#syntax-2)

> `chatbot load module `

#### Response

[](#response-2)

> `Loaded:  v by  - `

Unload Module
-------------

[](#unload-module)

*Unload and deactive an active module.*

Successfully unloading a module causes it to be removed from the config file. It will no longer be automatically loaded on boot.

#### Syntax

[](#syntax-3)

> `chatbot unload module `

#### Response

[](#response-3)

> `Unloaded:  v`

Extending ChatBot
=================

[](#extending-chatbot)

ChatBot supports extension via loadable modules. The `ROOT/modules` folder is automatically scanned by ChatBot during the boot sequence.

Modules should have their own folder. Inside that folder should be a PHP class file named `class..module.php` which should contain a PHP class named `Module` that extends the module base class `\ChatBot\Module`.

Module class files should use `namespace Module;` in order to prevent name conflicts.

**Example**

```
namespace Module;

use \ChatBot\ChatBot;
use \ChatBot\Module;

class BaseModule extends Module {

}

```

Module Initialization
---------------------

[](#module-initialization)

The `\ChatBot\Module` base class contains a single abstract method, `start()` which acts as the module constructor. `__construct()` is private and cannot be directly used.

Hooks
-----

[](#hooks)

The `start()` method should be used to define module hooks. A hook definition is simply a `callable` array tied to an event name.

**Example**

```
public function start() {
    $this->hook('event_name', [$this, 'hook_method']);
}

```

Multiple hooks can be defined for each event.

Permissions
-----------

[](#permissions)

In order to allow ChatBot to support higher level privileged functions, integration with Orchestration is supported. This integration allows role based permissions to be used for each command.

Each module can define a mapping between roles and granted permissions in its `start()` method.

**Example**

```
public function start() {
    $this->roles = [
        'administrator' => [
            'base.module.control'
        ],
        'staff' => [
            'base.report'
        ]
    ];
}

```

This mapping grants the permission `base.module.control` to users with the **Administrator** role, and the permission `base.report` to users with the **Staff** role.

Core Events
-----------

[](#core-events)

ChatBot has a number of core events that can be hooked out of the box. Combining these events can allow module writers to produce complex workflows.

- startup
- tick
- message
- directed
- command

### Event: startup

[](#event-startup)

Fired on startup, after all modules are loaded and just before ChatBot connects to the chat service.

**Arguments**

> No arguments are provided.

### Event: tick

[](#event-tick)

Fired every 10 seconds while ChatBot is running.

**Arguments**

> No arguments are provided.

### Event: message

[](#event-message)

Fired every time ChatBot receives any private or groupchat message.

**Arguments**

> `Array $event`
>
> ```
> An array describing the received message event.
> [
>   'scope' => String: 'chat' or 'group',
>   'original' => XMPPMsg: message,
>   'to' => XMPPJid: message source JID,
>   'from' => XMPPJid: message target JID,
>   'body' => String: body text,
>   'type' => ?,
>   'fromuser' => Array: source user info array
> ]
>
> ```

### Event: directed

[](#event-directed)

Fired every time ChatBot receives a private or groupchat message that was directed at the bot. All private messages are considered directed, and groupchat messages that start or end with the bot's name are also considered directed.

**Arguments**

> `Array $event`
>
> ```
> Same as message
>
> ```

### Event: command

[](#event-command)

Fired when chatbot receives a message that triggers a State-matched command.

**Arguments**

> `Array $event`
>
> ```
> Same as message
>
> ```

---

> `State $state`
>
> ```
> An object describing the triggered command and providing access to its data.
>
> ```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.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

Every ~128 days

Recently: every ~140 days

Total

12

Last Release

1848d ago

PHP version history (2 changes)v0.1PHP &gt;=7.0

v0.7PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/021b2a80f2781914dbb04a3aec8fa98a286915043f9b695cc158416c0c681b1e?d=identicon)[kaecyra](/maintainers/kaecyra)

![](https://www.gravatar.com/avatar/240cd2c0de6aa1876c3506e14214bc4d3aab9f17c572a265771631be7c51ddcf?d=identicon)[JReko](/maintainers/JReko)

---

Top Contributors

[![kaecyra](https://avatars.githubusercontent.com/u/248212?v=4)](https://github.com/kaecyra "kaecyra (30 commits)")[![LiamBull](https://avatars.githubusercontent.com/u/17298523?v=4)](https://github.com/LiamBull "LiamBull (3 commits)")

### Embed Badge

![Health badge](/badges/kaecyra-chatbot/health.svg)

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

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[j0k3r/php-readability

Automatic article extraction from HTML

186808.8k6](/packages/j0k3r-php-readability)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)[llm/mcp-server

PHP SDK for building MCP servers

431.1k](/packages/llm-mcp-server)

PHPackages © 2026

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