- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 11:24 AM
How do I proceed to parse the response in Flow Designer to capture a specific attribute. I would like to store the value of "CONTACTS_IN_QUEUE" and "OLDEST_CONTACT_AGE" in their own custom fields.
{
"metric_results": [
{
"Collections": [
{
"Metric": {
"Name": "CONTACTS_IN_QUEUE",
"Unit": "COUNT"
},
"Value": "0"
},
{
"Metric": {
"Name": "OLDEST_CONTACT_AGE",
"Unit": "SECONDS"
},
"Value": "0"
},
{
"Metric": {
"Name": "AGENTS_AVAILABLE",
"Unit": "COUNT"
},
"Value": "1"
},
{
"Metric": {
"Name": "AGENTS_ON_CONTACT",
"Unit": "COUNT"
},
"Value": "4"
}
],
"Dimensions": {
"Channel": null,
"Queue": {
"Arn": null,
"Id": null
}
}
}
]
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 10:31 AM
Hi @heathers_
Add a script step in Flow action with input of your response, create output variable and store these values in output variable from this script.
You can access output variables in your main flow by data pills
(function execute(inputs, outputs) {
var responseObj = JSON.parse(inputs.responseBody);
var collections = responseObj.metric_results[0].Collections;
var contactsInQueue = null;
var oldestContactAge = null;
for (var i = 0; i < collections.length; i++) {
var metricName = collections[i].Metric.Name;
var value = collections[i].Value;
if (metricName === "CONTACTS_IN_QUEUE") {
contactsInQueue = value;
}
if (metricName === "OLDEST_CONTACT_AGE") {
oldestContactAge = value;
}
}
outputs.contacts_in_queue = contactsInQueue;
outputs.oldest_contact_age = oldestContactAge;
})(inputs, outputs);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 05:29 PM
hi @heathers_ ,
In Flow Designer, the first step is to make sure the JSON response you receive is properly parsed so you can work with it as data. Usually, you do this by adding the Parse JSON action. This takes the raw response body from your REST step (often stored in a variable like Response Body) and converts it into a structured object that Flow Designer can read and navigate.
Once you have the parsed JSON, you'll notice that the data you need – CONTACTS_IN_QUEUE and OLDEST_CONTACT_AGE – are inside the metric_results list, under its first item, and then further inside a list called Collections. To extract these values, the common approach is to add a For Each loop in your Flow. In the For Each step, set the list to metric_results[0].Collections. This way, Flow Designer will go through each metric in that list one by one.
Inside the loop, add If conditions to check which metric you’re looking at. For example, check if the field item.Metric.Name equals CONTACTS_IN_QUEUE. When this condition is true, you can then add a Set Values action (or whichever action fits your Flow) to store item.Value into your custom field, like u_contacts_in_queue. Do the same for OLDEST_CONTACT_AGE by adding another If condition and then setting its value to your other custom field.
This method works because Flow Designer can’t directly “pick” a specific item out of a list based on a condition. Instead, you loop through each item and check if it’s the one you care about. Once it matches, you store the value you need. If the value is stored as text and you need it as a number, you can also add a step to convert it to an integer before saving.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 10:31 AM
Hi @heathers_
Add a script step in Flow action with input of your response, create output variable and store these values in output variable from this script.
You can access output variables in your main flow by data pills
(function execute(inputs, outputs) {
var responseObj = JSON.parse(inputs.responseBody);
var collections = responseObj.metric_results[0].Collections;
var contactsInQueue = null;
var oldestContactAge = null;
for (var i = 0; i < collections.length; i++) {
var metricName = collections[i].Metric.Name;
var value = collections[i].Value;
if (metricName === "CONTACTS_IN_QUEUE") {
contactsInQueue = value;
}
if (metricName === "OLDEST_CONTACT_AGE") {
oldestContactAge = value;
}
}
outputs.contacts_in_queue = contactsInQueue;
outputs.oldest_contact_age = oldestContactAge;
})(inputs, outputs);