How to get code reviewed by ChatGPT directly in ServiceNow
Demo screenshot of the feature from a personal ServiceNow instance

How to get code reviewed by ChatGPT directly in ServiceNow

Hey there!

Have you ever been stuck in the never-ending cycle of manual code review? It's like playing whack-a-mole, except the moles are bugs and the mallet is your brain. That's why I decided to create a code review tool in ServiceNow using the ChatGPT API. Not only did it save me from losing my mind, but it also showed off the integration opportunities between ChatGPT and ServiceNow.

So, I added a "Code to review" field to the SAFe Task form and a dropdown with options like "Comment inline", "Make leaner", "Find bugs", and "Explain". The options let the developer specify what type of feedback they want and how they want it delivered. Once the developer enters the code and selects the option, the code is sent to the ChatGPT API using a Flow.

Es wurde kein Alt-Text für dieses Bild angegeben.
The Flow itself. And yes, it uses a Decision Table to get the right phrases for the different options.
Es wurde kein Alt-Text für dieses Bild angegeben.
The core step in my custom Flow action. Important: encodeURIComponent(). Thanks to ChatGPT for the idea to use this method. ;)


The API then analyses the code and generates feedback, which is either stored directly in the code field or in the worknotes. Ta-da!

Es wurde kein Alt-Text für dieses Bild angegeben.
My dummy code, reviewed inline


The best part? It saves time and reduces the risk of human error. It's like having a personal code review robot. Plus, it can help improve the quality of the code by giving suggestions for making the code leaner and more efficient.

In conclusion, I created this tool to show off the integration opportunities between ChatGPT and ServiceNow, and it's a valuable addition to any software development team looking to increase productivity and maintain high-quality code. And as a bonus, this article was entirely written by ChatGPT, I just added the pictures. So, if you're ever stuck in the code review cycle, remember that you're not alone and chatbot has your back!

要查看或添加评论,请登录

社区洞察

其他会员也浏览了