Building bot with Ybot

Ybot - is chat robot written with erlang programming language. It is seats in the chat room and waits incoming messages from other chat users. When Ybot receive message, it try to parse it and after successful parsing it executes his plugin which depends on incoming message. Plugin is just executable script on python, perl, ruby or shell programming language. Ybot's plugins can be varied, from google search to get github site status, from calculating math expressions to get hacker news and etc etc...

In this post i try to descibe all in one place how to install Ybot, configure and use it.

Table of Contents

  1. Get Ybot
  2. Configuration
  3. Ybot and Http
  4. Ybot and Xmpp
  5. Ybot and HipChat
  6. Ybot and Campfire
  7. Ybot and Flowdock
  8. Ybot and Irc
  9. Ybot and skype
  10. Ybot and talkerapp
  11. Other Ybot's parameters
  12. Running Ybot
  13. All about Ybot plugins
  14. Conclusion

Get Ybot

Main Ybot repostiory is at github - Ybot. You can get it with difference methods. You can get it via git:

git clone git://github.com/0xAX/Ybot.git

Or you can download zip or tar.gz version. When you have downloaded you Ybot now you must get it's dependencies and build it from source with:

./rebar get-deps && ./rebar compile

After successful compiling we can configure it.

Configuration

Before Ybot starting we must configure it for your needs. Here i try to descibe all Ybot's configuration parameters. First of all open ybot.config file from Ybot's root directory. This is main and only one configuration file. It holds all Ybot's configuration. ybot.config - is just file with erlang programming language syntax. All strings after % symbol are comments and it's ignored. Let's see how to configure Ybot for different transports. Transport in Ybot is just chat type which Ybot supports. At that moment Ybot supports following transports:

Ybot and Http

You can configure Ybot on http supporting. It can receive data via http and send response. Example of Ybot http configuration:

You must just put host and port parameters to configuration file.

Ybot and Xmpp

You can configure Ybot on xmpp supporting. It can receive data via xmpp and send response to chat. It supports as single user chat, as multi use chat. Example of Ybot xmpp configuration:

Here you must put five standard jabber options to config as: jabber id, jabber room and etc... Since Gtalk works under xmpp/ssl, if you want use Ybot for Gtalk communication, you must just set following connection options into config:

Ybot and HipChat

HipChat works via xmpp too. If you want use Ybot for HipChat communication, just configure it for Hipchat:

It's simple. Little note about hipchat_nick. You must get it in the xmpp settings in your HipChat account page.

Ybot and Campfire

Ybot supports also campfire chat from 37signals. Here example of configuration file for campfire chat:

You must put: campfire login, access token which you can get into campfire account page, campfire room id and sub domain of your campfire room.

Ybot and Flowdock

You also can use Ybot with Flowdock chat. Here is configuration file for flowdock:

Just put Ybot's flowdock login/password and flowdock data as flowdock organization and flow.

Ybot and Irc

Irc :) Irc was first chat which Ybot supports. Ybot configuration example for irc:

You must put Ybot login, channell and server information. Also you can use it via ssl.

Other Ybot's parameters

Ybot's configuration file holds also some parameters. Let's look on it:

Ybot and skype

I added skype support for Ybot, and here i describe hot to configure Ybot for using with skype. First of all i must say, that there is very primitive skype support in Ybot. There is python script - skype.py which you can find here, which uses skype api for works with skype. Also if you want to use Ybot with skype, it depends on Skype4Py library, which you can install with:

pip install Skype4Py

or download source code and

python setup.py install

skype.py script receives skype messages and sends it to Ybot via http, got response from Ybot and sends it back to skype, all simple.

After Ybot configuring, you must configure your skype. Open /etc/dbus-1/system.d/skype.conf and add:

After skype configuring, you must have run skype in the same machine as Ybot. Now configure Ybot. We must run http interface and skype interface in Ybot:

Here we can see that we start skype and http transport. Now we can add to skype contact list our robot and send to it messages.

Ybot and talkerapp

Ybot supports also talkerapp chat. Ybot configuration for using with talkerapp:

running

After Ybot configuring, you can run Ybot with:

./start.sh

Also you can deploy at Heroku. Go to the Ybot's root directory and execute:

heroku create your-application-name -s cedar heroku config:add BUILDPACK_URL=http://github.com/heroku/heroku-buildpack-erlang.git git push heroku master

All about Ybot plugins

Every Ybot's command is plugin. Plugin is just executable script on python, perl, ruby or shell programming language. Ybot's plugins can be varied, from google search to get github site status, from calculating math expressions to get hacker news and etc etc... There are some simple rules how to write Ybot plugin:

You can find core plugins here.

Conclusion

Ybot is open source project and you can help to develop it. All parts of Ybot, Ybot core, Ybot transport, Ybot plugins are open. You can:

Fork Ybot at github, star it, or tell about Ybot to your friends.

Some usefule links: