AI‑Driven Knowledge Automation with Now Assist: Eliminating Tickets and Empowering User Self‑Service
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Use Case and Requirements
This implementation shows how ServiceNow can automatically generate knowledge articles from resolved conversations, helping users solve common issues without requiring agent assistance.
When the solution is first provided to the user with a live agent, then from the next time it creates a documentation or knowledge article. This helps solve the same issue faster, reduces human effort, and speeds up processes. It also makes them efficient using AI.
We achieved this using Now Assist. We integrated the Now Assist skill in the workflow, which triggers after the chat ends. Based on messages in the chat, it finds the sentiment (positive, neutral, or negative). If it is positive, then based on the chat and interaction, it creates a detailed matter explaining how we solved that problem.
Few points and tables we used are:
- For every interaction, it creates a record in the sys_cs_conversation table. After the chat ends, its state changes to completed.
- Every message is recorded in the sys_cs_message table in the payload field. This table is made as a related list to the above table, so we just need the conversation sys_id to get all messages.
- In the sys_cs_message table, the message is stored in a complex JSON object structure, which I have given below.
- These tables can be potential inputs for the custom skill. Using them, we get sentiment and messages. For that, we write the prompt efficiently.
- How we get all messages from complex JSON objects and how we find sentiment is explained more in the custom skill tool implementation.
Implementation
The basic structure for this implementation is:
- Create trigger in flow (when chat ends).
- Add custom skill we implemented (add input to it).
- Create skill to get sentiment and article text before adding it to flow.
- Extract info in output from skill.
- Create an article and fill it.
1. Skill Implementation
Remember, we extract messages, and then from them, we need to find sentiment and resolution steps of that problem.
Add input as sys_cs_conversation table record. This record has basic details about the conversation like who opened it, state of chat, channel of contact, and it also has list of messages as related records.
Now we need all message records associated with this conversation record because they have the actual messages to analyze , So we use the Script Tool.
Adding SCRIPT TOOL
- In the script tool, based on the conversation record, we fetch all message records associated using GlideRecord.
These message records have the payload field, which has a complex JSON object. In this object, we get the actual message. - The payload JSON object looks like this:
- This is the script I used. It takes all the above objects and puts them in an array. Now we have an array of payloads. These can be passed to the prompt.
- (function runScript(context) {/* @Param {Object} context - Execution context, which may include:*//* - Previous tool outputs/inputs (e.g., context['ToolName.attributeName'] or context.getValue('ToolName.attributeName')).*//* - Additional context information (e.g., context.getAllValues()).*//* @returns {Object} - The computed value for the attribute.*/// glide messages table and fetch datavar msgs = new GlideRecord("sys_cs_message") ;msgs.addQuery("conversation" , context['getconvoid.convo_id']) ;msgs.query() ;var arr = [] ;while(msgs.next()){arr.push(msgs.payload) ;}return arr ;})(context);
- We can access other tool data using:
context[toolname.attributename] in script.
Note: Here in the script, we cannot put only message text in the array, but the overall payload object. We write the prompt to analyze text from it.
Prompt
- We define clearly the role, context, goal, and output format.
- We pass the objects array (created in script tool) to the prompt. We tell the LLM to extract only message text from objects in the array.
- To help the LLM, we give the payload structure present in array objects, so it does its work better.
- Specify the output as a JSON object. It only has sentiment and article body.
- This output is returned to the flow, and we fetch sentiment and article text from it.
This is the main part of prompt to use :
"
# ROLE
You are a precise conversation analyst and knowledge author. Given a full chat session as an array of message objects, you will:
1) Infer the end-user’s overall sentiment for the conversation (Positive | Negative | Neutral), and
# CONTEXT
- Conversation metadata (for reference only; sentiment must come from message content):
- conversation_id: {{conversation.sys_id}}
- channel: {{conversation.device_type}} # e.g., Web, Teams
- Messages array (ANALYZE ALL):
messages = {{MsgObjects.output}}
Each element in messages follows this (or very similar) structure:
{
"uiType": "OutputText" | "InputText" | "System" | "...",
"model": {
"type": "outputMsg" | "inputMsg" | "event" | "...",
"name": "string" # e.g., "fieldAck.__silent_OutputPrompt_..."
},
"plainTextMessage": "string", # may be present for display text
"value": "string", # often duplicates visible text; prefer this if present
"hideControl": false,
"uiMetadata": {...}, # UI-only metadata (ignore for sentiment)
"shouldSkipTranslation": false,
"shouldForceTranslation": false,
... # other fields may exist; treat as non-semantic unless clearly textual
}
IMPORTANT TEXT EXTRACTION RULES:
- For each message object, extract the user-visible text in this priority order:
1) `plainTextMessage` if non-empty , this is actual chat text u ahve to analyze for sentiment,
2) else ignore (no visible text for sentiment).
"
Flow Creation
1. Trigger
- Based on the use case, when chat ends, the flow should trigger.
For this, use update record trigger and table sys_cs_conversation. - Write a condition: state changes to completed.
2. Add Custom Skill
Add the custom skill we created earlier. It is present in the “Now Assist Skill Kit” section
It expects an input record. Drag the conversation record from the trigger data pill.
Extract Data from Skill Response
- The response we get from the skill action is a complex object and stringified. It has several layers of attributes.
- According to the output specified in the prompt, our response looks like this:
Creating Flow Variables
Extract info from skill response using script and put them in variables:
- Sentiment variable: JSON.parse(JSON.parse(fd_data._1__execute_skill.output.response).model_output).sentiment ;
- Article body variable: JSON.parse(JSON.parse(fd_data._1__execute_skill.output.response).model_output).knowledge_article ;
Creating Article
- We have sentiment. This is given by the LLM based on chat text.
If it is positive, then the user got the solution.
Using an IF block, check sentiment and create an article. - Our custom skill also gives resolution steps and article text clearly based on chat.
We store this in a flow variable. Using this variable, we create a knowledge article.
FOLLOW UP :
1. instead of directly creating article we check whether already article exists or not ?
2. using IF like conditional flows in now assist skill we can first find article existence using retriever or PI then based on that we can move skill and in skill response use 1 more info that "isExisted" to know about it
3. if any one knows how to search existence of an article for particular problem let me know and reply we can implement
