Document Version History
Version number | Modified by | Modifications made | Date modified | Status |
1.0 | Shelf | Initial release of the Shelf Webhooks Feature Quick Start Guide. | 06 April 2022 | Active |
Introduction
This document is designed for administrators of Shelf’s clients who need to keep track of how users within their organizations interact with the Shelf platform.
Webhooks, Their Purpose and Benefits
What is a webhook and how can it be used?
Webhooks as implemented in the Shelf platform are automated messages that are generated and sent by Shelf upon certain events. To some extent, a webhook works as a push notification sent to a client-specified recipient. This recipient can be an external application, a file, a database, or even a server.
A standard webhook contains a message—also known as “payload”—and is sent by the system to a predefined unique URL address.
Example of a webhook sent to a recipient
JSON representation
{ "payload": { "accountId": "eb1541e7-ce1a-4d76-865d-f184468b3544", "action": "USER.SIGN_OUT", "actorUser": { "email": "jdoe@mail.com", "fullName": "John Doe", "id": "9d0939cb-47fa-4285-96ae-ab3dccc90dcb" }, "createdAt": "2022-04-05T14:53:00.358Z", "id": "01FZX3DXJ6HJXXQN7ZKMB8MRPN" } } |
---|
Difference between an API and a webhook
Any webhook you create and configure for your business purposes is an event-based entity. It means that this webhook is expected to run when a specific event occurs in the respective source application.
The key difference between APIs and Webhooks is that for a webhook to provide a response you do not need to send a request. At the same time, you ALWAYS need to send a request to an API in order to get a response.
In short, you receive data via webhooks and you retrieve data via APIs.
Prerequisites
In order to enjoy the full use of the Shelf Webhooks feature, the following preconditions must be met.
- Ensure that the Audit Log feature is included in your subscription plan. For this purpose, contact your Shelf representative and verify it is in your plan. If it is not, it can be ordered and enabled at an additional cost.
- Make sure your user has the Admin level of permissions. For this purpose, when on the main page of the Shelf platform, navigate to your user logo and open the dropdown menu. Then select the Admin Panel option to bring the Admin Panel to the screen. If you are able to get to the Admin Panel, it means your user has the Admin permissions.
Figure 1. Accessing the Admin Panel
Figure 2: Enabling the Audit Log option
If all the above preconditions are met, you can now start working with Shelf’s Webhooks feature. Jump to the below sections to find out which actions you can do on webhooks.
Limitations
In addition to the prerequisites, an efficient use of the Shelf Webhooks feature has certain restrictions, which are as follows:
- Not more than 5 (five) unique webhooks can be created from the Manage Webhooks submenu.
- One webhook can contain no more than 7 (seven) internal Shelf events.
- Your webhook endpoint is expected to respond with the HTTP status 2xx in 5 secondsor less. If the response is sent outside this timeframe, the webhook payload delivery is considered as failed. From our side, Shelf retries sending failed payloads for up to 3 times.
Create Webhooks
To start using the Webhooks feature of the Shelf platform, you first need to create a webhook.
☝ NOTE:
For user convenience reasons, we describe the webhook creation procedure on the example of the Shelf user logout. It means that the selected condition for the webhook to be triggered is user.sign_out. In general, the creation of webhooks that are to be triggered by other causes in the Shelf platform follows the same steps.
To create a new webhook, perform the following procedure.
- In the Admin Panel, locate and select the Manage Webhooks submenu.
Figure 3. Accessing the Webhooks feature
Figure 4. Starting to create a webhook
Figure 5. Creating a webhook
Table 1. Add Webhook form elements
Element name | Requirement | Details |
---|---|---|
Webhook name | Mandatory | Enter any desired name of the webhook; max length must not exceed 60 characters. |
Status | Mandatory | This element has two states represented by the checkboxes:
|
Endpoint URL | Mandatory | Enter an URL address of an endpoint to which Shelf is expected to send events in case new users are created in the system. The indicated endpoint URL must be capable of accepting POST HTTPS requests. ☝NOTE: For the purpose of future verification of the webhook operation, we use https://webhook.site as a service that helps check and verify webhooks. When you open this link in your browser, you are offered to copy the endpoint URL you can use for your webhook testing. In our case, this endpoint URL is https://webhook.site/4686d315-a53b-4838-b8dc-fafb73e286fb?. In a real-world scenario, use your the endpoint URL offered by your dedicated server. |
Description | Optional | In this text field, enter any description for your webhook. It should not exceed 500 characters. |
Events to send | Required | This element is where you need to select from 1 to 7 types of conditions that are to generate events to be sent to the specified endpoint. The available condition types are:
|
CANCEL | N/A | If you no longer need to create a webhook, click this button to stop the procedure and close the form without saving the changes made. |
ADD | N/A | Click this button to finish the webhook creation procedure and save the new webhook. |
Figure 6. Viewing the created webhook
Verify the webhook operation
Let’s now verify the webhook operation by the example of the user sign-out event. This exemplary verification is needed to show that your managers are able to track activities of their agents.
☝NOTE:
Any of the conditions/events indicated in Table 1 can be used for verification of the webhook operation.
In order to check if the created webhook is triggered properly, that is the system creates and sends relevant events to your endpoint, you need to log out of your Shelf account
Log out of Shelf
To log out of your Shelf account, perform the following steps.
- When on the Shelf main page, find and click your user pic in the upper right corner of the window.
- In the dropdown menu that appears, select the Logout option.
Figure 7. Logging out of Shelf
Once you are logged out, you are redirected to the Shelf login screen.
Check the webhook event
To make sure that the webhook you have created generates and submits proper events to your endpoint, log in to your server (or database, if applicable) and check if the respective event has been added.
As mentioned in the Note in Table 1, in the course of our webhook creation, we used the endpoint URL generated by https://webhook.site. This service is also used here in this section to check where the webhook we have previously created triggers proper events. In our case, this event must be triggered by logging out of the Shelf account.
To check if the webhook has triggered and sent the respective event upon the user logout, open the above URL address and see if there is any new record. If there is a new record and if it is about a webhook-triggered event, it must look like this:
Figure 8. Verifying the webhook event receipt
From the figure above, it is obvious the webhook was created and it generated the proper event (“USER.SIGN_OUT”} on the specified date and at the specified time (“2022-04-05T14:53:00.358Z”) as a result of the user that was registered under the specified email address (“jdoe@mail.com”) logging out of Shelf.
All this proves that the Shelf Webhook feature works as expected and triggers the proper event as a result of a certain action, which in our case is user logout.
Manage Webhooks
In Shelf, in addition to creating webhooks, it is also possible to manage them. For instance, you can edit webhooks you have previously created, disable them, or even delete.
☝NOTE:
In order to show a variety of conditions that trigger events in the Shelf Webhook feature, webhook editing, disabling, and deletion are described by the example of a new user creation webhook. You should note that any webhook you have previously created can be edited, disabled, and/or deleted.
Edit a webhook
In order to edit the existing webhook, follow the below procedure.
- Go to the MANAGE WEBHOOKS page by selecting the Manage Webhooks submenu in the Admin Panel. On this page, you can open the webhook that you want to edit either by directly clicking it or by opening the Actions menu and selecting the Open option.
Figure 9. Opening a webhook
Figure 10. Editing a webhook
Figure 11. Warning message
Disable a webhook
At a certain point, any of the previously created webhooks can become unneeded for some time. In that case, you can temporarily disable this webhook. To do so, perform the following.
Go to the MANAGE WEBHOOKS page and perform one of the following actions:
- Open the Actions menu next to the needed webhook and select the Disable option from the list.
Then in the pop-up window that appears, confirm your choice by clicking DISABLE.
Figure 12. Warning message when disabling a webhook
Figure 13. Switching webhook status to Disabled
Once the Disabled checkbox is selected, click SAVE to confirm the end of editing.
Figure 14. Saving a disabled webhook
Then confirm your intention by clicking the SAVE button in the warning pop-up window as shown in Figure 11.
Regardless of the method you have chosen to disable the webhook, once the respective button (DISABLE or SAVE) is clicked, the webhook status changes to Disabled, and you can see it near to the respective webhook on the MANAGE WEBHOOKS page.
Figure 15. Viewing the webhook status
Delete a webhook
If you no longer need any of the previously created webhooks, you can easily delete them from Shelf. To do so, perform the following.
Go to the MANAGE WEBHOOKS page and perform one of the following actions:
- Open the Actions menu next to the needed webhook and select the Delete option from the list.
Figure 16. Delete option in the Actions menu
Then in the pop-up window that appears, confirm your choice by clicking DELETE.
Figure 17. Confirming webhook deletion
Figure 18. DELETE button in the EDIT WEBHOOK form
Then in the pop-up window that appears, confirm your choice by clicking DELETE as shown in Figure 17 above.
Regardless of the method you have chosen to delete the webhook, once the respective button (DELETE) is clicked, the webhook is removed.
Figure 19. Viewing available webhooks
If you have successfully completed the actions described in the sections above, it means that you now understand how the Shelf Webhooks feature works and how to create, edit, enable/disable, and delete webhooks.