flyingbono/smart-bot

Smart multilinguage bot responder implemented in PHP, with learning capabilities

dev-master / 1.0.x-dev 2016-12-22 10:16 UTC

This package is not auto-updated.

Last update: 2024-11-01 21:28:48 UTC


README

Build Status Code Climate Test Coverage Issue Count Issue Count Listeners

Multilinguage bot responder implemented in PHP, with learning capabilities

Installation :

$ composer.phar require flyingbono/smart-bot

Basic usage :

<?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