Multilinguage bot responder implemented in PHP, with learning capabilities
$ composer.phar require flyingbono/smart-bot
<?php
require_once '../vendor/autoload.php';
// Options : all are optionals
$options = array(
'listener' => 'SmartBot\Bot\Listener\EnUSListener', // default listener (default: EnUSListener)
'innate' => 'file.php', // Innate memory data (default: null)
'entity' => 'CallerUID', // ID of the person talking to the bot (default: null)
'context' => ['Humor:Funny'], // List of the bot contexts (users-defined)
);
$bot = new \SmartBot\Bot(
// Data path for acquired memory storage)
'/tmp/smartbot-data/',
// Bot options
$options );
// Load innate memory (optionnal)
// @see (documentation : todo)
$bot -> setInnateMemory( $memoryFilePath );
// Learn some data (optional)
$bot -> learn('Weather', 'Sun shine');
$bot -> learn('Myself:name', 'Smart BOT');
// ...
// Add custom listener (optionnal)
$bot -> addListener( 'SmartBot\Bot\Listener\CustomListener' );
// Add custom contexts
$bot -> addContext('Time:morning');
$bot -> addContext(array('Humor:Funny','...'));
// Sets the user who's talking to the bot (required)
// It may be the logged user in your app,
// or simply the PHP Session ID
$bot -> setEntity('Bruno VIBERT');
// Talk to the bot (optionnal, but recommanded ;))
$response = $bot -> talk('Hello !'); // Hello, Hi...
$response = $bot -> talk('My name is John'); // Ok, John, I will remember that !
$response = $bot -> talk('Hi'); // Hello, John