Using JMESPath expressions

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:

Examples

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:

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

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 JSON
JMESPath

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

Example: decode and return multiple fields

Input JSON
JMESPath

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

Select a Single Field

Input JSON
JMESPath

Expression: name Output:

Access Nested Fields

Input JSON
JMESPath

Expression: user.profile.location Output:

Select Multiple Fields

Input JSON
JMESPath

Expression: {name: name, email: email} Output:

Select all array element's properties

Input JSON
JMESPath

Expression: products[*].name Output:

Filter array by condition

Input JSON
JMESPath

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

Select root-level array

Input JSON
JMESPath

Expression: @ Output:

Use bult-in functions

Input JSON
JMESPath

Expression: max(products[*].price) Output:

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 JSON
JMESPath

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

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

Last updated