YOUR FEEDBACK
wrote: Trackback Added: Who is Technology’s Highest Paid CEO?; Who is Technology&...


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.

LATEST FLEX STORIES & POSTS
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 AJAXWorld Conference & Expo 2008 West is 'Beyond AJAX to the RIA Era' and the Call for Papers, which is still ope...
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted to be...
Red Hat CTO Brian Stevens, Citrix CTO Simon Crosby, Egenera CTO Pete Manca, Allen Stewart, Group Manager, Windows Virtualization at Microsoft, and Brian Duckering, Sr. Director of Products and Alliances at Symantec were the top industry executives who joined Jeremy Geelan in the 4th Fl...
I have recently released a new benchmark called GUIMark. GUIMark is kinda like an Acid3 test on speed that’s geared towards RIA technologies. The goal was to figure out how to implement a reference design in different runtimes and then benchmark how smoothly that design could be anim...
Clear Toolkit 3.0 is a set of components, code generators, and plugins created by software engineers of Farata Systems that they were using internally in multiple Flex enterprise projects. This toolkit will be available free of charge.
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec...
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