Tutorial: Write your own GTalk custom bot in 10 mins!!

A Chat bot is completely automated, that is online 24×7 and will always send & respones to your requests, just like a virtual friend. You can do lot of interesting stuff  like receive alert notifications, post to twitter, book tickets, set reminders, write blogs, and so much more.

Now the reason I am specifically looking at GTalk here is, coz its on open standards - XMPP !!

So how do we write your GTalk custom bot in 10 minutes!


The Solution: We will write a basic chat bot which will change its status message on our command, using an Opensource Framework PYGtalkRobot.Later, you can expand the idea to more complex tasks like posting to twitter or checking emails etc..

Requirements:

-- Geeky mindset, with basic language skills of python.

-- Linux server running Centos with SSH access

-- 2 Gtalk user accounts.

 

Lets, Get Started..

Step 1: Install Python - 2.4 and above

 



yum install python


Step 2: Download and unpack xmpppy.

To install it go into the unpacked directory and run:



python setup.py install


Step 3: Download and unpack pydns.

To install it go into the unpacked directory and run:



python setup.py install


 

Step 4: Next, Checkout the source code for pygtalkrobot from SVN server:



svn checkout http://pygtalkrobot.googlecode.com/svn/trunk/pygtalkrobot/src pygtalkrobot-read-only


Step 5: Setup the Bot

 The pygtalktrobot directory contains the file:'sampleRobotcode.py".In this file, edit the following lines:

Change the following lines as below:



--  if jid == 'ldmiao@gmail.com': to  'ldmiao@gmail.com' to your gtalk id, so that this bot recognizes you as the admin.


--  bot.start("account_name@gmail.com", "password")  to "account_name@gmail.com" & "password" to your second gtalk account details through which the bot will login.


Step 6: Run the sampleRobot



python sampleRobotcode.py


Your sample bot should start running now, and the status should show connected.

 

Step 7: Add the gtalk bot user as a friend in your Gtalk Messenger.

Gtalk bot will automatically accept you as a friend.

 

Step 8: Once added, send the command "online GTalk Bot".

This will change the status message of the bot to "GTalk Bot". Hurray!! Your own bot is ready and it responds to the commands..