Installing the Webhooks package

The Webhooks package allows other systems to receive JSON payloads about Compass records when certain conditions are met, such as a specific action being executed on a record, or a record changing state.

Note: Use of the REST API server is not supported in an on premises environment, such as on Windows and Linux. To use the HCL Compass REST API server in a supported environment, deploy the HCL Compass REST API server to a Kubernetes environment. For more information, see Getting Started with HCL Compass on HCL SoFy.

Installing the Webhooks package

Install the Webhooks package by completing the following steps:
  1. Open the Compass Designer.
  2. Log in to the desired repository.
  3. Right-click the reposority in the left sidebar and click Install Package.
  4. In the Install Package Wizard, expand the Webhooks package and choose version 1.0 of the package.
  5. After the installation completes, click Finish, then OK.
  6. In the left sidebar, expand to the desired repository and expand the schema that you want to apply the package to.
  7. Right-click the currently loaded version of the schema, and navigate into Packages, then click Apply Packages.
  8. Expand the Webhooks packages and choose version 1.0 of the package, then click Next.
  9. Checkmark the record types to apply the Webhooks package to. These are the record types that you will be able to configure webhooks for. For example, you will be able to configure a webhook that will receive payloads from Compass whenever a record of one of the checkmarked types is created.
  10. Check in the new version of the schema by right-clicking the version in the left sidebar and navigating to Revision Control, and then Checkin.
  11. Upgrade the desired database with the new schema version by clicking the repository in the left sidebar where the package was installed and applied. Navigate to the Compass Database Admin tab at the bottom center of the Compass Designer.
  12. Right-click the database to upgrade with the new schema version and click Upgrade Database. Click the desired schema version and click OK.

Configuring the webhooks package for use in Compass

  1. Using an administrator account, create a record of type Webhook_Master. Provide any groups that should be allowed to create and manage webhooks (WebhookConfig records) and a callback URL to the Compass REST API server. It is recommended, but not required, to create a group specifically for users with access to manage WebhookConfig records.
  2. Create a WebhookConfig record. You may need to log out of Compass and log back in for this option to appear. Provide a webhook name and URL, and optionally, a secret for securing the webhook and description. The secret will be used to hash the payload that is delivered to webhooks so that the receiver can verify the payloads validity.

    Also, choose a Tracked Record, which will be the record type that you want to receive payloads about. The default Webhook Type is set to Commit, which means that payloads will only be sent when actions executed on records of the tracked type are successful. If you want payloads to be sent regardless of success, choose Notification.

    In the Controls tab, choose a combination of Actions and/or States that you wish for your webhook to receive payloads about. For example, choosing the Submit action triggers a payload to be sent any time the Submit action is used on a record type.

  3. Using any API client, such as Postman or the command line, create an HTTP POST request to the REST API servers hookSetup endpoint. This enables the server for use with the Webhooks package by creating a system user that can execute the necessary actions in Compass. The credentials that you provide in the payload should belong to a user that has permission to create users. API calls to the hookSetup endpoint can only be executed by a user with User Maintenance privileges or higher.

    Example URL: https://localhost:8190/ccmweb/rest/hookSetup

    Example payload:
    {
    	"username": "admin",
    	"password": "",
    	"repo": "TestRepo",
    	"db": "SAMPL"
    }
  4. Restart the Compass REST API server for these changes to take effect.

Usage

After the initial setup is complete, using the Webhooks package is simple.

Any time that one of the following occurs, a payload containing information about the relevant record will be delivered to the registered webhook:
  1. Any of the actions chosen in the WebhookConfig record are triggered on the chosen Tracked Record.
  2. The Tracked Record is moved to any of the states chosen in the WebhookConfig record.

The Compass REST API server will attempt to deliver the payload 10 times before giving up and removing the payload from its queue. The webhook must respond to the incoming payload with a successful or unsuccessful HTTP status code and a response body containing a message in order to continue proper execution of payload deliveries to the webhook.