Get name of person who updated ticket (from activity section) | XM Community
Skip to main content

Hi All,
I'd like to build a script that detects if a ticket has been assigned to a person. If it hasn't, I want to email the person.

For example, the person makes a change to a ticket (eg adds a comment or completes the follow-up questions) but forgets to assign the ticket to themselves.

I noticed that when someone adds a comment to the ticket, the change is noted in the activity section of the ticket with the person's name and what they changed. Is there an API called to grab this info in order to retrieve the person's name to then send them an email reminding them that they need to assign the ticket to themselves?
I found an API called 'CommentEventDetails' but it looks rather empty in the Qualtrics API resources webpage (https://api.qualtrics.com/instructions/c2NoOjYwNzc4-comment-event-details) so perhaps that won't work?
Any advice would be most welcome.
Thanks
Rod Pestell

Hello Rod_Pestell

You can use the Retrieve events for a ticket call to retrieve the current status:
https://api.qualtrics.com/api-reference/b3A6NjExMjU-retrieve-events-for-a-ticket
You can use the retrieve tickets for account in order to get details of all tickets currently in your account:

https://api.qualtrics.com/api-reference/b3A6NjExMTk-retrieve-tickets-for-account


Hi Aanurag_QC ,

Thanks for the reply. Can you confirm the API method retrieves the activity text where you can parse out the person's name? The API links you included don't seem to talk about that. Unless I've not understood the API page?
Thanks
Rod Pestell


https://api.qualtrics.com/api-reference/b3A6NjExMjU-retrieve-events-for-a-ticket This call will help you retrieve all events within the ticket. If you want to update user name, then you will be required to use a PUT call : https://api.qualtrics.com/guides/b3A6NjExMjE-set-statuses

Your flow would look something like below:

1) Fetch data of all tickets: https://api.qualtrics.com/api-reference/b3A6NjExMTk-retrieve-tickets-for-account
2) Retrieve events for a ticket call to retrieve the current status: https://api.qualtrics.com/api-reference/b3A6NjExMjU-retrieve-events-for-a-ticket
3) Update ticket: https://api.qualtrics.com/guides/b3A6NjExMjE-set-statuses


Hi Aanurag_QC
I've had a look at the different API calls and tested a few. The header is being clipped though when I ask it to return the info on the screen (using powershell console at the moment). It's not showing me all the detail in the content section. I'm very new to using and working with API requests so please could you advise as to how I get round that so that I can check the info I need is included?

Powershell script run from the powershell console:
$headers=@{}
$headers.Add("Content-Type", "application/json")
$headers.Add("X-API-TOKEN", "_________")
$response = Invoke-WebRequest -Uri 'https://eu.qualtrics.com/API/v3/tickets/T-3234/events' -Method GET -Headers $headers
return $response

This is what it returns (I've redacted some ID's)
StatusCode        : 200
StatusDescription : OK
Content           : {"result":{"elements":e{"ownerId":"UR_b1mc_____RMtxA","eventType":"STATUS_CHANGED","createdAt":"2021-09-20T10:38:37.000Z","eventDetails":{
                    "oldStatusId":0,"newStatusId":5}},{"ownerId":"UR_3aNV___405...
RawContent        : HTTP/1.1 200 OK
                    request-time: 312
                    x-frame-options: DENY
                    x-permitted-cross-domain-policies: master-only
                    x-xss-protection: 1; mode=block
                    x-envoy-upstream-service-time: 316
                    referrer-policy: strict-...
Forms             : {}
Headers           : {request-time, 312], :x-frame-options, DENY], x-permitted-cross-domain-policies, master-only], {x-xss-protection, 1; mode=block]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 2642


I did try adding the below on the end of the $response line in case formatting it into a tabular form would help but it came back saying 'Cannot send a content-body with this verb-type'. I don't know why as it's worked in the past. Again I'm new to API. :(
b adding the below Invoke-WebRequest line
-ContentType 'application/json' -Body '{ "format": "csv"}'

FYI: This is what I've trying to pick out (see screen shot below), It's a comment that was made by a person in the ticket activity section. My aim is to parse out the person's name, check to see if the ticket has been assigned to a person and if not assign it to Olivia by finding the email address and then using a PUT command to assign it.
image.pngI think I am somewhat simplifying the process here and assume there are quite a few hurdles I need to work out but I've got to start somewhere.

Hope you can advise
Thanks
Rod


https://api.qualtrics.com/api-reference/b3A6NjExMjU-retrieve-events-for-a-ticket

This call has a result output called event details which will give you the exact detail that you highlighted in the screenshot.

I am not too sure about Powershell myself as I use postman. However, the link mentioned should meet your requirements:

image.png




ok, so I am using the correct API call then. I just need to know how to parse the data from the JSON data. I think the problem I am needing to resolve is something to do with pagination in my script. I will have to find some example of how you do that as a first step so that I can then pull out the correct field with the name in.
I'm restricted to using powershell at present as I don't have any other programming software. I've got VBA or Powershell at my disposal. Is there an online version of Postman as that would let me easily see the full JSON string no doubt without me having to mess around with Powershell.

Thanks

Rod


Leave a Reply