Order hook expression problem

I’m trying to create a hook configuration in my store to be notified in any of the following events:

  • Orders with any of these status: payment-approved, ready-for-handling, invoiced
  • When a order receives its tracking number (package sent)
  • When a order is marked as delivered

This is what I’ve come up with:

    "filter": {
        "type": "FromOrders",
        "expression": "(status in [\"payment-approved\", \"ready-for-handling\", \"invoiced\", \"canceled\"] or packageAttachment.packages.trackingNumber != \"\" or packageAttachment.packages.courierStatus.data or packageAttachment.packages.courierStatus.finished = true)",
        "disableSingleFire": true
	"hook": {
		"url": "mywebhookurl",
		"headers": {
			"account": ""

I have tested my expression on JSONata playground (https://try.jsonata.org) against an order JSON payload and it seems to be fine.

But for some reason I’m being only notified on status changes.

I’ve been trough this documentation: Feed v3 and it’s saying that the expression “isAllDelivered = true” would filter delivered orders, but It doesn’t work either.

Can someone give me a light? :slight_smile:

Hello Dante!

Maybe the problem with the expression is related to the fact that the “packages” is an array.
Try something like this $count(packageAttachment.packages[courierStatus.finished = true]) > 0 and tell me if it works. Never tried before. :smiley:

1 Like

Hi Saito,

According to the JSONata documentation and tester it shouldn’t be a problem, since it returns true for the expression that I wrote even if I don’t use the array count. :frowning:

Also the other conditions are not activating, for example the trackingNumber not equals to “”, and so on.

Hi @dante, according to Order Hooks documentation:

FromOrders: the hook will receive order updates when there is a change in the order.

FromWorkflow: the hook will receive order updates only when there is a change or update in the order status.

For your scenario, I believe it is necessary to use the type of your Order Hook as FromWorkflow.

Have you tried configuring your Order Hook as FromWorkflow?

The problem is, as you said:

FromWorkflow : the hook will receive order updates only when there is a change or update in the order status.

And there are two changes that I need to be notified that are not related to order statuses, which are orders with new tracking notifications and orders marked as delivered. In both cases the orders are generally in the “invoiced” status, so these changes would not appear in the FromWorkflow scenario.

I just found this https://help.vtex.com/en/known-issues/feed-hook-indexing-feature-skipping-events-in-fromorders-filters--6wpHloVS4KnH1TN5S5ySN2

So I guess the problem is a known issue and there is no solution for now.

Hi @dante,

hmmm but what if:

  1. configure a Order Hooks to capture orders with the desired status
  2. do a getOrder to get all the data coming from the order
  3. process orders where packageAttachment.packages[0].courierStatus.deliveredDate is filled in?

Hi @andremiani

The workflow I need to create will be used to send whatsapp notifications on these events, so It would be better If VTEX could simply notify me correctly when the events occur, that’s why I’m using Hook instead of Feed :slight_smile:

Unfortunately when a order is marked as sent or receiving a tracking update, the status doesn’t change.

I could implement some sort of routine to ask every period of time if anything change in the order, but that would be less performant from my point of view, and would generate a delay between the event actually occurring and the notification being sent.


Same issue here :slight_smile:

We’re trying to get a notification when an order is refunded, so we basically copied what the documentation suggest:
“filter”: {
“type”: “FromOrders”,
“expression”: “$count(packageAttachment.packages.restitutions.Refund.value) > 0”,
“disableSingleFire”: false
“hook”: {
“url”: “mywebhookurl”,
“headers”: null

But we’re not getting notified.