Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Dan Martinez
Tera Expert

Overview

AI has been a thing for a few years in the IT ecosystem and ServiceNow is no expection. Things have evolved and been improved over time, but some organisations still don’t know how to make use of it. This article talks about how to create an AI skill with a sensible purpose so that those that still haven’t felt ready to use it feel more confident about it and also can get an idea for their first use.

In this article we will talk about a new AI skill that calculates how close an Incident and the Problem it’s related to are. Sometimes agents select the wrong problem due to the speed at which they work, so this field can help us locate incongruencies.

 

Data model

First of all, we need to have a place to store such result. The confidence level calculated by the AI will have to be stored somewhere so that we can see it, order by it, group, etc…

For doing so, we will go to the “System Definition” > “Dictionary” and create a new field called “Problem Affinity”

dict.png

 

The field needs to be read-only as shown below:

 

DictEntry.png

 

We add it to the form under the “Related Records” tab as close as we can to the “Problem” field itself:

 

newField.png

 

Creating our skill

Then we will create a new skill by going to “Now Assist Skill Kit” > “Home”. Bear in mind you will need the “sn_aia_admin” role to access this page.

 

homeSkill.png

 

Once we access it, we click on “Create skill”:

 

skills.png

 

Our skill will be configured as shown below:

 

createSkill.png

 

Once we click on “Next” we get the following screen, where we can define the inputs this skill will require. We create a “Reference” type one called “Incident” which is mandatory. This is the Incident we will require to calculate how close it is to the Problem it’s linked to.

 

CreateSkill2.png

 

After doing so, we can click on “Summary and Finish” to be able to edit the skill itself. In there we have the prompt, which we enter the following way:

 

prompt.png

 

Bear in mind we reference the “incident” in the input we mention and we can dot walk as we would do in a script, hence why we do “incident.problem_id.short_description” for instance. Please, remember where the “Run test” button is highlighted by the red arrow above, as we will be using it later.

 

Now let’s create two incidents and one problem. One of the incidents will match the problem. The other one, though, will not.

 

This is the incident that will match the problem:

 

INC17.png

 

This is the problem that matches it:

 

PRB.png

 

Finally, the unrelated Incident:

 

INC18.png

 

Now, we go to the “Related records” in both incidents and relate them to the Problem we have just created.

Let’s test our skill with both incidents and see what happens now that we have them linked.

With INC0019018 (the unrelated INC) the AI recognises that both aren’t related.

 

test1.png

 

However, with INC0019017

 

test2.png

 

Given that we can see it works well, we will be amending the prompt to request it not to provide anything apart from the percentage of affinity.

 

test3.png

 

Then we need to Publish the prompt by clicking on the button above it.

With this, our skill will return only that number, but the response field will contain a JSON structure that looks like this:

 

{“model_output”:100}

 

For this reason, we cannot simply assign this response to the “Problem affinity”. We have two options, we remove the JSON structure and replace it with the number in the skill or we parse the response in the Flow. At this moment we cannot redirect the output to another output field as ServiceNow doesn’t allow that as of today.

Once this is possible we could simply redirect it. Given that this is not the case, we will opt for creating a Postprocessor to “clean” the output so that the Flow can consume it directly.

 

processors.png

 

This can be done by going to the “Skill settings” and going to the provider, in this case “Now LLM Service” and clicking on “+Add” on the “Provider postprocessor”. This will allow us to perform actions after the skill has provided an output.

 

postprocessor.png

 

Once we perform this action, we save the postprocessor and are ready to configure its visibility and usability. Just make sure you click on “Save” to prevent the changes from being lost.

 

Ensuring we can use the Skill

Now let’s go to the “Skill Settings” and there to the “Deployment Settings” and we tick the “Flow Action” option to be able to use this skill in a Flow, although this is not the only thing we need to do. We will see after publishing the skill how to ensure it’s selectable there.

 

deploy.png

 

Then we publish the Skill using the button located at the top-right corner:

 

pub.png

 

pub2.png

The skill is now ready to go, but there is one more thing we need to do to ensure the skill can be used in a Flow. For that, we need to go to the “Now Assist Admin” panel.

 

admin.png

 

Then under the “Now Assist Skills” > “Other” we will find the “Problem Affinity Calculator” skill within the “Available” tab. Bear in mind that it appears under “Other” because when we selected the Workflow under the “Now Assist Features” in the Deployment section of our skill we selected “Other”.

 

skillAdmin.png

 

By clicking on “Active skill” we will see the following screen. Bear in mind if you see “Turn on” you need to go back to the deployment settings in your skill and ensure you select “Flow”.

 

triggerskill.png

 

In this screen we ensure the “Display” slider close to the Flow Action is on and click on “Save and continue” to see the other details, which we can simply leave alone and Activate the skill.

 

Making use of the skill

The only thing needed now is a Flow. This Flow will ensure there’s both a trigger and a mechanism to store the confidence level the skill prints into the “Problem Affinity” field we created at the beginning of this article.

 

flow designer.png

 

We create a new flow called “Problem Affinity Calculator”:

 

newFlow.png

The first step is defining the trigger, which we define this way. If the Problem field within the Incident changes, we will trigger the flow for every update of this type:

trigger.png

 

Then the first action needs to be an "if" statement to validate if the Problem field contains something or not. If not, we need to clear the "Problem Affinity" value, otherwise we need to recalculate it:

 

ProblemIsEmpty.png

 

This is the update we perform if "Problem" is empty:

Problem is empty.png

 

Then we create an else statement and use the “Execute skill” selecting “Other” in the “Workflow” field and our skill under “Skill Config”. Then the Dynamic input should show the Incident input we defined in our skill. If it doesn’t we can always click on the circle arrow to refresh the values.

 

execute.png

 

The last step is saving the result of our skill in the Incident under the “Problem Affinity” field we created at the very beginning of this article.

 

ExecResult.png

 

Selecting the incident coming from the trigger, then setting the “Problem Affinity” to the response obtained from the output given by the “Execute Skill” action we ensure we store the result. Then we Activate the Flow as usual.

 

Showing the end results

In the test we performed in our skill we had already entered a Problem in both Incidents. Let’s clear the “Problem” value in them and save them so that we can enter the same problem again and see how ServiceNow populates the “Problem Affinity” field.

 

populatedfield.png

After making it blank and populating it again, we see the “Problem Affinity” being populated.

From the list itself, if we display the Problem Affinity field, we will see them at a glance, helping us detect Incidents related to a Problem they shouldn’t be:

 

IncidentList.png

Please like 👍 and share 🌍 this article to your colleagues if you found it useful.