Webhook notification

This sample demonstrates how to set up webhooks for Slack or log files to obtain notifications for changes in Decision Center.

Time required

10 minutes

Prerequisites

You must have Decision Center installed to use this sample. Check that the sample server is started before you use this sample (see Starting and stopping the sample server).

You also need the following items:

  • A running installation of a Node.js server on your machine.
  • For Slack notification, a Slack channel set up with an incoming webhook that allows you to post events. Refer to the Slack documentation to set up the webhook.

    (Optional) To display a Slack user ID and information, a registered Slack token that gives you access to the Slack API. The sample uses this API to get the user ID that corresponds to the Decision Center login. The Slack and Decision Center logins should be the same. To get a Slack token, you must request one from your local Slack administrator. Without a Slack token, messages display the Decision Center login.

Description

This sample shows you how to receive notifications from the Decision Center Business console in a Node.js server, and send them to a Slack channel or log files. The key feature of this sample is the webhook mechanism (see Setting up notifications from Decision Center with webhooks).

Webhooks are user-defined HTTP callbacks. An event such as adding code to a repository or posting a comment can trigger a webhook. When the event occurs, the source site makes an HTTP request to the URL configured for the webhook.

You configure webhooks to invoke a behavior on a site when an event occurs on another site. For Decision Center, you set up webhooks to notify users when a decision service is modified or a user leaves a message. Because webhooks use HTTP, they can be integrated into web services without adding new infrastructure.