YOUR FEEDBACK
andy.mulholland wrote: intriguing !!! We have full scale 'Mashup Factories' in Chicago USA and Utrec...


2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
MXDJ TOP LINKS YOU MUST CLICK ON !


Building an IM Bot Using ColdFusion
It's easier than you think

The CFC can be saved anywhere on your server. The default path for gateway CFC files is /gateway/cfc under the ColdFusion root (c:\cfusionmx7\gateway\cfc on a Windows standalone installation, c:\jrun4\servers\cfusion\cfusion-ear\cfusion-war\web-inf\cfusion\gateway\cfc on the default ColdFusion instance on a Windows multi-server installation).

Defining The Gateway Instance
With the config file and CFC saved, you can now register the new gateway instance. Here are the steps needed:

  1. Open the ColdFusion Administrator.
  2. Go to the Event Gateways, Settings screen, and make sure that Enable ColdFusion Event Gateway Services checkbox is checked.
  3. Next, go to the Event Gateways, Gateway Instances screen.
  4. Use the form at the top of the screen to add your new gateway instance. Start by specifying a unique Gateway ID.
  5. In the Gateway Type field select XMPP - XMPP Gateway.
  6. In the CFC Path field specify the path to your gateway CFC file.
  7. In the Configuration File field specify the path to your gateway configuration file.
  8. To have your gateway start automatically upon ColdFusion server start, set Startup Mode to Automatic, otherwise set this field to Manual.
  9. And finally, click the Add Gateway Instance button to save your new gateway instance.
To start the gateway, click the green Start button in the gateway Action column. The status will change to Starting, and then Running. And once running, your Google Talk IM bot will be ready to receive and respond to requests.

But what if the bot won't start? The Debugging & Logging, Log Files screen contains a file named eventgateway.log (this file will be created the first time event gateways are used). You can inspect this log file to determine what your gateway is doing and what errors it may have thrown.

And with that, your Google Talk IM bot can be online, and responding to requests.

What About Other IM Networks?
Thus far we have concentrated on Google Talk IM bots, but there are other IM networks out there. In fact, AOL IM (or AIM) and Yahoo IM (or YIM) are the most used public IM networks, with MSN and ICQ (now owned by AOL) being important, too. So what about those networks? What would it take to create an IM bot for those services?

ColdFusion ships with two IM gateway types, XMPP and Lotus Sametime. XMPP is the protocol used by Jabber, and thus by Google Talk (as explained previously), and by private Jabber servers. Lotus Sametime is IBM's real-time collaboration platform which includes instant messaging (and is generally used within organization for internal IM communication, as opposed to public IM communication). So, while ColdFusion can automatically communicate with Google Talk and other Jabber based services, it cannot talk to AIM, YIM, MSN, and ICQ without custom gateway types for these networks and their proprietary protocols.

So how could your bot connect to these services? You have several options available to you:

  • The best option is JBuddy-CF, a set of gateway types created by Zion Software (www.zionsoftware.com/). JBuddy-CF is a commercial product which supports all of the major networks. It comes with an installation program which installs the required Java files into your ColdFusion server, and even includes an optional .cfm file which uses the Administration API to register the new gateway types. Once installed, these can be used like any other gateway types. (And indeed, this is what I am using for the YIM and AIM interfaces of my CF LiveDocs gateway connected as user cflivedocs). This is not a free solution, but it is the simplest and cleanest option available thus far.
  • The CFMX7 IM Event Gateways SourceForge project (http://sourceforge.net/projects/cfmximgateways/) is an ongoing initiative to develop IM gateway types for AIM, MSN, and YIM. This project is a work in progress, but if you don't mind getting involved with alpha code, this may be a viable option.
  • You could install your own Jabber server (your own local IM server), and connect to it using the included XMPP gateway. Jabber add-ons can then be used to connect your IM server to the major IM networks (some servers and add-ons are freebies, others are commercial products). This configuration is not trivial, but it can be made to work very inexpensively.
Once installed and configured, the steps needed to build your bot are no different from those described in previously.

One important point to note is that different gateway types may require different CFC methods and may support different options and gateway helper functions (we'll get to those shortly). JBuddy-CF (built using the same underlying technology as the included XMPP gateway) provides the cleanest IM abstractions, using the exact same interfaces and helper functions for all networks. As such, if using JBuddy-CF, the identical CFC can be used for all networks (only the gateway types and config files will differ). This may, or may not, be the case when using the other two options described above.

Using Helper Functions
So now you know how to create bots and bring them online. But what if you wanted to manipulate bot settings, perhaps to set the status to away temporarily, or to programmatically obtain the number of messages responded to?

Developers creating the Java code for the underlying gateway type can include Java helper methods specific to that gateway type. Not all gateway types have helper methods, but many (including the XMPP gateway) do. To access the helper function you need to obtain a Java GetwayHelper object using a little known CFML function named GetGatewayHelper(). This function takes the id of a gateway as a parameter, and returns a Java object that can then be used within your CFML code.

To demonstrate this, the following code is used to set the IM status for my CFDocs Google Talk IM bot. To use this code with your own bot, simply change the gateway_id. To try out this code, just save it in a .cfm file (on the server running your bot) and execute it.

About Ben Forta
Ben Forta is Adobe's evangelist for the ColdFusion product line. He is the author of several books.

YOUR FEEDBACK
Randy Smith wrote: Got it working - remember to remove the pound sign from in front of each of the options! I assumed that if they said there was a "default" version that you didn't need to specify the parameters. Wrong!
Randy Smith wrote: This was written in 2005. Here it is 2008 and I'm trying to apply this using Cold Fusion 2008 Enterprise, but I can't get the instance to start. The log files are basically saying that talk.google.com won't let me connect. Is there now a different IP I should connect to, or did Google shut down this "portal"?
emanuel wrote: Where can i download this bot? Thanks.
Mark Holton wrote: This is an awesome overview - Thanks for taking the time to supply this great info, Ben!
LATEST FLEX STORIES & POSTS
As a speaker at the upcoming AJAX World RIA Conference & Expo, I just received an email from Lindsay over at SYS-CON Events. She just informed me about the coupon code "spkrguestbootcamp" (lower case) that I can use to invite three guests with. I am not planning to bring anyone with me...
Director of Ribbit's Developer Platform, Chuck Freedman, will explore an evolution in web communication. With the growing demand of RIA and voice-over-the-web solutions, developers finally have a full suite of communication APIs to add to Flash. Coding with Ribbit, Freedman will demons...
Hoffman will give a review of traditional web security and explain the intracacies of Resource enumeration attacks in great detail, Injection attacks, and session hijacking as well as a step by step walk through of hacking an AJAX travel site. The intensive, one-day, hands-on training ...
Kevin Lynch, who will be keynoting on October 21, 2008, helped originally coin the term "Rich Internet Application" in 2002. He has been at the center of innovation in Flash and Adobe AIR since their inception, and currently drives Adobe’s technology platform for designers and develo...
Enterprises are enthusiastically embracing the shift from traditional client/server computing to SaaS. Inspired by customers who have embraced the web, developers are using RIA tools to create innovative new on-demand business applications. One important factor in the shift from tradit...
Rich Internet Applications offer the potential to fundamentally change the user experience and in doing so, yield significant business benefits. The theme of this October's AJAX World Conference & Expo 2008 West is 'Beyond AJAX to the RIA Era' and the Call for Papers, which is still op...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE