HBot.js - Simple and Lightweight Javascript AI Library

HBot.js Introduction

HBot.js is a Simple and Lightweight Javascript AI Library suitable for creating a Live Chat/Help Center/Chat Bots inspired by A.L.I.C.E.
The HBot function take three arguments (Database, Message, Default Reply), explained below.

Database: Database is a Javascript Object containing Regular Expressions String as Key and A Callback Function as Value. (Required)

Message: Message is the user input, it can be from any input source e.g Input Area, Window Prompt, String etc. (Required, Default: No match for in bot's database)

Default Reply: This text would be returned if no match was found for the user input. (Optional)

Example & Demo

Below is an example code and the result:

<div id="output"></div> <form method="post">
<input type="text" id="msg" value="" placeholder="Enter message..." />
<input type="submit" id="chat" value="Chat"/>
<script src="HBot.js"></script>
(function () {
document.querySelector('#chat').onclick = function (e) {
var db = {
'Hello': function (m) {
return "How are you";
'My name is (.*)': function (m) {
// 'm' is a array that contains all the regular expressions matches.
return "Hello " + m[1];
var msg = document.getElementById('msg').value;
var output = document.getElementById('output');
output.innerHTML += "You: " + msg + '
output.innerHTML += "Bot: " + HBot(db, msg) + '
'; msg = '';

Note: (.*) means ANYTHING and m would contains all the matches, you should know Regular Expressions to make more advanced matches.

Demo ( Recognize only 'Hello', 'My name is <your_name>' and 'Bye' or 'Goodbye' )...Note: 'hELlo' is same as 'Hello', it is case-insensitive :)

Check my other projects here