Angel \”Java\” Lopez on Blog

September 27, 2013

Thinking A Bot (2)

Filed under: Artificial Intelligence, Bot, NodeJs, Open Source Projects, SimpleBot — ajlopez @ 7:09 pm

Previous Post

Yesterday, I started a new Node.js module project:

https://github.com/ajlopez/SimpleBot

And today, I have a very simple version 0.0.1 running, with a sample application.

Reference in your program:

var simpletbot = require('simplebot');

Create, configure and launch a bot:

var bot = simplebot.createBot();

bot.use(plugin1);
bot.use(plugin2);
bot.use(plugin3);

bot.start();

A plugin can:

  • Produce incoming messages to be processed by the bot and its plugins
  • Emit out coming messages using the bot
  • Subscribe and process incoming message sent the bot
  • Process out coming messages from the bot

See the README.md, test and samples folder for more detailed information. All is work in progress.

Keep tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

September 26, 2013

Thinking a Bot (1)

Filed under: Artificial Intelligence, Bot, JavaScript, NodeJs, Open Source Projects — ajlopez @ 11:49 am

Next Post

Yesterday, this project entered in my radar:

http://hubot.github.com/

GitHub, Inc., wrote the first version of Hubot to automate our company chat room. Hubot knew how to deploy the site, automate a lot of tasks, and be a source of fun in the company. Eventually he grew to become a formidable force in GitHub. But he led a private, messy life. So we rewrote him.

Today’s version of Hubot is open source, written in CoffeeScript onNode.js, and easily deployed on platforms like Heroku. More importantly, Hubot is a standardized way to share scripts between everyone’s robots.

Interesting, isn’t it? And it’s using Node.js. You know my position: JavaScript + Node.js + TDD is butter 😉

Some months ago, I started to play with autonomous agents, see my Spanish post

Inteligencia Artifical en C# (1) Primeros Agentes

and projects:

https://github.com/ajlopez/SharpAima
https://github.com/ajlopez/NodeAima

(Node.js version was easier, less types, no friction)

My idea is to implement autonomous agents a la Russell Norvig:

 

And now, a bot in Node.js with plugins could be a first path to explore, to have a concrete implementation. An “intelligent” bot is an agent. Let’s explore the idea and implementation.

First: the bot is not related to chat, SMS, email servers, git account, etc. No. A bot is an entity with:

– Input channels (“percepts” in the above picture), to receive message from the environment
– Output channels, to send message to the environment
– Plug-ins

Each plug-in could:

– Implement an input channel, i.e., a plug-in could connect to a chat session, read message from it, and send them to the bot. Or a plug-in that reads messages from a remote queue. Or a plug-in that reads data from a physical sensor.
– Implement an output channel, the same bot could send message from bot to the chat room. Or an output channel could manage LEDs in Raspberry or Arduino.
– Subscribe to messages, i.e. saying “all message that starts with ‘github ‘” are important to me.
– Send message to bot output channel(s)
– Do something, imagine a plug-in to run Grunt tasks, or run tests in a project

A picture:

Each plug-in could be implemented as a JavaScript module, to be install using NPM (Node Package Manager). And it could be tested in isolation. The bot behavior should be simple: a coordinator. And again, it could be build easily using TDD, asynchronous call in Node.js.

A message can be:

– A simple string
– A simple object (ready to be serialized as JSON, if needed)

Some methods would receive a message, and an additional object (named options?) with additional information, like original channel, etc… But I prefer to start simple. Remember:

Baby steps, make it works, make it right, make it fast

More ideas: there could be channels between bots, even distributed bots.

Some of these ideas are implemented in projects mentioned in my post

Distributed Applications and Node.js

It’s time to put these ideas to work.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

Blog at WordPress.com.