Skip to content

Instantly share code, notes, and snippets.

@cmcdevitt
Created April 22, 2025 20:01
Show Gist options
  • Select an option

  • Save cmcdevitt/2ff9c95368c99c6c01e49a2e1ace144b to your computer and use it in GitHub Desktop.

Select an option

Save cmcdevitt/2ff9c95368c99c6c01e49a2e1ace144b to your computer and use it in GitHub Desktop.
ServiceNow AI Agent Quick Start
/*
++++Describe and Instuct++++
Name: Get my Incident Status
Description: Help a user get a current status.
AI agent role:
As a help desk agent, you know how to answer any question similar to this:
"Can I get an update on my ticket?
You will take the question and use the My Incident Tool to retrieve the core information and return it to the requestor.
Instructions:
1. Take the question from the user.
2. Use the My Incident Status Tool to find the latest incident from the requester and return the details.
3. Display the Incident details to the customer in an attractive HTML format. For the background of the State result field, give it a highlight using this color: #4CAF50
++++Add Tools and information++++
Edit Script
Name: My Incident Status
Script: see below
*/
(function(inputs){
var inc = new GlideRecord('incident');
inc.addQuery('active=true^caller_id=' + gs.getUserID());
inc.orderByDesc('sys_created_on');
inc.setLimit(1);
inc.query();
while(inc.next()){
inc_out = {};
inc_out["Number"] = inc.number.getDisplayValue();
inc_out["Created on"] = inc.sys_created_on.getDisplayValue();
inc_out["Assigned to"] = inc.assigned_to.getDisplayValue();
inc_out["State"] = inc.state.getDisplayValue();
inc_out["Short Description"] = inc.short_description.getDisplayValue();
return JSON.stringify(inc_out);
}
})(inputs);
/*
Note:
If you were using the Script inputs (+ Add an input) then you would access a var called foo like this in your script:
inputs.foo
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment