Creating a GenAi-PI using ServiceNow NowAssist

by snnerd
793 views

Integrating Generative AI (GenAI) with ServiceNow

Generative AI (GenAI) is changing the way we work with ServiceNow by automating tasks like decision-making, ticket handling, and improving customer service. In this guide, we’ll look at how to integrate GenAI with ServiceNow, whether you’re using NowAssist or building your own solution with AI APIs.

Leveraging NowAssist for Seamless AI Integration

If you’re using NowAssist, integrating AI is significantly easier with the following built-in tools:

  • Skill Kit: A powerful framework that allows ServiceNow developers to leverage AI capabilities within workflows, automating complex decision-making processes.
  • GenAI Spoke: A set of predefined actions for integrating AI-driven automation, including text analysis, sentiment detection, and predictive analytics.

With these tools, you can integrate AI-driven insights directly into ServiceNow, streamlining processes without extensive manual configuration.

Implementing AI Without NowAssist

If you don’t have access to NowAssist or Skill Kit, you can still integrate AI into ServiceNow using third-party APIs. This approach requires additional setup but allows for greater flexibility in selecting AI models.

  • REST Spoke: Use ServiceNow’s REST Spoke to connect with external AI providers like OpenAI, Google Cloud AI, or Azure AI Services.
  • Scripted REST API: Develop a custom ServiceNow API endpoint that interacts with your AI provider, handling requests and responses dynamically.

Although this method takes longer to implement, it provides full control over AI interactions and data processing.

What is GenAI-PI?

GenAI-PI is a term I coined to describe the structured interaction between Generative AI and APIs. Traditionally, APIs return structured responses based on specific queries. Similarly, by carefully engineering AI prompts, we can ensure AI models return structured, predictable outputs—effectively treating them as “GenAI APIs.”

By leveraging structured AI responses, businesses can automate workflows, generate insights, and integrate AI-powered decision-making into their existing platforms.

Use Case: Predicting Customer Satisfaction for Service Improvement

Customer feedback is a cornerstone of service improvement in the IT industry, helping businesses refine their processes, enhance customer experiences, and address recurring issues. However, one major challenge is the low response rate to customer satisfaction surveys.

The Challenge: Low Survey Participation in IT Support

According to industry research:

  • Survey response rates in IT service management (ITSM) typically range from 5% to 30%.
  • CSAT (Customer Satisfaction) surveys for IT support teams often see even lower participation, averaging between 10% and 15%.
  • A Gartner report indicates that 80% of companies rely on CSAT surveys for measuring service quality, yet only a fraction of customers respond.
  • Forrester Research found that companies collecting more feedback have 5-10% higher retention rates than those that don’t, emphasizing the importance of obtaining satisfaction insights.

The Impact of Missing Surveys

When customers don’t respond to surveys, businesses miss out on crucial data points needed for continuous service improvement. Key consequences include:

  • Skewed Perception of Customer Satisfaction: The customers who respond to surveys are often those with extreme experiences—either very satisfied or very dissatisfied—leading to biased results.
  • Lack of Actionable Insights: Without feedback, service teams struggle to pinpoint systemic issues, making it harder to optimize resolution processes.
  • Reduced Service Improvement Opportunities: Missing customer insights can lead to higher churn rates, as businesses may fail to address recurring pain points.
  • Potential Compliance and SLA Risks: In industries with strict service-level agreements (SLAs), failing to track satisfaction accurately could lead to breaches in customer commitments.

The Solution: AI-Powered Customer Satisfaction Prediction

What if, instead of waiting for customers to respond to surveys, we could predict their satisfaction based on ticket interactions, resolution notes, and historical trends?

Using Generative AI (GenAI), Natural Language Processing (NLP), and machine learning models, organizations can analyze:

  • Customer comments and sentiment in service requests
  • Resolution notes provided by IT support teams
  • Case handling efficiency (e.g., response time, resolution time, escalation history)
  • Previous CSAT scores (if available)

This AI-powered prediction approach allows businesses to fill in the gaps left by non-respondents, providing a more holistic and accurate view of customer satisfaction. By automating satisfaction scoring, organizations can proactively improve service quality, address potential dissatisfaction, and optimize their IT support operations.

Creating a NowAssist Skill

Using ServiceNow and NowAssist skill kits, we can make this solution a reality!

Let’s walk through creating a new Skill in ServiceNow!

Creating new AI skill ‘Customer Satisfaction’

Selecting an AI Model for prompts

For this example, we will start with NowAssistLLM, ServiceNow’s built-in AI model. However, you can use any AI model, such as OpenAI’s GPT-4, by configuring a custom API connection.

Crafting an AI Prompt

To generate a customer satisfaction prediction, we will use a structured AI prompt designed to extract meaningful insights from customer comments and resolution notes.

ServiceNow was kind enough to generate a prompt based on the description we provided for our skill:

## Role You are a customer service analyst. Your task is to derive a customer satisfaction score and identify areas of improvement based on customer feedback and resolution notes. 

## Context
 - Additional comments from the customer: '{{insert_your_input_here}}' 
- Resolution notes: '{{insert_your_input_here}}' 

## Instructions 
1. Analyze the additional comments and resolution notes. 
2. Detect positive and negative sentiments expressed in customer feedback. 
3. Assess the effectiveness of the resolution based on customer sentiment. 
4. Assign a satisfaction score (1 = very dissatisfied, 5 = very satisfied) with a brief justification. 
5. Provide actionable recommendations for improving customer service. 

## Output 
Return a JSON response containing: 
- Satisfaction score (1-5) with a short explanation. 
- Key takeaways from customer feedback. 
- Specific service improvement suggestions.

This structured prompt ensures AI outputs are consistent, making it easy to integrate them into ServiceNow workflows.

Skill Input

We will need to get data from the platform to feed into our prompt. The following data types are available:

  • Record
  • String
  • Numeric
  • Boolean

In this example we will use the record type against the Incident table so we can input fields into our prompt.

Enhancing Predictions with Additional Context

To improve prediction accuracy, we can provide AI with more context, such as:

  • Agent-Customer Transcript: Including the full conversation history allows AI to detect tone shifts and unresolved concerns.
  • Resolution Codes: Providing resolution categories helps AI assess whether similar cases led to positive outcomes.

These enhancements make AI-generated predictions more reliable, helping organizations proactively improve service quality.

We can add this information from our Incident record using the following fields:

  • Resolution notes
  • Resolution code
  • Additional comments

If you are familiar with journal fields, we will need to write a script to parse this out.

Adding a tool

More complicated input can be added to the prompts using Tools. The following can be selected:

  • Flow Action
  • Retriever
  • Script
  • Sub Flow

In this example, we will write a Script to parse the additional comments, splitting it into agent and customer comments.

In the spirit of using GenAI, I used ChatGPT-4o to assist in writing a script to extract customer and agent comments from any given task:

var GetTaskComments = Class.create();
GetTaskComments.prototype = {
    initialize: function () {},

    getComments: function (tableName, recordNumber, callerField, journalField) {
        var grTask = new GlideRecord(tableName);
        if (!grTask.get('number', recordNumber)) {
            gs.info('Record not found in table: ' + tableName);
            return null;
        }

        var callerId = grTask[callerField].getDisplayValue();
        var journalEntries = grTask[journalField].getJournalEntry(-1); // Get all comments
        
        return this.processJournalEntries(journalEntries, callerId);
    },

    processJournalEntries: function (journalEntries, callerId) {
        return this.processEntriesWithCaller(journalEntries, callerId);
    },

    processEntriesWithCaller: function (journalEntries, callerId) {
        var callerComments = [];
        var otherComments = [];

        var entriesArray = journalEntries.split('\n\n'); // Split into individual comment entries

        for (var i = 0; i < entriesArray.length; i++) {
            var entry = entriesArray[i];
            var headerMatch = entry.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} - (.+?) \(Additional comments\)/);

            if (headerMatch) {
                if (headerMatch[1] === callerId) {
                    callerComments.push(entry);
                } else {
                    otherComments.push(entry);
                }
            }
        }

        return {
            callerComments: callerComments,
            otherComments: otherComments
        };
    },

    type: 'GetTaskComments'
};

This part is really cool!

Once we have created our script, we can leverage it by adding a Tool of type Script.

ServiceNow automatically parses all the functions and parameters, allowing you to select parameter input values. This is some amazing tech I would love to see implemented to convert scripts into Flow Actions in future.

Leveraging a script by adding a tool

Let’s modify the prompt to include this additional context.

Inserting inputs from our scripts via Tools

Adding tool outputs to the prompt inputs

GetTaskComments returns an object, so we will need to reference the properties.

## Context
The customers comments: '{{GetTaskComments.output.callerComments}}'
The agents comments: '{{GetTaskComments.output.otherComments}}'
The resolution notes: '{{incident.close_notes}}'
The resolution code:  '{{incident.close_code}}' 

Creating a GenAi-PI prompt

Now let’s modify the instructions and output to return a structured response. This prompt will be a GenAi-PI.

## Instructions
Provide a customer satisfaction score of N/A  if there are no callerComments.

## Output
Output the following JSON, with no explanation of the output:
{
customer_satisfaction_score: 'Guess of customers satisfaction out of 5 based on customer comments. If no comments or cannot determine return N/A',
emoji: 'emoji to represent that customers experience and sentiment'
customer_experience_summary: 'Summary of the customer experience',
areas_of_improvement:'Analyzing the agent's comments of the  {{incident.sys_class_name}}, could communication have been changed to increase customer satisfaction?'
improvement_keywords: 'From the areas of improvement, add an array of keywords that the agent can improve on'
}

Test 1 – No comments

Testing on an incident with no comments. The grounded prompt will show us the raw prompt sent to the LLM, and the response will be the response sent back.

Grounded prompt

## Role
You are a customer service analyst. Your task is to derive a customer satisfaction score and areas of improvement based on the additional comments field and resolution notes.

## Context
The customers comments: '[]'
The agents comments: '[]'
The resolution notes: ''
The resolution code:  '' 

## Instructions
Provide a customer satisfaction score of N/A  if there are no callerComments.

## Output
Output the following JSON, with no explanation of the output:
{
customer_satisfaction_score: 'Guess of customers satisfaction out of 5 based on customer comments. If no comments or cannot determine return N/A',
emoji: 'emoji to represent that customers experience and sentiment'
customer_experience_summary: 'Summary of the customer experience',
areas_of_improvement:'Analyzing the agent's comments of the  incident, could communication have been changed to increase customer satisfaction?'
improvement_keywords: 'From the areas of improvement, add an array of keywords that the agent can improve on'
}

Now LLM Response

{
"customer_satisfaction_score": "N/A",
"emoji": "N/A",
"customer_experience_summary": "No comments provided",
"areas_of_improvement": "N/A",
"improvement_keywords": []
}

OpenAI Response

{

customer_satisfaction_score: 'N/A',

emoji: '😐',

customer_experience_summary: 'No comments provided by the customer',

areas_of_improvement: 'No comments provided by the customer',

improvement_keywords: []

}

It has obeyed my instructions to return N/A when their is no survey, and only return the JSON so we can pretend this is a real API.

Test 2 – Using Demo Data

Prompt

Testing on an incident with customer comments and two agents (INC0000060 on a demo instance)

Demo data conversation on an Incident
Resolution notes
## Role
You are a customer service analyst. Your task is to derive a customer satisfaction score and areas of improvement based on the additional comments field and resolution notes.

## Context
The customers comments: '["2016-12-13 12:30:14 - Joe Employee (Additional comments)\nHi David, \nThat must be it. I was on phone calls at all three of those times and must not have had any activity on my computer. Please close this incident.","2016-12-13 07:53:01 - Joe Employee (Additional comments)\nHi David,\nThank you! I use the corporate VPN and was also unable to connect to the email server at 9:30AM and 10:45AM.","2016-12-12 12:43:50 - Joe Employee (Additional comments)\nHi Beth,\nYes, I'm connected to the VPN, although I've had to reconnect to it a couple of times. The last time I was unable to connect was 2:30PM.","2016-12-12 07:19:57 - Joe Employee (Additional comments)\nI am unable to connect to the email server. It appears to be down."]'
The agents comments: '["2016-12-13 10:42:25 - David Loo (Additional comments)\nHi Joe,\nI've checked in network logs and you were timed out from the VPN at 9:25AM, 10:42AM and 2:28PM. These three times coincide with entries in the exchange server logs showing you lost connection at those same times. The VPN policy is to time out a connection if it hasn't been active in 30 minutes. Please ensure the next time you lose connectivity you are still connected to the VPN.","2016-12-13 06:43:17 - David Loo (Additional comments)\nHi Joe,\nMy name is David. I'll be assisting you with this incident. Can you confirm which VPN you have been using today? I also see you were having this issue at 2:30PM. Were there any other times you can recall you had issues connecting to the email?","2016-12-12 16:56:57 - Beth Anglin (Additional comments)\nHi Joe, \nAs per discussion on call, Workaround has been provided and it has worked for you. I have verified with the Exchange team we haven't had an issue with the email server today. I'm going to assign this issue to the network team for further investigation.","2016-12-12 10:52:42 - Beth Anglin (Additional comments)\nHi Joe, \nAre you connected to the VPN when you're having this issue? Can you identify a specific time you were unable to connect to email?","2016-12-12 08:30:49 - Beth Anglin (Additional comments)\nHi Joe, \nMy name is Beth and I'll be assisting you with your issue."]'
The resolution notes: 'This incident is resolved.'
The resolution code:  'Solved (Permanently)' 

## Instructions
Provide a customer satisfaction score of N/A  if there are no callerComments.

## Output
Output the following JSON, with no explanation of the output:
{
customer_satisfaction_score: 'Guess of customers satisfaction out of 5 based on customer comments. If no comments or cannot determine return N/A',
emoji: 'emoji to represent that customers experience and sentiment'
customer_experience_summary: 'Summary of the customer experience',
areas_of_improvement:'Analyzing the agent's comments of the  incident, could communication have been changed to increase customer satisfaction?'
improvement_keywords: 'From the areas of improvement, add an array of keywords that the agent can improve on'
}

NowLLM Response

{
"customer_satisfaction_score": "4",
"emoji": ":thumbsup:",
"customer_experience_summary": "The customer experienced issues with connecting to the email server and VPN, but the issue was resolved. The customer was satisfied with the resolution and the assistance provided by the agents.",
"areas_of_improvement": "The agent could have provided more proactive communication to the customer about the VPN policy and the reason for the timeouts. This could have helped the customer understand the issue better and take necessary actions to prevent future timeouts.",
"improvement_keywords": ["proactive communication", "VPN policy explanation"]
}

OpenAI Response

{
customer_satisfaction_score: 3,
emoji: '😐',
customer_experience_summary: 'The customer experienced issues with connecting to the email server while using the corporate VPN. The issue was resolved, but the customer was not satisfied with the overall experience.',
areas_of_improvement: 'The customer may have been more satisfied if the agent had provided more clear and timely communication about the issue and potential solutions.',
improvement_keywords: ['communication', 'timeliness', 'clarity', 'solutions']
}

Which response do you prefer?

Publishing & Deployment

You can publish as a UI action or Now Assist Panel via Skill Setttings > Deployment Settings >Allow the Admin to enable this skill from the following . We will publish it as a UI action.

This will generate some code for you to use:

var inputsPayload = {};
// incident is a input of type: glide_record
inputsPayload['incident'] = {
  tableName: 'incident',
  sysId: current.getValue('sys_id'),
  queryString: ''
};

var capabilityId = '9cf9134c93a06a50147ef8847aba10f6'; 
var request = {
	executionRequests: [{
		payload: inputsPayload,
		capabilityId: capabilityId,
		meta: {
			skillConfigId: '20f9534c93a06a50147ef8847aba1025'
		}
	}], 
	mode: 'sync' 
};

try {
	var response = sn_one_extend.OneExtendUtil.execute(request) || {}; 
	var skillResponse = ((response["capabilities"] || {})[capabilityId] || {})["response"]; 
	gs.addInfoMessage(JSON.stringify(skillResponse));
} catch(e) {
	gs.error(e);
	gs.addErrorMessage('Something went wrong while executing skill.');
}
action.setRedirectURL(current);

The UI action is disabled by default and must be activated. I’ve activated it and made it red to stand out.

I was not able to switch it to use the OpenAI prompt after the initial skill was created with NowLLM.

With some window dressing, this could be quite useful to your Service Management team at scale.

Final Thoughts

Integrating Generative AI with ServiceNow opens up endless possibilities for automation, enhanced customer service, and improved decision-making. Whether you’re using NowAssist or building a custom AI solution with third-party APIs, structuring AI prompts effectively can turn AI models into powerful tools for predictive analytics and workflow automation.

The concept of GenAI-PI—treating generative AI responses as structured API outputs—enables businesses to harness AI insights in a predictable and actionable manner. By applying this approach to customer satisfaction prediction, organizations can bridge gaps in survey participation and proactively enhance service quality.

As an avid user of GenAI in IDE’s for scripting in ReactJS and NodeJS, I am yet to be blown away by any particular ServiceNow product-specific NowAssist skills.

However, the NowAssit Skill Kit has genuinely impressed me. This is some really cool technology, bring custom AI generation and low code together, with enough tools for pro coders.

The key challenge remains with GenAI; finding a good use case, and having good data to input. This continues to be elusive.

TL;DR

  • NowAssist provides built-in AI tools (Skill Kit, GenAI Spoke) for easy integration with ServiceNow.
  • Without NowAssist, you can connect AI via REST APIs and scripted integrations.
  • GenAI-PI treats AI responses as structured API outputs, making AI interactions predictable.
  • Use Case: AI can predict customer satisfaction from ticket interactions, reducing reliance on surveys.
  • Implementation: Structured AI prompts + contextual data (customer comments, resolution notes) improve accuracy.
  • ServiceNow UI Action: Deploy AI skills as UI actions to integrate AI insights seamlessly.
  • Big Picture: AI-powered automation in ServiceNow is possible.

Related Posts

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More