When building automation rules in Jira that interact with AI tools or external services, you may receive a response that contains JSON and want to use it in Jira Automation.
This is my pains trying and thought I would share them...
||My first attempt was to split the two parts with a delimiter ( || ) and then split the string in a smart value, but Jira Automation was being a pain and values were not separated as expected.
I initially structured the AI response like this:
The issue described in the ticket Access to USB drives required is similar to a previously resolved service request. This suggests that it is not a widespread problem affecting many users. Therefore, I would assign a **Medium** priority to this issue. It causes inconvenience or impacts productivity, but a workaround likely exists, and it does not prevent work from continuing entirely. || MediumI tried to extract the priority with:
{{agentResponse.split("||").get(1).trim()}}However, this returned empty values. you probably can do it with the split() functionality but I lost patience and it seemed to work inconsistently when extra whitespace, formatting or smart values are involved. I found it brittle, especially when AI responses included line breaks or HTML formatting. This led me to look for a more reliable approach.
A robust solution is to have your AI or web service return a JSON object rather than a delimited string. For example:
{
"reasoning": "The issue 'Unable to Print' is reported as a single‑user problem with no evidence of a system-wide outage or multiple users affected. Similar past tickets have been resolved with Medium or High priority, but none indicated a business-wide impact. Therefore, the appropriate priority is **Medium**: it impacts the user's productivity but does not block the entire team or business from operating.",
"priority": "Medium"
}I created a second variable that converts the string into an object:
parsedResponse{{jsonStringToObject(preResponse)}} ## A I am using a variable I put the {{agentResponse}} in firstThe function jsonStringToObject converts a string into a JSON object that Jira can traverse.
Then tried Referencing the fields
{{parsedResponse.priority}}{{parsedResponse.reasoning}} This then just returned Blank Values
I created a individual variables that converts the string into an object:
Priority{{jsonStringToObject(preResponse).priority}}Reasoning{{jsonStringToObject(preResponse).reasoning}}


{{Priority}}. This sends only the name of the priority to Jira{
"fields": {
"priority": {
"name": "{{Priority}}"
}
}
}If something doesn’t work, use the #debug helper to inspect variables in the audit log:
{{#debug}}{{jsonStringToObject(preResponse).reasoning}}{{/}}This writes the value to the audit log so you can see exactly what Jira is reading.
Hope this helps someone and saves them several hours trying to get it to work.
Aaron Haydon
1 comment