Use nested JSON Payload from external Services in Shopify Flow with Webhook

In this article we want to show you how to use nested JSON payload from external services that sends data into Shopify Flow with a Flow Webhook.


For example the payload could be

{
  payload: {
    person: {
      firstName: "Foo",
      lastName: "Bar"
    },
    user: {
      email: "foo@bar.buzz"
    }
  }
}

and you want to access person and user attributes in Shopify flow.


First, we need to create a mapping for the "payload" attribute on our webhook we want to use.

Important:

For external services that send data to the webhook, we recommend enabling "Allow Custom Request Body" since normally the webhook checks the body and disallowed properties it does not know. Since external services often send arbitrary body, you should enable this in this case.

Now we can start. JSON gets automatically parsed and stringified back, so you can parse it again in Shopify Flow.

The flow could look like this

with "Run code" action

and "Log output" action

We can now trigger the webhook with a curl command like this:

curl -X POST \
  https://flow-webhooks.k8s.eu.codecreationlabs.cloud/webhook/oh8sa3pg \
  -H "Content-Type: application/json" \
  -d '{
    "payload": {
      "person": {
        "firstName": "Foo",
        "lastName": "Bar"
      },
      "user": {
        "email": "foo@bar.buzz"
      }
    }
  }'

and get the following result

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.