ColdFusion 8 hosting on HostMySite · 56 words posted 05/30/2007 04:15 PM

HostMySite is offering free ColdFusion 8 beta hosting for as long as the beta lasts. Amazingly, the plan even includes a 600MB SQL Server database. Plenty of room to kick the tires on someone else’s machine—although HostMySite and Adobe must both have real confidence in the stability of CF8 to offer a deal like this.

(via fullasagoog)

Comment

* * *

Interview: Dave Hoff and Anthony Webb of IMified · 571 words posted 02/28/2007 05:29 PM

Dave Hoff and Anthony Webb recently launched IMified, “an instant messenger buddy that works across all major IM networks and offers access to a growing number of web applications.” While I’ve worked with the ColdFusion Event Gateway to build automated bots in the past, I’ve never seen the Event Gateway used so well for such broad purposes under a heavy load: IMified provides a single chat interface to Basecamp, Remember the Milk, Google Calendar, and more. I asked Dave and Anthony to talk about their service. And if you haven’t checked out IMified yet, it’s worth your time.

since1968: IMified is one of those great ideas that seem obvious only in hindsight: an IM content aggregator. How did you come up with the idea?

IMified: The idea for IMified came about when I was looking for an easier way to post todo’s to my Basecamp account. I found myself neglecting to add stuff to my projects because the process to do so was too cumbersome. Basecamp is a service I use a lot but doesn’t really warrant me leaving it open in my browser all day. I use IM throughout the day for staying in touch with colleagues and family. It’s always open and available, yet unobtrusive and was a logical interface to “fire and forget” simple data entry tasks.

since1968: Rails gets most of the “Web 2.0” attention. How did you decide to use ColdFusion?

IMified: Choosing anything other than CF as platform wasn’t really an option. Anthony and I are CF developers. When the concept for IMified was finally laid out, ColdFusion became the logical option due in most part to the excellent Event Gateways that are offered out of the box in the enterprise edition. The event gateways allow us to tightly integrate with the IM networks we connect to.

since1968: You say on your blog that your initial growth was almost accidental. For all we know you guys may be running a higher load on the CF Event Gateway than anyone else. What is your load?

IMified: Before launching IMified we did some research and tried to find others out there making use of CF’s Event Gateways under a heavy load. We didn’t find much information to go off of and were really surprised to see that the event gateways were so under utilized. We are handling a very heavy load and CF has handled this load like a champ! Our down time to date has been due to problems with some of the IM networks we run on and one out of control log file that grew to 30gb. In just 3 weeks of operation, our users have completed over 60,000 tasks through IMified!

since1968: What pitfalls did you encounter with the Event Gateways?

IMified: Honestly, none. There haven’t been any surprises as of yet and we don’t expect to see any soon. We’re really impressed with their performance, stability, and ease of use.

since1968: Do you have plans to monetize IMified?

IMified: Yes, we most certainly do. Someones got to pay for all this bandwidth! In the next few weeks we’ll be launching the next phase of IMified that we feel will really change the way people think of IM. We want IMified to be your go-to buddy when you need to get something done at your desk or on your mobile. Somewhere in there will be a business model. Hint hint… API.

since1968: Thanks for your time.

Comment [5]

* * *

ColdFusion and the Basecamp API · 262 words posted 03/26/2006 08:31 PM

37signals has released an API for Basecamp, the project collaboration tool. If you use Curl, here’s a command line example for listing your projects (line breaks inserted for clarity):

curl
-H 'Accept: application/xml'
-H 'Content-Type: application/xml'
-u myname:mypassword -i
since1968.projectpath.com/project/list

But if you’re not hip to the command line, here’s a ColdFusion example of the same query:

<cfhttp url=
"since1968.projectpath.com/projects/42022/milestones/list"
method="get"
result="myresult"
username="myname" password="mypass">
<cfhttpparam type="header" name="Accept" value="application/xml" />
<cfhttpparam type="header" name="Content-Type" value="application/xml" />
</cfhttp>

ColdFusion stores the results in a variable called myresult:

<cfdump var="#myresult#" />

You’ll need to parse the XML stored in myresult.filecontents to make the information human-readable. For example, here’s a quick and dirty loop through the milestone titles, adapted from the ColdFusion XPath docs:

<cfscript>
myxmldoc = XmlParse(myresult.filecontent);
selectedElements = XmlSearch(myxmldoc, "/milestones/milestone/title");
for (i = 1; i LTE ArrayLen(selectedElements); i = i + 1)
writeoutput(selectedElements[i].XmlText & "<br>");
</cfscript>

Basecamp also accepts XML strings to refine your query results, but I haven’t yet figured out how to post them via CFHTTP. If anyone’s done it, feel free to follow up in the comments.

Update: As Dan Short noted here, you can save your XML with CFSAVECONTENT and pass it with another CFHTTPPARAM:

<cfhttpparam type="body" name="post" encoded="no" value="#PostVar#" />

The trick is to make sure you use the name parameter. Thanks Dan.

Comment [2]

* * *

ColdFusion Event Gateways: Building an eCommerce Bot for iChat and Google Talk · 1521 words posted 03/23/2006 12:57 AM

I recently rebuilt an ecommerce site from the ground up. One of the frustrations of working remotely is that you don’t get to see, in real time, how your client uses the application you’ve built for him. Fortunately, ColdFusion MX 7 supports Event Gateways out of the box. Think of an event gateway as a real-time information broker that bypasses HTML to let your site communicate via SMS or Instant Messaging with non-web clients such as a cell phone, or iChat.

spacer

So I whipped up an IM system that sends an alert to iChat any time an administrator logs into the new ecommerce site (see screenshot, left). I liked the feature so much that I thought I could persuade my client to fund a messaging system to send an alert whenever a customer took a certain action, for example, made a purchase over XX thousand dollars, or requested expedited overnight shipping.

In this entry, I’ll suggest an architecture for building your own messaging system using ColdFusion MX 7. The site is closed-source, so I can’t share the bulk of my source code, but I’ll walk you through the logic and give you enough help to get you started.

Requirements

The requirements for this project were pretty restrictive:

Filtering the above requirements, we’re left with an inexpensive (free) widget that lives outside the browser, communicates in real time, and is already built for me. Sounds like a job for an IM client.

ColdFusion Event Gateways, XMPP, Jabber, Google Talk, iChat, and Protocol Soup

By default, ColdFusion MX 7 Enterprise Edition ships with several gateway types, including XMPP, the protocol that powers Jabber. You might not have heard of Jabber, but you’ve certainly heard of Google Talk or iChat, both of which support Jabber Instant Messaging.

By configuring a gateway instance, you can tell ColdFusion to recognize and respond to chats with an arbritrary gmail address, for example your.admin.bot@gmail.com. You can also use the gateway to push messages out to people who are listed as buddies.

For the developer it sounds like a potluck of protocols to understand, but for the end user it’s very simple: using any IM client that recognizes Jabber (such as Google Talk, ichat, Adium, etc.) you add the bot as a buddy and you chat with it.

For the technical details of configuring a bot, see Ben Forta’s excellent Building an IM Bot. Here’s one way to architect your application.

You Had Me At Hello: bot logic

spacer

The diagram below consists of three layers: people (whether it’s an admin using ichat to set up alerts, or a customer using a web browser to place an order); components (these are CFCs); and, of course, the database.

In our example, the gmail bot is a listener CFC: it’s only job is to listen to chat requests and respond accordingly. When a person sends a message to the bot, ColdFusion packages the information in a structure called CFEvent. Within the CFEvent structure you can access information about the sender and the message she sent. Our gmail bot uses the onIncomingMessage function to recognize four commands:

The orders CFC handles orders and inserts them in the database.

The auth CFC authenticates and tracks admin logins.

Finally, the sender CFC broadcasts messages to the ichat client using sendGatewayMessage().

The ichat client is an admin with a gmail address. Let’s call the address you@gmail.com. The admin needs to add the gmail bot as her buddy. Let’s call it your.admin.bot@gmail.com. There are any number of ways you can have the gmail bot authenticate a buddy request. For example, you could look up the sender’s gmail address (passed in CFEvent.OriginatorID) and compare it to a list of known admins in the database. My small business client only has 10 employees, so for convenience and security I manually added each employee as a buddy.

spacer

Step by step:

  1. The admin send a hello message to the bot.
  2. When the bot receives a message, it recognizes the admin as a buddy it calls the function onIncomingMessage. Our onIncomingMessage function includes a simple parser built around a series of findnocase() statements. When it recognizes hello the bot takes two steps: first, it passes the admin’s gmail address (CFEvent.originatorID) to auth, and second, it assembles a return message consisting of a command, a buddyID, and a message to return back to the admin—we just need to let her know that we recognized her command.
  3. auth inserts the admin’s buddy ID into the database. Let’s call the table tbl_listeners. This means the admin is now listening for events. And here’s an important catch: while gateway CFCs can create and recognize session variables, they do not share those variables with regular CFM files. This means you can’t expect a page loaded over the web to recognize a session created via the gmail bot. The implication becomes clearer when we get to the sender in a moment. For now, just remember that the admin is now listed in our database as someone who’s listening for events.
  4. A customer places an order.
  5. The order is saved in the database.
  6. After safely inserting the order, the orders CFC checks for a trigger. You can write a trigger any number of ways; I write my triggers as functions which return booleans. Did the customer select expedited shipping? If no (false), that’s the end of our flow chart—our admin doesn’t need to know the instant every customer places an order. But if true, we want to pass a message to the sender CFC to alert the admin.
  7. The sender CFC has just received a message from orders. The sender hangs on to the message, but first…
  8. sender checks with auth to see who, if anyone, is listening.
  9. auth grabs a list of listening admins from the database and passes that list as a query object back to sender.
  10. Finally, sender takes the message (“A customer has placed an overnight order”) and pushes it to the listener, you@gmail.com. The listener receives an alert in iChat and can act accordingly.

Considerations

Once you understand how Event Gateways work in ColdFusion, it’s easy to build a simple messaging system. Some final considerations to keep in mind:

I hope this gets you started building your own messaging systems. From here, it’s only a short step to building an order support system that’s an order of magnitude faster than a web interface, or even an SMS system that allows customers to track shipments from their phones. In addition to the Forta article mentioned above, I found the following two resources especially helpful: Jeff Tapper’s PowerPoint presentation Using Event Gateways in CFMX7 and Rule Your Site With Instant Messaging by Robert Capili.

Finally, thanks to Sean Corfield for his feedback.

Comment [3]

* * *

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.