Menu
Guides
VTEX IO Apps

VTEX IO Apps
Orders Feed Example
Community extension
Version: 0.0.1
Latest version: 0.0.1

A boilerplate app implementing an event handler receiving status updates from OMS Feed. This is the method for using Feed v3 Hook inside VTEX IO.

How to Use

This app handles events sent by the app vtex.orders-broadcast, as you can see by looking at node/service.json.


_18
{
_18
"memory": 256,
_18
"ttl": 10,
_18
"timeout": 2,
_18
"minReplicas": 2,
_18
"maxReplicas": 4,
_18
"workers": 1,
_18
"events": {
_18
"listenOrderChange": {
_18
"sender": "vtex.orders-broadcast",
_18
"topics": ["order-status-updated"]
_18
},
_18
"someStates": {
_18
"sender": "vtex.orders-broadcast",
_18
"topics": ["cancel", "order-created"]
_18
}
_18
}
_18
}

You have two ways of consuming changes in status:

  1. Receive all events subscribing to the order-status-updated topic, as the listenOrderChange handler does
  2. Receive a selection of status changes where the currentState equals the topic, as the someStates handler does. This option is the preferred one, when you know ahead of time, what types of events, you want to listen to.

Normally vtex.orders-broadcast sends events only in master workspace. If you want to use it in a developer workspace, do the following:

  1. Create your development workspace by running vtex use {workspaceName}
  2. Go to https://{accountName}.myvtex.com/admin/apps/vtex.orders-broadcast/setup
  3. Change the Target Workspace variable to the name of the workspace you have created previously.
  4. Now you can link this app (vtex.orders-feed-example) in your desired workspace and receive order status updates.

Additionally, if you are setting up the app in a subaccount, it is important to check the Notify Subaccounts option at https://{accountName}.myvtex.com/admin/apps/vtex.orders-broadcast/setup even if the feed is not configured for the main account.

Here is an example body that you can expect to receive:


_14
{
_14
"recorder": {
_14
"_record": {
_14
"x-vtex-meta": {},
_14
"x-vtex-meta-bucket": {}
_14
}
_14
},
_14
"domain": "Marketplace",
_14
"orderId": "v69305315atmc-01",
_14
"currentState": "invoice",
_14
"lastState": "payment-approved",
_14
"currentChangeDate": "2020-07-13T20:25:13.2304508Z",
_14
"lastChangeDate": "2020-07-13T20:25:03.9527532Z"
_14
}

If you want to understand further how Feed v3 works, check out this documentation.

On this page
Was this helpful?