Webhooks

A webhook is a callback function that delivers an event payload to a URL when certain events occur in Nitro. The URL can be any address, including https, where you can access the files sent by Nitro. Typically, webhook data is used to develop processes not available in Nitro. For example, you could create a process that ingests the webhook data to send an email notification when a user receives a recognition.

You can trigger a webhook when the following events occur:

Create or Edit a Webhook

  1. Open Nitro Studio > Integrate > Webhooks.
  2. Click New. Or, to edit an existing webhook, click Edit (Edit Button).
  3. Set webhook properties:
  4. Field

    Description

    Name

    The webhook name.

    Description

    The webhook description.

    Callback Url

    The URL of the location where you want to receive the event payload.

    Active

    Select to activate the webhook.

    Triggers

    Select an event trigger. When an event occurs for the webhook type, an event payload will be sent to the Callback URL. Each point category can only be associated with one webhook. The available triggers are:

    • User mission complete - send the payload when a user completes a mission. A payload will not be sent for group mission completions.
    • User [point category name] earned - send the payload when a user earns points within this point category.
    • [interaction name] interaction created - send the payload when a user gives a recognition within this recognition exchange.
    • User level earned - send the payload when a user's level changes.
  5. Click Save.
  6. (Recommended) Add code to validate the authenticity of the request you receive from Nitro using the information in the Webhook URL Validation section.

Webhook Processing

A webhook eventId is unique to the payload event. If a webhook call fails (the HTTP status code returned to Nitro is not between 200 and 399), it's retried every 3 hours up to 3 days. The original and retry calls are identical in terms of payload, headers, etc.

When sending a response to Nitro after receiving a payload, the response should be sent as soon as the payload is received as the endpoint timeout is 30 seconds.

Webhook Process Diagram

Webhook URL Validation

The event payload will be delivered in UTF-8 format via a POST call to the URL configured in the webhook.

Show me an example of the body of a points event post callClosed

Show me an example of the body of a mission completion event post callClosed

Show me an example of the body of a level earned event post callClosed

Show me an example of the body of a recognition event post callClosed

Once you define the URL, you can validate the authenticity of the request from Nitro. The following authorization headers are provided in the http call:

 

You will need your site's secret key to complete the following verification steps. The secret key is available in Nitro Studio > Configuration > Site Settings > Overview > API secret key.

  1. Concatenate the following strings into one.

<your site's secret key> "|" <x-bb-content-sha256 header value> "|"<x-bb-date header value>

  1. Convert the string from Step 1 into a SHA256 hash. The hash must be 64 characters long. If your hash is shorter than 64 characters, prefix the hash with zeros to make it 64 characters.

<your language of choice string to sha256 converter>(<string from step 1>)

  1. Compare the hash produced in Step 2, with the hash in the Authorization header (with the “SHA256 Signature=” prefix removed).

<hash from step 2> == <authorization signed hash - without the “SHA256 Signature=” part from the Authorization header>

  1. Convert the entire event body payload received into a SHA256 hash. The hash must be 64 characters long. If your hash is shorter than 64 characters, prefix the hash with zeros to make it 64 characters.

Ensure the hash contains the raw payload and with no formatting applied to the data. Formatting may cause you to lose the numeric precision that the original content was generated with.

<your language of choice string to sha256 converter>(<event body received>)

  1. Compare the hash produced in Step 4 with the hash received in the x-bb-content-sha256 header.

<hash from step 4> == <x-bb-content-sha256>

If the comparisons in Step 3 and Step 5 pass, your payload is guaranteed to originate from Nitro.

Show me example code I can modify to use for validationClosed

See also

Point categories

Missions

Levels

Recognition