Setting up the webhook notification sample

You install this sample by using a Node.js command.

Before you begin

You must start the sample server (see Starting and stopping the sample server) to use this sample.

About this task

Use the following instructions to get notices in either Slack or log files. For a clear separation of the sample code, you cannot run both configurations at the same time.

Configuring the webhook for Slack
  1. Add information about the Slack channel to the endPoints.json file, which is located in the sample directory: <InstallDir>/teamserver/samples/webhooknotifier/slack/endPoints.json. The file lists all the endpoints for Decision Center event dispatches in the following JSON format:
    [
     {
     "endpoint": "<Enter the Slack incoming webhook URL.>",
     "token": "<Enter the Slack token.>",
     "notify": "<Use true if you want to send events to Slack. Otherwise, use false for testing purposes.>"
     }
    ]
  2. Open a command term and navigate to the sample directory <InstallDir>/teamserver/samples/webhooknotifier/slack.
  3. Call the command npm install. It runs a Node.js server to initialize the Slack notifier package.
  4. Call the command node slack-notifier.js.
    Wait for the following message:
    Ready to receive events from ODM Decision Center
  5. (Optional) Use the following URL in your web browser to generate an access token:

    http://localhost:3000/token.generate

    Keep the token for the next step. It is a security item that is provided when you define the webhook in Decision Center.

  6. Register your webhook in Decision Center:
    1. Open to the Samples Console (see Running samples from the the Samples Console).
    2. In the Sample Server tab, click Decision Center REST API tool to open the tool.
    3. Click Authorize and enter Paul as the username and password for basic authentication.
      Note: If you are already logged in to Decision Center, log out before clicking Authorize or you might get an error.
    4. Open the entry Manage/ PUT /v1/webhook/notify and enter the following arguments:
      • authToken: If you generated a token in step 5, enter here. Otherwise, leave this item empty.
      • data source: Leave it blank. The default value is OK.
      • URL: http://localhost:3000/slack
    5. Run the request. The response code is 200 and the response body shows the ID of the new webhook.
The slack webhook is ready to use. You can skip the following section and go to the next topic on the sample's details.
Configuring the webhook for log files
You run the command for setting up the webhook for log files.
  1. Open a command term and navigate to the sample directory <InstallDir>/teamserver/samples/webhooknotifier/files.
  2. Call the command npm install. It runs a Node.js server to initialize the file notifier package.
  3. Call the command node log-notifier.js.
    Wait for the following message:
    Ready to receive events from ODM Decision Center
  4. Register your webhook in Decision Center:
    1. In the Sample Server view in Rule Designer, open the Decision Center REST API tool.
    2. Click Authorize and enter Paul as the username and password for basic authentication.
      Tip: If you are already logged in to Decision Center, log out before clicking Authorize or you might get an error.
    3. Open Manage/ PUT /v1/webhook/notify and check the following arguments:
      • authToken: Leave it blank.
      • datasource: Leave it blank. The default value is OK.
      • URL: Enter http://localhost:3000/print.
  5. Run the request. The response code is 200, and the response body shows the ID of the new webhhook.

The file webhook is ready to use. Go to the next topic: Webhook notification details.

Results

Your webhook is now ready. When you use the Decision Center Business console, events are sent on port 3000, and processed by the Node.js server.