Skip to content

Use JMESPath expressions to map and transform JSON response from webhook action into the desired data structure.

Example of using JMESPath expression in your output attributes mapping

Be aware of the following:

  • If your JMESPath expression is incorrect or points to non-existent fields, the output attribute value will be empty.
  • If the resulting value of your JMESPath does not match the target attribute type, the attribute value will also be empty.

Resources on JMESPath:

Custom function: json_decode(...)

Webhook V2 supports a custom JMESPath function called json_decode(...).

Use it when an API returns JSON inside a string field and you need to read values from that encoded object.

Without json_decode(...), string fields are treated as plain text and cannot be traversed with dot notation.

Syntax:

json_decode(<json_string_field>)

You can combine it with normal JMESPath traversal, for example:

json_decode(payload).order.status

If the string is not valid JSON, the result is treated as empty for mapping purposes.

Example: extract values from a JSON-encoded field

Input JSONJMESPath
{
  "eventId": "evt_901",
  "payload": "{\"order\":{\"id\":\"ORD-1007\",\"status\":\"shipped\",\"tracking\":{\"carrier\":\"DHL\",\"number\":\"TRK-7788\"}}}"
}

Expression:
json_decode(payload).order.tracking.number

Output:

TRK-7788

Example: decode and return multiple fields

Input JSONJMESPath
{
  "payload": "{\"order\":{\"id\":\"ORD-1007\",\"status\":\"shipped\"}}"
}

Expression:
{order_id: json_decode(payload).order.id, order_status: json_decode(payload).order.status}

Output:

{
  "order_id": "ORD-1007",
  "order_status": "shipped"
}

Select a Single Field

Input JSONJMESPath
{
  "name": "Alice",
  "age": 30,
  "city": "London"
}

Expression:
name

Output:

Alice

Access Nested Fields

Input JSONJMESPath
{
  "user": {
    "profile": {
      "name": "Charlie",
      "location": "London"
    }
  }
}

Expression:
user.profile.location

Output:

London

Select Multiple Fields

Input JSONJMESPath
{
  "id": 123,
  "name": "Bob",
  "email": "bob@example.com",
  "age": 25
}

Expression:
{name: name, email: email}

Output:

{
  "name": "Bob",
  "email": "bob@example.com"
}

Select all array element’s properties

Input JSONJMESPath
{
  "products": [
    {"name": "Laptop", "price": 999},
    {"name": "Mouse", "price": 25},
    {"name": "Keyboard", "price": 75}
  ]
}

Expression:
products[*].name

Output:

[
  "Laptop",
  "Mouse",
  "Keyboard"
]

Filter array by condition

Input JSONJMESPath
{
  "items": [
    {"name": "Apple", "price": 1.5, "inStock": true},
    {"name": "Banana", "price": 0.8, "inStock": false},
    {"name": "Orange", "price": 2.0, "inStock": true}
  ]
}

Expression:
items[?inStock == `true`]

Output:

[
  {"name": "Apple", "price": 1.5, "inStock": true},
  {"name": "Orange", "price": 2.0, "inStock": true}
]

Select root-level array

Input JSONJMESPath
[
  {"id": 1, "name": "Alice", "role": "admin"},
  {"id": 2, "name": "Bob", "role": "user"},
  {"id": 3, "name": "Charlie", "role": "user"}
]

Expression:
@

Output:

[
  {"id": 1, "name": "Alice", "role": "admin"},
  {"id": 2, "name": "Bob", "role": "user"},
  {"id": 3, "name": "Charlie", "role": "user"}
]

Use bult-in functions

Input JSONJMESPath
{
  "items": [
    {"name": "Apple", "price": 15 },
    {"name": "Banana", "price": 999 },
    {"name": "Orange", "price": 75 }
  ]
}

Expression:
max(products[*].price)

Output:

999

Select array elements for a form message with dynamic data

Section titled “Select array elements for a form message with dynamic data”

You can create a from message with dynamic data retrieved from a webhook action. For example:

Input JSONJMESPath
{
  "products": [
    {"sku": "LAP-001", "name": "Laptop", "price": 999},
    {"sku": "MOU-002", "name": "Mouse", "price": 25},
    {"sku": "KEY-003", "name": "Keyboard", "price": 75}
  ]
}

Expression:
products[*].{key: sku, value: name}

Output:

[
  {"key": "LAP-001", "value": "Laptop"},
  {"key": "MOU-002", "value": "Mouse"},
  {"key": "KEY-003", "value": "Keyboard"}
]

This can then be used as a data source for your searchable select in a form message.