[rt-users] RT Survey plugin

Allen allen+rtlist at crystalfontz.com
Thu Apr 1 17:45:51 EDT 2010

> On 29-03-2010 19:00, Todd Chapman wrote:
>> You could just have the resolved template include a link to a survey
>> monkey. http://www.surveymonkey.com/

In our organization, we don't include Transaction Content in the email
templates. So for us, a link to a survey in that email (which does not
include our actual reply to the ticket, just a notice to come see the
ticket in web SelfService) would not make sense.

Therefore, we have a local mod to SelfService/Display.html that will
offer unprivileged users a link to a survey when the ticket is in
resolved or autoclose status, and a customfield (applied to whichever
queues you want, and with Group perm "SeeCustomField" for "Everyone")
flag is unset.

We chose to use a survey created in Google Docs instead of
surveymonkey because we already use Google Apps in our org. But Google
Surveys redirect people at the end to a dead-end Google page instead
of a configurable page, so we needed to alter the html supplied by the
Google Survey. We also needed a place to flip a switch on the RT
CustomField that flags whether the user has visited the survey, so we
know when to stop offering a link to it.

So, we wrapped the Google Survey in a PHP script. The link to that
script from the ticket carries the ticket ID in the querystring. So
the PHP script knows the Ticket ID. The survey asks for the ticket
number in the 3rd question, so appending &entry_2=N to the url to the
google survey generates the form with "N" already filled in as the
answer to question #3.

We used file_get_contents() to get the html from Google and then
DOMxml functions to alter it, adding some code that you can find on
the web that targets the form to a hidden iframe in the page (to bury
google's dead-end "thank you" page) and javascript to then redirect
the user in the main window to the "thank you" page you want, which
for us is back to the ticket. We make sure that if the user was in RT
over SSL, they are redirected back to RT over SSL so they get back in
with the same session.

After the PHP wrapper fixes the html for the survey form, and before
displaying it to the user, it exec()'s the rt cli to set the
"MySurvey" customfield flag, signaling not to show the survey link on
that ticket anymore:

    rt edit ticket/12345 set CF-MySurvey="1"

In order to use the cli, we had to create another privileged user for
that purpose with Global perms to ShowTicket,ModifyTicket and local
perm SeeCustomField,ModifyCustomField for the "MySurvey" CF.

Having to make a new user and keep its password in the PHP wrapper is
kind of messy. It probably would have been better to add an AJAX call
in the wrapped survey form upon submit that would contact RT with the
user's existing session to flip that CF flag. I just didn't know where
to begin to make (or recycle) an RT page that would process such a
request to set a value for that customfield.


More information about the rt-users mailing list