Overview
The Webhooks module enables viewing all major changes within your Virto Commerce ecosystem.
For instance, you can get notified on user login and/or password changes, catalog or product changes, and so on, which will assist you in better monitoring your system. Whenever a change you are watching (i.e. you 'subscribed to') is triggered, you will get the relevant notification uploaded to the URL address you previously specified.
Apart from the event you are following, you can also configure which fields or parameters you will see in the report you get.
Key Features
- Employees can manage webhooks but only under their own Permission level
- Admin users can manage webhooks
- Resolving Virto Commerce Domain Event for installed modules
- Sending Webhook notifications in the background via a POST request with JSON serialized event data to the specified URL
- Access to previous values of selected fields
- Sending the retry policy with configurable exponential intervals
- Viewing the error(s) when a webhook notification fails
Configuraton
To configure a new webhook, open the Webhooks module and click the Add button:
This will open the Webhook List tab:
Give your webhook a name and select the event you want to follow; for instance, you may want to get notified when a user profile has been changed, a user has logged in or out, or has reset their password:
Please note: You can only select one event per webhook. This means that, if you want to track, say, both the User Logged In and User Logged Out events, you will have to create two different webhooks. You can, however, create any reasonable number of webhooks you need.
In the Additional Fields area, you can select up to ten additional parameters you will see in the notification you will get with this webhook:
By default, only the ID and ObjectType properties will be included into the report. If you do not want any additional parameters to appear, just skip this step.
Finally, toggle the Activate button to get your webhook running or leave it deactivated if you want to enable it later, and specify the URL you will get the report at:
This is it. You can now click the Save button in the upper part of the tab to finalize your webhook configuration:
Once you do so, you will be able to see your new webhook in the list:
Alternatively, you can click the Reset button to reconfigure your webhook from scratch.
Warning Message
If you use webhooks with multiple event subscriptions in the previous version, you might get the following warning message once you update the Virto platform:
This is actually fine: you can continue using such a webhook as you did before, although you will not be able to edit it. However, we recommend you remove such webhooks and replace them with new ones instead. Currently, the single event per webhook limitation works for the newly created webhooks only, but, moving forward, we might totally remove the code that supports multiple event subscriptions.
Webhook Json Format
Please expand this paragraph to see an example of JSON output for a webhook based on the Order Changed event.
{
"EventId": "VirtoCommerce.OrdersModule.Core.Events.OrderChangedEvent",
"Attempt": 1,
"EventBody": [
{
"ObjectType": "VirtoCommerce.OrdersModule.Core.Model.CustomerOrder",
"Id": "1d58ff39-0631-44aa-afc6-a0d4adbc9787",
"Status": "New",
"Number": "CO220224-00003",
"__Previous": {
"Status": "Pending",
"Number": "CO220224-00003"
}
}
]
}
NOTE: You can then call the Order API and get the extended order information.
NOTE: `__Previous` field contains the same list of the fields with previous values.
References
- We recommend using webhook.site to inspect and test web hooks.