Creating RT Scrips with AI

Photo by Emiliano Vittoriosi on Unsplash

AI has been a huge topic in 2023 across all industries and we have been experimenting with it at Best Practical across all parts of our business. One of the areas where we see some real potential is allowing more RT admins to build custom Scrips to automate more things in their systems. Many tools have tried for years to build GUI interfaces to help people build complex logic without learning a programming language. The new AI tools may have just made it possible to let people explain what they need in natural language and get functioning code to implement it.

Experimenting with ChatGPT

The first step in working with the new large language models (LLMs) is working out how to explain to the model exactly what you want it to do for you. These instructions are “prompts”, so this has been referred to as “prompt engineering”. There are techniques that can significantly improve your likelihood of getting good output, so there are many ChatGPT prompt cheat sheets available online and OpenAI has published their own documentation to help people get the most out of the tool.

I decided to try to create a simple Scrip that I have used in training, which is “On Update from Big Boss, Set Priority to High”. This is a fairly simple scrip that uses information about any update on a ticket to possibly change the priority. As you can see from the video, the process involves working through various prompts to get the correct code to create the condition and action. The really cool part is that once you work out how to ask correctly, ChatGPT shows you that it knows how to program valid RT code.

Video showing an RT scrip being created with ChatGPT.

AI Resources

As noted in the video, OpenAI’s ChatGPT isn’t the only service available as a potential coding partner. I have experimented with Microsoft’s Bing and Google’s Bard. There are also open source options like HuggingFace, which has several models to choose from. When we tested, we got some decent output using falcon-180B-chat. All of these services require an account and you’ll need to log in. Each behaved a little differently and needed different tuning to refine and improve the prompts.

Creative Coding

Even with the AI help, you might still run into some snags. One of the models included this line in the sample code output:

my $modifier_email = $self->TicketObj->LastModifier->EMail;

That looks perfectly reasonable, except tickets objects in RT don’t have a “LastModifier” method. And even if it did, RT usually refers to email as EmailAddress rather than EMail. What to do if you run into this?

If you get some errors with suggested code, you can check our documentation to see if there is something close. For example, the RT::Record class, the parent of RT::Ticket, has a method LastUpdatedByObj which is the user who last updated the ticket. That’s pretty close, and you can call “EmailAddress” on that. So the AI might give you a good idea and our documentation can get you the rest of the way. You might also be able to prompt the AI to review the code and confirm it’s real.

Have you had any experiences working with AI to generate some custom RT code? We’d love to hear about what other people are trying and what your experience is. Stop over to our forum and let us know how it’s working for you.

Share this post: