Hello,
I’m developing an integration with VTEX and I have two scenarios — B2B and B2C — and I have a question: I need to capture all new users registered in my B2B environment and I’d rather not keep polling for them. Is there a way to configure a webhook to fetch newly registered customers in my B2B environment?
Hey @Manzini, how’s it going?
In VTEX, you can solve this type of problem in two ways:
- Querying the order feed: VTEX provides an order feed that you can use to retrieve information about placed orders.
- Registering an Order Hook: You can set up an order hook that will be notified whenever an order meeting a certain condition is generated.
The ERP Integration: Set Up Order Integration documentation covers both scenarios in detail.
Personally, I prefer to create an Order Hook to be notified whenever an order that meets a specific condition is generated in VTEX.
So whenever an order is created or changes status, the registered endpoint receives a JSON with the fields shown in the example below. From this JSON, you can get the OrderId and make an order query to retrieve all the order data, including customer information, and carry out the desired processing — such as determining whether the customer is new or whether any data needs to be updated.
{
"Domain": "Marketplace",
"OrderId": "v40484048naf-01",
"State": "payment-approved",
"LastChange": "2019-07-29T23:17:30.0617185Z",
"Origin": {
"Account": "accountABC",
"Key": "vtexappkey-keyEDF"
}
}
Hey @andremiani, doing great, how about you?
Thanks for the idea! We already have the integration using the Order Hook to capture paid orders from B2B and B2C customers. However, my client wants to target B2B customers who registered on the site but didn’t complete a purchase. If there’s no webhook available to implement for this, I’ll just go ahead and develop it via Polling.
Hey Manzini,
Wow, I totally missed that lol