# Webhooks

You can configure webhook endpoints to be notified about events that happen in your Sleekplan account, like feedback items & comments created, votes, subscriptions. You can configure webhooks from the dashboard, which provides a user interface for registering and testing your webhook endpoints.

Web Hooks can be used to integrate with Sleekplan, and receive real-time events from Sleekplan on a custom HTTP endpoint.

Webhooks can be used in the following scenarios:

  • Store new suggestions in your database
  • Store user emails right when a visitor sets their email
  • Do something when a user performs any action (like a user vote, comment or subscribe to a suggestion)
  • Etc. (you may come up with other scenarios)

# Get started with webhooks

To setup wehooks, you first need to setup a public HTTP endpoint, handling HTTP POST payloads. The endpoint can listen on any domain name / URL and can be hosted on your own servers.

To ensure no external user/attacker can post fake Crisp events to your endpoint URL, it is recommended you append a secret key to the endpoint URL, as a GET parameter, e.g. https://endpoint.yourapp.com/webhooks?key=MY_SECRET_KEY. Your backend can then check that the provided key parameter matches the configured security key.

# Create webhooks

Feedback Widget

Once the endpoint is ready, create the webhook on Sleekplan:

  • Go to your product settings on your Sleekplan Dashboard.
  • Navigate to the "developer" section
  • Scroll down, and select "add webhook"
  • Finally, enter the endpoint URL (eg. https://endpoint.yourapp.com/webhooks?key=MY_SECRET_KEY as described before)

# Events

Each event consists of two parts separated by a dot (event.part). The first part indicates the event category and the second part means the event action (e.g. item.create for webhooks triggered once a new suggestions is created). You can find a list of events that can be handled below:

Feedback/Suggestion related events

  • item: create, delete, update
  • comment: create, delete, update
  • vote: create
  • subscription: create, delete

Other events

  • user: create, delete, update
  • changelog create, update, subscribe
  • satisfaction create

# Payloads

Webhook events come when a real-time event occurs in your Sleekplan board. Event payloads have the same data format as the REST API returned JSON strings.

General format:

A Web Hook HTTP POST body is JSON-encoded and formatted as such:

{
    "product_id": 5456534244,
    "action"    : action_key, // The action key (e.g. item.create, comment.update, vote.create)
    "data"      : data, // The webkook payload
    "timestamp" : timestamp // UNIX timestamp of the event
}

Example:

{
    "product_id" : 5456534244,
    "action" : "item.create",
    "data" : {
        "feedback_id": "3",
        "product_id": "1",
        "title": "Show/search for similar ideas as you [...]",
        "description": "This can help us avoid users posting a [...]",
        "status": "open",
        "trend": "0",
        "type": "user-interface",
        "total_up": "9",
        "total_down": "0",
        "total_sum": "9",
        "total_comments": "0",
        "total_ratio": "9",
        "total_subscriber": "1",
        "scoring": "0.55",
        "effort": "1",
        "created": "2020-05-22 16:49:00",
        "updated": "2020-05-22 16:49:00",
        "user": {
            "user_id": "4",
            "admin_id": 0,
            "data_name": "lennishq",
            "data_mail": "",
            "data_img": "https://storage.sleekplan.com/..."
        }
    },
    "timestamp" : "1506985999999"
}