Webhook notification details

You can run and rebuild the sample, and look at its source files to understand how it works. The sample uses the Decision Center Business console.

Running the sample

Make changes in the Business console to receive notifications.

  1. Log into the Business console by using Paul as the username and password, and then make changes:
    • Open the Miniloan Service main branch, and deploy a RuleApp archive. Create a rule in the validation package, name it test, and then delete it.
    • In the Loan Validation Service decision service, create a release named Test based on the Initial Release, create a change activity named TestActivity, and then delete both the change activity and the release.

    Look in the terminal where the Node.js server runs. It shows that seven events were sent, and displayed in the JSON format. If you configured the Slack package, you get notifications in Slack.

    If you configured the log file package, files are created in the <webhooknotifier sample directory>/files/results directory:

    • deployments.txt: Contains a summary description of each deployment.
    • rules.txt: Contains a summary description of changes to rules.
    • releases.txt: Contains a summary description of changes to releases.
    • activities.txt: Contains a summary description about activities.
  2. Stop the Node.js server by stopping the process in the terminal.

Rebuilding the sample

To rebuild this sample:
  1. Open the Samples Console (see Running samples from the Samples Console).
  2. In the Samples Commands tab, expand Samples Commands > Decision Center > Web Hook Notifier.
  3. Run the clean command to remove all the Node.js modules and file hook output files.

How the sample works

This sample defines a Node.js express server that receive notifications from the Business console. The notifications are decoded and sent to either Slack or a log-file system. The webhook is registered in Decision Center by using the Swagger REST API.

Source files

The source files for this sample are in <InstallDir>/teamserver/samples/webhooknotifier.

You can view and modify the files in Rule Designer. To import the file into your workspace:

  1. In the Samples Console, open the Samples and Tutorials tab, and expand Decision Center > Samples > Business rule management extensions.
  2. Click the Import projects link under Webhook Notifier to import the following projects:
    • HookOnSlack:
      • package.json: Describes the Node.js module.
      • endpoints.json: Describes the Slack channel.
      • slack-notifier.js: The main entry point of the webhook, it contains the express application description.
      • Other JavaScript files: Contain utility functions that decode an event based on its type.
    • HookOnFile:
      • package.json: Describes the Node.js module.
      • log-notifier.js: The main entry point of the webhook, it contains the express application description.
      • fileUtil.js: Contains utility functions that decode an event based on its type.