Gorgias logo
Gorgias logo

All articles

Creating Flow variables using JSONPathUpdated 11 days ago

When using our HTTP request Flow step, you can create variables using the response you received from a third party to leverage it in subsequent steps (for example, get a customer's loyalty point balance).

You can create variables from your response by defining their JSONPath (JavaScript Object Notation).

Imagine you have a big box full of smaller boxes, each labeled with names like "Photos", "Letters", and "Receipts" - JSONPath is like a map that helps you find a specific small box or even a single item inside one of these boxes. 

In the digital world, JSONPath helps us find data inside a format called JSON, which is just a way to organize information in a neat, readable way.

JSON is a popular way to store and transport data, like a digital filing system. For example, think of a contact list on your phone. Here's how a simple contact might look in JSON:

1{
2  "name": "Alice",
3  "phone": "123-456-7890"
4}

JSONPath lets us pick out specific pieces of information from JSON data.



Steps

  • Start at the Root - In JSONPath, $ symbolizes the start of the data. Think of it as the outermost box.
  • Find Your Way - Use the names (keys) in the JSON to navigate. For example, to find Alice's phone number, you would use $.phone.


Examples

Accessing Data

To get Alice's name from our example, you use $.name. This is like saying, "In the big box, find the smaller box labeled 'name'."

Result: Alice

Accessing Nested Data

Imagine you have another box inside labeled address, and you want the city. Your JSON might look like this:

1{
2  "name": "Alice",
3  "address": {
4    "city": "Wonderland"
5  }
6}

To find the city, use $.address.city.

Result: Wonderland

Was this article helpful?
Yes
No