PHPackages                             chipslays/robot - 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. chipslays/robot

ActiveLibrary

chipslays/robot
===============

1.2.5(3y ago)026MITPHP

Since Oct 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/chipslays/robot)[ Packagist](https://packagist.org/packages/chipslays/robot)[ RSS](/packages/chipslays-robot/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (13)Used By (0)

Robot 🦾
=======

[](#robot-)

A very simple and indispensable helper that helps you automate the answers to simple questions in your application like a chatbot, chat on website, etc.

Supports all languages from [wamania/php-stemmer](https://github.com/wamania/php-stemmer#languages).

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

[](#installation)

```
composer require chipslays/robot
```

Getting Started
---------------

[](#getting-started)

```
require __DIR__ . '/vendor/autoload.php';

$robot = new Skynet\Robot('english');

$robot->train([
    [
        'question' => 'buy coffee get some where can',
        'answer' => 'You can buy coffee in our shop: st. Lenina 420',
    ],
    [
        'question' => 'how much coffee costs price',
        'answer' => 'Coffee costs $5',
    ],
]);

$robot->ask('Where I can buy coffee?'); // You can buy coffee in our shop: st. Lenina 420
```

Examples
--------

[](#examples)

Examples can be found in [examples](/examples) folder.

Methods
-------

[](#methods)

#### `train(array $data): self`

[](#trainarray-data-self)

Train robot brain.

```
$robot->train([
    [
        // a set of keywords, sentences, (duplicate words will be removed)
        'question' => '...',

        // answer for this question
        'answer' => '...',
    ],
]);
```

#### `ask(string $text, callable $callback = 1): string|array|null`

[](#askstring-text-callable-callback--1-stringarraynull)

Get answer for message.

```
$answer = $robot->ask('Where I can buy coffee?'); // returns answer string
```

With callback.

```
// returns value from callback
$answer = $robot->ask('Where I can buy coffee?', function (array|null $item, array $result) {
    // $item - it raw value from traind data with question,
    // answer and the values you passed, or null if answer not found.

    // $result - contain sorted matches, if not found returns empty array

    if (!$item) return null;

    return $item['answer'];
});

dump($answer); // You can buy coffee in our shop: st. Lenina 420
```

#### `matches(int $count = 1): self`

[](#matchesint-count--1-self)

How many matches we need to cut off unnecessary results.

```
$robot->matches(1)->ask(...);
```

#### `debug(bool $enable = false): self`

[](#debugbool-enable--false-self)

Get more details by `ask()` method (matches count, words, etc).

> **NOTE**Not working if callback passed.

```
$answer = $robot->debug(true)->ask('Where I can buy coffee?'); // returns array of all matches detail

// ^ array:2 [
//   0 => array:3 [
//     "matches" => 4
//     "words" => array:4 [
//       0 => "buy"
//       1 => "coffe"
//       2 => "where"
//       3 => "can"
//     ]
//     "answer" => "You can buy coffee in our shop: st. Lenina 420"
//   ]
//   1 => array:3 [
//     "matches" => 1
//     "words" => array:1 [
//       0 => "coffe"
//     ]
//     "answer" => "Coffee costs $5"
//   ]
// ]
```

License
-------

[](#license)

MIT

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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 ~1 days

Total

12

Last Release

1298d ago

### Community

Maintainers

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

---

Top Contributors

[![chipslays](https://avatars.githubusercontent.com/u/19103498?v=4)](https://github.com/chipslays "chipslays (24 commits)")

---

Tags

chatbotrobotassistant

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/chipslays-robot/health.svg)

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

###  Alternatives

[botman/botman

Create messaging bots in PHP with ease.

6.2k1.5M97](/packages/botman-botman)[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

22.8k69.3k](/packages/grumpydictator-firefly-iii)[vipnytt/robotstxtparser

Robots.txt parsing library, with full support for every directive and specification.

27754.6k7](/packages/vipnytt-robotstxtparser)[nlgen/nlgen

A library for creating recursive-descent natural language generators.

56181.3k](/packages/nlgen-nlgen)[casperlaitw/laravel-fb-messenger

A Laravel Package to Integrate Facebook Messenger API

10631.5k](/packages/casperlaitw-laravel-fb-messenger)[tgallice/wit-php

Wit.ai php sdk

7325.2k1](/packages/tgallice-wit-php)

PHPackages © 2026

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