| By Ben Forta | Article Rating: |
|
| May 7, 2008 01:45 PM EDT | Reads: |
35,739 |
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:
- Open the ColdFusion Administrator.
- Go to the Event Gateways, Settings screen, and make sure that Enable ColdFusion Event Gateway Services checkbox is checked.
- Next, go to the Event Gateways, Gateway Instances screen.
- Use the form at the top of the screen to add your new gateway instance. Start by specifying a unique Gateway ID.
- In the Gateway Type field select XMPP - XMPP Gateway.
- In the CFC Path field specify the path to your gateway CFC file.
- In the Configuration File field specify the path to your gateway configuration file.
- To have your gateway start automatically upon ColdFusion server start, set Startup Mode to Automatic, otherwise set this field to Manual.
- And finally, click the Add Gateway Instance button to save your new gateway instance.
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.
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.
Published May 7, 2008 Reads 35,739
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Ben Forta
Ben Forta is Adobe's Senior Technical Evangelist. In that capacity he spends a considerable amount of time talking and writing about Adobe products (with an emphasis on ColdFusion and Flex), and providing feedback to help shape the future direction of the products. By the way, if you are not yet a ColdFusion user, you should be. It is an incredible product, and is truly deserving of all the praise it has been receiving. In a prior life he was a ColdFusion customer (he wrote one of the first large high visibility web sites using the product) and was so impressed he ended up working for the company that created it (Allaire). Ben is also the author of books on ColdFusion, SQL, Windows 2000, JSP, WAP, Regular Expressions, and more. Before joining Adobe (well, Allaire actually, and then Macromedia and Allaire merged, and then Adobe bought Macromedia) he helped found a company called Car.com which provides automotive services (buy a car, sell a car, etc) over the Web. Car.com (including Stoneage) is one of the largest automotive web sites out there, was written entirely in ColdFusion, and is now owned by Auto-By-Tel.
![]() |
Randy Smith 05/07/08 02:00:43 PM EDT | |||
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 05/07/08 01:16:24 PM EDT | |||
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 10/22/05 09:43:27 PM EDT | |||
Where can i download this bot? Thanks. |
||||
![]() |
Mark Holton 10/16/05 09:35:23 AM EDT | |||
This is an awesome overview - Thanks for taking the time to supply this great info, Ben! |
||||
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Adobe Cans Another 9% of its Workforce
- Moyea DVD4Web Converter V2.0 Converts DVD to FLV Fast and Synchronously with Watermarks
- Adobe Fiddles with its Web Apps
- Adobe & Salesforce Cut Cloud Deal
- Hosting.com Launches ColdFusion 9 in the Cloud
- The Real Time Infrastructure Ultimatum
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Microsoft Expression Web Has Got Game
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Bruce Chizen Joins Voyager Capital as Venture Partner
- My Top Seven Wishes From Adobe MAX 2009
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- The Asynchronous CFML Gateway
- Web Services Using ColdFusion and Apache CXF





























