Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Save satisfaction comments in a custom field

As tracked at JSDCLOUD-4317, Jira Service Management's CSAT survey comments are not searchable via JQL. This article introduces a workaround to make them accessible via a custom field.

 

(0) Backdrop

Skip ahead to section (1) if you are not interested in the peripheral context.

You can browse the available Smart Values at the issue URL like https://SAMPLE.atlassian.net/rest/api/2/issue/EX-5?expand=names; however, there's no field holding the survey comment value. Refer to Find the smart value for a field for more details.

Although this article introduces an approach with REST APIs, it's error-prone due to some constraints. So please make a careful decision whether to implement the rule considering the benefits vs. cost of operations.

 

(1) Preparation

First things first, you always need to have credentials when you do something important:

  1. Issue an API token of site-admins account at https://id.atlassian.com/manage/api-tokens
  2. Encode your credentials "$EMAIL_ADDRESS:$API_TOKENwith base64 as (1-2) Example below. Or go with any online tool like Base64 Encode. Make sure not to include a line break at the end.
    • base64encode.png

 

(1-2) Example - How to encode your API token

$ echo -n "site-admin@example.com:123e4567-e89b-12d3-a456-426614174000" | base64
c2l0ZS1hZG1pbkBleGFtcGxlLmNvbToxMjNlNDU2Ny1lODliLTEyZDMtYTQ1Ni00MjY2MTQxNzQw
MDA=

 

(2) Project prep

Make sure to have a custom field to save the values. For example:

  1. Create a custom field named "Satisfaction comment"
  2. Assign the custom field to the target issue types

 

(3) Create a rule

Here's the overview:

  • Trigger: Field value changed
    • Fields to monitor for changes: Satisfaction date
  • Action: Re-fetch issue data
  • Action: Send web request
    • Web request URL: {{baseUrl}}/rest/api/2/issue/{{issue.key}}/properties/service-request-feedback-comment
    • Headers:

      • AuthorizationBasic <The output we got from (1-2)>
  • Action: Create variable
    • Variable name: satisfactionComment
    • Smart value: {{webhookResponse.body.value.comment}}
  • Action: Edit issue
    • Selected fields: Satisfaction comment
    • Value: {{satisfactionComment}}

Screen Shot 2022-04-12 at 16.21.59.png

(5) Commentaries

When a customer selects the satisfaction rate in the email, the rule will be triggered because the "satisfaction date" is changed. Then the web request receives a 404 error due to the lack of comment. Feel free to add a comment if you find any solution for this symptom.

Screen Shot 2022-04-12 at 15.48.51.png

Besides, the edit issue action can cause the following error:

Found multiple fields with the same name and type

In that case, you can go with the additional fields like below:

{ "fields": { "customfield_10003": "{{satisfactionComment}}"} }

Refer to Advanced field editing using JSON for more details.

3 comments

Chris McCullough
Contributor
November 16, 2022

@K_ Yamamoto thank you very much for the write up on this! I'm having some trouble with adding the webhook response to the log though. I'm using the following for the log message: webhookResponse.body={{webhookResponse.body}}

 

But that only returns: webhookResponse.body=

However, in the webhook response payload I am getting back the following:

{
  "key": "service-request-feedback-comment",
  "value": {
    "comment": "Agent was very helpful"
  }
}

 

 Since I'm getting a valid response in the webhook, why would the log message not return the body/value of the comment?

 

Edit: Actually, I figured this out this morning. I had forgotten to check the box in the Send Web Request action to "Delay execution of subsequent rule actions until we've received a response for this web request". Once that was checked the satisfaction comment started being logged and added to my custom field.

OMAR MOHAMED AHMED MOHAMED FATHY
Contributor
October 11, 2023

add this smart value 

{{issue.properties.service-request-feedback-comment.comment}}

Like Anju likes this
Diego Borba
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 14, 2024

An alternative is creating automation with the trigger "Incoming webhook".

Then add a webhook for the Entity property (Created or updated).

In the URL add a query parameter with the issue key.

 

?issue={issue.key}

 

webhook.png

Use the following smart values to retrieve the issue key and the survey comment:

{{triggerIssue.key}} // {{webhookData.property.value.comment}}

automation.png

 

This configuration will trigger the automation when a property is set to the issue. Additional steps may be applied (e.g ensure the property key is service-request-feedback-comment).

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events