Nested fields

Many times you will face with webhooks services that requires or sent you nested fields. Nested fields are containers with multiples values or event containers with nested containers inside.

For those situations, Webhooks add-on includes solutions to work with this kind of data.

Nested fields when receiving data from webhook

Let’s imagine that a service sends a webhook like the following one:

"data": {
    "customer": 123,
    "first_name": "AutomatorWP",
}

To handle the “data” parameter on the Receive data from webhook trigger, you need to configure the parameter as “Array”:

Webhooks add-on will handle automatically all its nested parameters and you will be able to use all of them on tags separating each index by slashes (/), for example, to access to the “first_name”, you need to place the tag as “data/first_name” as you can see in the following screenshot:

Important! If you are receiving a JSON webhook like this one:

"data": [
    {
        "customer": 123,
        "first_name": "AutomatorWP",
    }
]

The brackets ([]) place the information inside an array, so you need to place the array index like “data/0/first_name” to use this “first_name” parameter on tags.

Nested fields when sending data to webhook

On the Send data to webhook action you are able to send nested fields by setting the field keys with the indexes you wish separated by slashes (/).

For example, if you want to send some nested fields like the following ones:

"data": {
    "customer": 123,
    "first_name": "AutomatorWP",
}

Simply, you need to setup the “data/customer” key with the value “123” and the “data/first_name” key with the value “AutomatorWP” like you con see in the following screenshot:

In addition, If you configure multiples fields with the same key, they will get grouped automatically in a nested field, for example this setup:

Will generate the following data:

"data": [
    123,
    456,
]

An example with repeated sub parameters:

Will generate this data:

"data": {
    "customer": [ 
        123,
        456,
    ]
}

Unlimited nested levels support

Of course, Webhooks add-on includes support for unlimited nested levels and is able to send and receive a complex nested data like this one:

"data": {
    "customer": {
        "address": {
            "country": {
                "code": "ES"
            }
        }
    }
}

The key to access to the “code” parameter on this same data is “data/customer/address/country/code”.