Sitecore XMCloud Webhooks events notitications
In Sitecore XMCloud different kinds of events will be get notified with the 3rd party system using the API endpoint, this helps the 3rd party system to do necessary action based on the information received from the webhook events triggered from XMCloud.
There are 3 kinds of webhooks we can get notifications from.
- Webhook Event handler
- Webhook Submit action
- Webhook validation action.
Webhook Events handler:
This webhook is used to provide notifications from XMCloud for the following events, We are not limited to using only the out-of-box events, we can create our custom events and get notifications from them.
Webhooks can be set to trigger on certain rules that we can set in XMCloud, once the Rule is met then this webhook will be triggered to provide notification on the defined API endpoint.
Webhook Submit actionThis Webhook submit action is set at the workflow level, either from moving from one state to another state or from the command level or as an action.
Once this webhook is enabled the necessary information about the item that is passed to 3rd party system to do necessary action on it, like cache purge, notification email, etc.
This Webhook validation action is also set at the workflow level only, but there is a difference between the Webhook submit action and this.
This Webhook Validation action expects the approval from the 3rd party system to either approve the content with the changes or reject it, based on API system response XMCloud will move the item to its next workflow state if the response does not come back due to an error from the API system XMCloud will not move the item next workflow state.
The response format expected by the XMCloud is {"IsValid":true,"Message":""}
Fields Available in Webhook Template:
Types of Authorization:Steps to enable Webhook in XMCloud and preview the request response in the 3rd party API System
- Webhooks Events Handler needs to be created in the following path /sitecore/system/Webhooks
- Webhook Submit action / Webhook Validation needs to be created in workflow state/command
- After setting all the necessary fields and enabled the Webhook, then we can capture the data in the API system like below.
- In the below screen shot I have saved the Home item from xmcloud with some fields updated which triggers the Webhook Event handler based on the Rule I have defined in it.
- The event got captured in the API system to the endpoint mapped in the URL field.
- The response is captured by API system and it will process according to the business needs.
Webhook Events Handler Request:
Webhook Validation Action request:
If the Webhook Validation action is set for moving from one state to another then it should
receive the response from 3rd party system. Sometimes the API request will fail due to a
timeout issue, we can increase our timeout by patching the config setting Sitecore.HttpClientTimeout.
On approving the workflow state this Webhook will get triggered, and it will wait for the response from the API end to move to the next state.
This webhook will trigger on the state and command level based on our workflow configuration.
Happy Programming 😊
Comments
Post a Comment