Data Outputs

Most tasks give back a fixed set of outputs. Each of these outputs is a string you can use in your next task, and using them is as simple as inserting them into an input.

However, sometimes we don't know what data a method will come back with, and that data may change between each request. For this situation, we have a special output type called a Data Output.

You'll know your task has a data output because you'll see the { } symbol next to the output when you select it:

Prerequisites

Our data output is a more advanced feature, and will be easier to understand if you already know what JSON is. Don't worry if you don't though, it's not that difficult.

It's also much easier if you know what data your method comes back with, even better if you have some example data to hand. For example, if you're using the data output with a webhook action to fetch data from an API, it would be ideal to have an example response to hand.

See the Flow XO docs for examples of the data you'll get back from other methods. You can also run your flow and then view the log to see what data comes back - that might be necessary sometimes.

Referencing Data

So, you know what JSON looks like, and know what data you have available to you. Let's imagine we have a data output called data. You know it contains this:

{
  "name": "Product A",
  "price": 150,
  "features": {
    "speed": 5,
    "weight": 20
  },
  "tags": [
    { "id": 1 },
    { "id": 3 },
    { "id": 5 }
  ]
}
We'll start by learning how to use the name ("Product A") as an output. In your flow, get to the input field where you want to insert the name.
Now select the output that contains the data we see above. You should see something like this:
If you leave the output like this, all of the data you see above will be inserted into the input field (as JSON). Sometimes that's useful, but in our case we just want the name.
So amend your output from {{task.data}} to {{task.data__name}}. Like this:
In Flow XO, we use a double underscore to access 'nested properties' in JSON, properties within properties. In this case, name is a property of data. We call this Double Underscore Notation.
If we wanted to use speed in our input, we'd do so like this:
Now, we'll learn how to use the tags property. As that's an array (or a collection of items), we have to use a slight variation that allows us to say which item in the array we're interested in. So to get the ID of the first tag (item 0):
To get the second item, you'd use {{task.data__tags__1__id}}, and so on. It's also possible to treat any item in an array as a Flow XO collection output. That way, you can easily get a nicely formatted list of all tag ID's:
This would give you the output "1, 2 & 3". See the collection output docs to learn more.

Troubleshooting

It's a little harder to use a data output than a regular output, and it's easier to get into trouble with it.
If you find that you're not getting what you need in your output, your first stop should be the logs. Look at what data you received, and consider whether your output referenced a property that exists.
Some common pitfalls:
  • Accidentally using a single underscore instead of double.
  • Using 1 instead of 0 to try and get the first item of an array.
  • Data that changes between requests. You might set the method up based on what data you think you'll be receiving, but that might change as you start to use the flow for real - examine the log carefully to see what data you receive in each situation.

If the output points to a property that doesn't exist, the output will be replaced with an empty string (i.e. nothing is output).

Let us know how we can improve Flow XO on our feedback site.

Still need help? Contact Us Contact Us