|
|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SOA World Conference
Virtualization Conference $200 Savings Expire May 16, 2008... – Register Today!
SYS-CON.TV SYS-CON.TV WEBCASTS |
MXDJ TOP LINKS YOU MUST CLICK ON ! Feature
Building an IM Bot Using ColdFusion
It's easier than you think
By: Ben Forta
May. 7, 2008 01:45 PM
Digg This!
Page 1 of 4
next page »
So what would an IM bot be used for? Imagine that UPS or FedEx had bots online (named UPS or FedEx) that would allow you to simply type a tracking number in an instant message, instantly receiving a tracking response. Or an airline allowing you to type in a flight number to obtain gate information or flight status. Or your company employee directory allowing users to type in partial names to do lookups (the results of which could include an e-mail address which could be clicked on to send an e-mail). Or my ColdFusion LiveDocs example, mentioned previously. Of course, not all applications are suited to this type of interaction. But many are, and IM bots allow you to provide instant access to applications leveraging the immediacy and simplicity of now ubiquitous IM clients. ColdFusion Event Gateways To The Rescue ColdFusion MX 7 Enterprise (and Developer's Edition) includes support for event gateways. The best way to understand event gateways is to understand what it is they allow. ColdFusion has long been an incredibly simple way to build Web apps. That's why we all use ColdFusion, simplicity (and thus productivity). But ColdFusion is not exclusively tied to the Web. In fact, ColdFusion does not even talk to Web browsers (that is the Web server's job). ColdFusion simply executes scripts on the server in response to requests, requests which (thus far) have been typically HTTP originated. So could ColdFusion respond to other requests? For example, data sent to a specific port, or changes in a folder, or inbound SMS and IM messages, or database table changes, or ... ? The answer is yes, ColdFusion can respond to any and all of those, it just needs a way to know when those events occur. Understanding ColdFusion Event Gateways ColdFusion has a built in event gateway service (which can be stopped and started using the ColdFusion Administrator, and which is running by default). The event gateway service receives all gateway requests, queuing and routing them to the appropriate gateways as needed, and then executing them using a designated number of allowed threads (10 by default). ColdFusion ships with an array of gateway types out of the box (additional ones are available from 3rd parties, and you may write these yourself too). Gateway types written in Java, and are registered in the ColdFusion Administrator. Gateway types are just that, types, they are not gateway instances. The folder watcher type has no code specific to your folders or what you'd want when an event is triggered. An SMS gateway type knows how to connect to SMS servers and exchange messages, but is not tied to a specific account or processing. Gateway types are generalized, they are the processing that is not unique to your application. You can kind of think of gateway types as being a bit like database drivers, they contain (and encapsulate) the code and processing needed to interact with some system or technology. And, as already stated, they must be registered in the ColdFusion Administrator before they can be used. Gateway instances are also defined in the ColdFusion Administrator. A gateway instance is simply an entry that defines the name, the associated type, the name of an optional configuration file, and the name of the CFC file containing your processing. So, if you needed a gateway to respond to requests coming in over a socket, you'd create a gateway instance using the appropriate gateway type and specifying a CFC file that would actually receive those requests so as to be able to respond to them. A single gateway type can be used in as many gateways as needed (so you can have several different IM applications running, or multiple folders being watched each triggering different events). The CFC used is no different to any other CFC, except that specific method names are used (these are specified by the gateway type being used, each gateway type will expect specific CFC methods to be present). The CFC is straight CFML, and can contain any CFML code and processing. When a gateway event occurs (an SMS message arrives, a database trigger fires, data is received by a socket being watched, and so on), the ColdFusion gateway engine calls the appropriate CFC method, telling it everything it needs to know about the event. And your CFC code can then respond, using the same CFML that you know and love. What You Need
Page 1 of 4 next page »
LATEST FLEX STORIES & POSTS
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||