Update urgency of an incident when end user wants to escalate incident via VA chatbot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 05:53 AM
Hello Everyone
Recently I got one requirement of urgency of an incident must be updated as high when end user selects as Yes for a question "Would you like to escalate this ticket ?" in Virtual agent chatbot.(Topic name is Check IT Ticket Status) (please refer attached screenshots)
Could anyone help me with a script to achieve this requirement ?
Thanks in advance
Nagurbee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 05:31 AM
Hi @Nagurbee1
Please proceed with the steps below:
Step 1: Modify or Create Virtual Agent Topic
First, ensure you have a Virtual Agent topic that either already handles checking the IT ticket status or create a new one if necessary. Within this topic:
1. Ask the Escalation Question: Use a “User Response” node to ask the user if they would like to escalate their ticket. For simplicity, let’s assume you set the response options to “Yes” and “No”.
2. Handle the “Yes” Response: Use a “Choice” or “Decision” node following the “User Response” node to branch the conversation based on the user’s answer.
Step 2: Script to Update Incident Urgency
If the user selects “Yes”, you’ll want to execute a server script to update the incident. In the Virtual Agent Designer, this is typically done using a “Script” node after the decision to escalate has been made
(function process(inputs, outputs) {
// Assuming ‘inputs.incidentSysId’ is the sys_id of the incident to be updated.
var incidentSysId = inputs.incidentSysId; // Ensure you have a way to pass this correctly.
if (!incidentSysId) {
// Handle error or fallback if the incident Sys ID isn’t provided
outputs.error = true;
return;
}
var gr = new GlideRecord('incident');
if (gr.get(incidentSysId)) {
gr.setValue('urgency', '1'); // Set urgency to ‘High’. Ensure ‘1’ corresponds to ‘High’ in your instance.
gr.update();
// Output success if incident was updated
outputs.error = false;
outputs.result = "Incident urgency updated to High.";
} else {
// Handle case where incident isn’t found
outputs.error = true;
outputs.result = "Incident not found.";
}
})(inputs, outputs);
Inputs and Outputs:
- You’ll need to ensure your Script node has the necessary inputs (like the incident sys_id) and outputs (to send back whether the operation was successful or any error occurred).
Step 3: Collect and Pass Incident Sys ID
Ensure that during the conversation flow, you’re correctly capturing and passing the Incident sys_id to the Script node. This might involve additional steps or nodes in the Virtual Agent Designer to capture the user’s incident details and extract the relevant sys_id.
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 02:03 AM
Hello Deepak
Thank you so much for the given solution.
I have used the script given by you but unable to get the output.
May be I'm not passing the sys id's correctly, if possible from my screenshots could you please suggest that in which step I can find those sys id's to update into a script provided by you ?
Thanks in advance
Nagurbee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 09:24 PM
Hi @Nagurbee1
Please follow these steps to easily tackle the requirement. Add a Script Action Node
Based on the user’s response, you’ll need to add a Script Action node after the User Response node to evaluate the response and update the incident if necessary.
1. Insert a Script Action: After the question node, add a “Script Action” node where you’ll write the logic to update the incident’s urgency.
2. Configure the Script: In this node, you will access the incident related to the chat and update its urgency if the user selected “Yes.”
(function process(/ResolverEnvironment/ env) {
// Assuming ‘escalateResponse’ is the variable capturing the user’s response
var escalate = env.getFlowVariable('escalateResponse');
var incidentId = env.getFlowVariable('incidentId'); // Assuming you have the incident Id stored in a variable
// Check if the user wants to escalate the ticket
if (escalate === 'Yes') {
// Retrieve the incident record
var incidentGR = new GlideRecord('incident');
if (incidentGR.get(incidentId)) { // Ensure the incident exists
// Update the urgency to High. Assuming ‘1’ represents High urgency in your setup
incidentGR.setValue('urgency', '1');
incidentGR.update(); // Save the changes
// Optionally, you can add a confirmation message to inform the user of the escalation
env.setFlowVariable('escalationConfirmation', 'Your ticket has been escalated.');
}
}
// You might want to handle the case where the user selects “No” or the incident cannot be found/updated
})(env);
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 02:29 AM
Urgency = how quickly should something be resolved.
Changing Urgency automatically changes the priority of an incident. Why would you allow end users to update the priority of an incident through code? Any issue an end user has, is of high priority and every incident from them should be resolved first. Isn't it better to update a 'needs attention' field, so it can objectively be reviewed by the assignment group to validate if impact and urgency are correctly set and if the ticket is in the correct place in the queue?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark