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:
"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)",
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?
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.
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.
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.
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
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
We’re trying to get a notification when an order is refunded, so we basically copied what the documentation suggest:
“expression”: “$count(packageAttachment.packages.restitutions.Refund.value) > 0”,
But we’re not getting notified.