yousuf/chatman

Chatbot is a php library that uses machine learning to generate responses based on collection of known conversations.

v1.0.1 2024-04-08 13:31 UTC

This package is auto-updated.

Last update: 2024-04-08 13:52:29 UTC


README

Chatman is a machine-learning based chatbot library build in PHP. It can generate responses by learning the conversations. Chatman is very easy to use. It can be used for generating auto responses for social media, customer support, ecommerce website, personal fun etc.

Read Documentation

Installation

First make sure your system has composer installed.

composer require yousuf/chatman

If you get any error like this :

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Root composer.json requires yousuf/chatman ^1.0 -> satisfiable by yousuf/chatman[v1.0.0].
- yousuf/chatman v1.0.0 requires writecrow/lemmatizer dev-master -> found writecrow/lemmatizer[dev-master] but it does not match your minimum-stability.

Then run these commands :

composer require writecrow/lemmatizer:dev-master
composer require yousuf/chatman

Training Dataset :

{
"intents": [

{"tag": "intro",
  "patterns": ["Hello", "Hi", "Hi there", "hey", "Whats up"],
  "responses": ["Hi, how can I help you ?", "Hey, do you need any help ?", "How are you doing?", "Greetings !"]
},

{"tag": "age",
  "patterns": ["how old are you?", "can i know your age", "what is your age"],
  "responses": ["I am 19 years old", "My age is 19", "My birthday is Jan 5th and I was born in 2002, so I am 19 years old !"]
}]
}

Example Code :

require_once __DIR__ . '/vendor/autoload.php';

use Chatman\BotWithPatterns;

$bot = new BotWithPatterns("chatbot.json");
$bot->defaultMsg = "I did not understand !";
$bot->train();

$resp = $bot->getResponse("hello");

echo $resp['resp'];