More CF+Trac integration

I am ever-so-slowly converting our company over to more and more Trac integration. Last week I convinced the Manager of Customer Service that our current system for handling website contacts needed to be Trac-ified. The old system worked pretty much the same way most Contact Us forms work on most CF-powered websites: basic form-to-email gateway. We hadn’t even bothered to throw them in a database.

As our online presence has grown, we’ve been getting more and more contacts via the website. Problem being, managing that volume via email has grown cumbersome. Another problem is that we had been using one form for all types of contacts. Whether the person wanted to ask a question, or report a problem with a product or order, or wanted to contact our HR department — all inquiries came in via the same form, and then were routed manually to the appropriate individual.

Sound familiar?

The new system uses customized forms for each contact type: questions, feedback, problems. Better yet, all of those forms generate tickets immediately in Trac. With Trac involved, we can now report on how long it takes us to get back to people, etc, etc. And if someone is out of the office for a week, someone else can easily go in and take over their tickets until they get back.

Long story short, here’s how to link your contact forms to Trac:

  1. Get at least Trac 0.10.4 running. I’m told that 0.10.5 will also work, but you’re on your own for that one.
  2. Install the following Trac plugins:

    Restart the webservice running Trac once you have all of the new plugins installed.

  3. DO NOT just do cfquery INSERT statements against the Trac database. The Trac UI does a bunch of caching and your tickets won’t show up. Instead, you’re going to need to use XML-RPC to add tickets. Don’t Panic! That’s not nearly as bad as it sounds.
  4. If you aren’t running CF8 with its much-enhanced XML-RPC support, you’ll need to get the custom tags that do XML-RPC: Rob Blitz’s CF_XMLRPC. Follow the included install instructions. Then edit xmlrpc_cf5serializer.cfm and remove the if blocks using IsNumeric, IsDate, IsBinary, and IsBoolean. Yes, really. Trac’s XML-RPC implementation doesn’t want anything but strings and structs and arrays coming in.
  5. Load up the XML-RPC API in your web browser. It’ll look like Towards the bottom of the page, look for the “ticket” section. Pay particular attention to the ticket.getTicketFields() and ticket.create() functions.
  6. If you are using CF_XMLRPC, the call is pretty simple:
    <cfset TracVals=StructNew()>
    <cfset TracVals.Type="defect">
    <cfset TracVals.Milestone="whatever">
    <cf_xmlrpc_clt methodname="ticket.create" serverhostname="#Server#" authuserid="#AuthUser#" authuserpwd="#AuthPassword#" serverurl="#TracURL#" output="Result">
    	<cf_xmlrpc_clt_requestparam value="#Summary#">
    	<cf_xmlrpc_clt_requestparam value="#Description#">
    	<cf_xmlrpc_clt_requestparam value="#TracVals#">
    	<cf_xmlrpc_clt_requestparam value="#Notify#">

    If you are using CF8’s built-in XML-RPC/webservice handling, it’s not too different.

  7. Use the Custom Fields Admin to add any fields from your contact forms that you would like to be visible on each ticket, such as the contact’s company and full name, fax #, etc. Those values get thrown into the TracVals struct above.

With 1-4 hours worth of work, you now have every contact from your website generating a ticket that can be tracked and reported against. Beats the heck out of writing your own ticket tracking system, doesn’t it?

Now you just have to train your people to reply via Trac instead of email, or at least to remember to close out tickets when they are done with them.

By Rick Osborne

I am a web geek who has been doing this sort of thing entirely too long. I rant, I muse, I whine. That is, I am not at all atypical for my breed.