Search with Incident or Request number in Virtual Agent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 03:05 AM
Hi All,
There is a requirement that if we search with the incident or a Request no. in Virtual Agent chat then it should give us few details like short description, description, etc. about that ticket.
Is this functionality possible in ServiceNow Virtual Agent?
Please help me to resolve the same.
Regards,
Sakshi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 04:11 AM
Hi @Sakshi Lambat ,
Yes, it is possible to create a functionality in ServiceNow Virtual Agent that allows users to search for Incident or Request details by entering a ticket number. Below are the detailed steps for configuring this functionality:
Step 1: Create a Virtual Agent Topic
1. Navigate to Virtual Agent Designer:
- In the ServiceNow application navigator, type Virtual Agent Designer and select it.
2. Create a New Topic:
- Click on Create New Topic.
- Name your topic "Search Incident/Request Details" and provide a description for future reference.
3. Define Triggers:
- Under the Triggers tab, add phrases that will invoke this topic, such as:
- "Search incident"
- "Find ticket"
- "Request details"
- "Get incident status"
- "Find request by number"
Step 2: Build the Conversation Flow
1. Add a User Input Node:
- Drag and drop a User Input node into your flow.
- Set the prompt message to ask the user for their ticket number. Example prompt:
- "Please provide the Incident or Request number."
- Create a new variable, for example, `ticketNumber`, to store the user’s input.
2. Add a Script Action Node:
- Drag and drop a Script Action node below the User Input node.
- Configure the Script Action to execute server-side code that will look up the ticket details.
Sample Script for the Script Action Node:
(function executeScript(inputs, outputs) {
var ticketNumber = inputs.ticketNumber; // User input from the Text variable
var gr;
// Determine if it's an Incident or Request based on the number prefix
if (ticketNumber.startsWith('INC')) {
gr = new GlideRecord('incident'); // Incident table
} else if (ticketNumber.startsWith('REQ')) {
gr = new GlideRecord('sc_request'); // Request table
} else {
outputs.result = "Invalid ticket number. Please provide a valid Incident (INC) or Request (REQ) number.";
return; // Exit if the number is invalid
}
// Query the table for the provided number
if (gr.get('number', ticketNumber)) {
// If a record is found, output the necessary details
outputs.short_description = gr.getValue('short_description');
outputs.description = gr.getValue('description');
outputs.state = gr.getDisplayValue('state'); // Use display value for better user understanding
} else {
outputs.result = "No record found for the provided ticket number.";
}
})(inputs, outputs);
Step 3: Define Output Variables
1. Add Output Variables:
- Under the Script Action node, define output variables:
- short_description: to hold the short description of the ticket.
- description: to hold the full description.
- state: to hold the current state of the ticket.
- result: to handle any messages about invalid input or ticket not found.
Step 4: Display the Output to the User
1. Add a Display Message Node:
- Drag and drop a Display Message node below the Script Action node.
- Set up the message to show the user the ticket details retrieved by the script.
Example Display Message Template:
Here are the details for {{ticketNumber}}:
- Short Description: {{short_description}}
- Description: {{description}}
- State: {{state}}
2. Handle Error Cases:
- You can add a condition to check if the `outputs.result` is set, and if it is, display that message instead of the details.
Step 5: Test the Topic
1. Publish the Topic:
- After completing the setup, ensure to Publish the topic.
2. Test in Virtual Agent:
- Open the Virtual Agent interface.
- Test the topic by entering valid and invalid Incident and Request numbers.
- Ensure that the bot returns the correct information or appropriate error messages.
By following these detailed steps, you can successfully create a Virtual Agent topic in ServiceNow that allows users to query details about incidents or requests using their ticket numbers.
Regards,
Siddhesh Jadhav
Please test this setup and see if it works. If it does, don't forget to mark this as helpful and accept the answer!