Automatically Creating ServiceNow Tickets Using Edge DX

One of the ways that companies strive to do more with less is with automation. I have written a few articles on using ControlUp Edge DX regarding Unified Communications. In those articles, you would need to monitor the Edge DX dashboard to see issues affecting end users’ experience with their UC applications. Edge DX’s powerful automation engine addresses common problems, with manual Edge DX’s tools available for less common issues.

While correcting problems is essential, it’s only one part of the process – we also need to be notified of problems when they occur when we are away from the dashboard so that a helpdesk ticket can be created and assigned to the right group or person to assist, or, in the case of totally-automated fixes, to document that a problem has been detected and resolved.

CRM Customer Engagement Center (CEC) companies like ServiceNow (SNOW) and Zendesk are the backbone of many help desk workflows. In these systems, a reported problem creates a new ticket containing all data gathered during the investigation. The ticket is closed once a solution is determined. However, the problem with this process is that ticket management (i.e., opening, adding information to, and closing tickets) takes time that is better spent solving the issue rather than documenting it.

To automate this process, CRM companies have an API that allows for the programmatic management of tickets. Likewise, advanced and modern products like Edge DX that can detect and automatically correct issues can use these same APIs to document what they have done.

ControlUp is working hard at implementing integration with ServiceNow and other CEC companies into Edge DX and expects full integration in the first half of 2023. However, until that happens, I will show you a rather simplistic example (with code snippets) of how Edge DX can use the SNOW APIs to create a SNOW ticket.

As a disclaimer, I am not a PowerShell programmer. I can, however, take snippets of code and get them to work to solve a problem; that is what I did for this article. As such, you will want to inspect the code in the article and modify it to meet your needs and your company’s standards.

The Code

I used PowerShell with the SNOW API to create a new ticket from Edge DX when MS Teams had a mid-call failure. I needed my SNOW user ID, password, and account number to do this. The code I came up with is as follows

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 # This line is added automatically to help with Unicode characters. Please add your code below 
$username = "admin"
$password = "xxpaswordxx"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Authorization", "Basic $base64AuthInfo")
$body = "{
`n `"short_description`": `"Teams Mid call failure - Opened by Edge DX`",
`n `"description`": `"Mid Call Failure detected in teams`",
`n `"short_description`": `"Please use Edge DX to view Teams mid call failure`",
`n `"work_notes`": `"Ticket opened automatically by Edge DX`",
`n `"urgency`": `"1`",
`n `"impact`": `"1`"
`n}"
$response = Invoke-RestMethod 'https://dev666.service-now.com/api/now/table/incident' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
Write-Output("### SIP EVENT BEGINS ###")
Write-Output "SNOW Ticket opened for Low Wifi signal detected"
Write-Output("### SIP EVENT ENDS ###")

The code should be self-explanatory with just a few exceptions: `n is used to append a new line to the standard output, and the information between the SIP EVENT code writes to the Device Output screen in Edge DX. 

I set up an alert to execute this script whenever a Windows system had a BSOD. BSOD are logged in Edge DX in the win_event_log data index in the event_id field with a value of 41.

I tested it by manually running it on a Windows machine.

After doing this, SNOW created a new ticket from a mid-call failure occurrence.

When I opened the call, I could see that the ticket was populated with the information prescribed by the script.

I was surprised at how easy it was to create a SNOW ticket programmatically after a Teams call had a failure.

This was a rather simplistic example of just opening a SNOW ticket. Going further, I could enhance self-healing by using Edge DX to perform a workflow like this:

  1. Create a new SNOW ticket automatically when a condition occurs.
  2. Automatically copy the dump file to a central location.
  3. Instantiate an action to correct the problem or apply a patch to the system.
  4. Update the SNOW ticket.
  5. Verify that the action did solve the problem. If yes, close the ticket; if not, update the ticket so that the problem can get additional attention.

The scenario above wouldn’t require any manual intervention or interaction.

Automation of tasks is driving us to work smarter, including tools such as SNOW’s API to create and manipulate tickets.

More information:

About the author

Tom Fenton

Tom Fenton is a Technical Marketing manager here at ControlUp (in addition to an all-around great guy). He’s THE subject matter expert for Edge DX, our physical endpoint monitoring solution, as well as an expert in all things VMware (FACT: he used to work at VMware, teaching their employees about their technology). He creates valuable, educational content for the ControlUp blog, leads deep-dive webinars, and educates our sales teams and other IT professionals with tips and tricks about how to use ControlUp solutions. In his spare time, he writes for StorageReview.com and Virtualization Review magazine, and enjoys outdoor sports in the Pacific Northwest. Connect with him on Twitter @vDoppler.