Webhook

Fires a webhook every time a task is passed as input. Returns the same task as output.

Settings

URL. The url where to send the webhook. Secret. The secret to pass along with the webhook.

Webhook Content

Sample Webhook Output

Sample Webhook Output
{
  "asset": "https://angohub-private-assets.s3.eu-central-1.amazonaws.com/1a3caf60-aea9-451b-ae2c-38cfd6be926a.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIATAGM6WLISC5CRH7S%2F20230927%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20230927T120720Z&X-Amz-Expires=120000&X-Amz-Signature=2fa60de18d538aa7f89711fb55b4b4baae312df98eb8558e7fecaa397baa65c4&X-Amz-SignedHeaders=host&x-id=GetObject",
  "assetId": "65141af7a9e78800154eeb54",
  "dataset": [],
  "externalId": "Symbol Secondary Usage - White.png",
  "metadata": {
    "width": 445,
    "height": 95
  },
  "batches": [
    "651521e299f4bf0015872c91"
  ],
  "task": {
    "taskId": "65141af7a9e78800154eeb62",
    "stage": "Label",
    "updatedAt": "2023-09-28T09:37:33.733Z",
    "updatedBy": "lorenzo@imerit.net",
    "totalDuration": 11643,
    "tools": [
      {
        "bounding-box": {
          "x": 194.4620486366986,
          "y": 30.24221453287197,
          "height": 7.889273356401384,
          "width": 12.789240972733971
        },
        "objectId": "b792278d6a89cedb0235598",
        "classifications": [],
        "metadata": {
          "createdAt": "2023-09-28T09:37:32.598Z",
          "createdBy": "lorenzo@imerit.net",
          "createdIn": "Label"
        },
        "schemaId": "7d38d842079133453b4b328",
        "title": ""
      }
    ],
    "classifications": [],
    "relations": [],
    "brushDataUrl": null,
    "medicalBrushDataUrl": null
  }
}

Differences between Webhook Output and Export

ExportWebhook

Batches provided as names.

Batches provided as IDs.

stageId field in task object present

stageId field not present.

Set Up a Sample Webhook Server

This sample is a minimum server setup you can use to test whether your webhook configuration is working or not.

  1. Run this Python script, changing your_secret_key with a secret key of your choice.

Sample Webhook Python Script
import json

from flask import request, Flask
import hmac
import hashlib

secret = b'your_secret_key' # Secret Key you entered while adding the integration
app = Flask(__name__)


@app.route('/hook', methods=['POST'])  # Custom Endpoint
def hook():
    computed_signature = hmac.new(secret, msg=request.data, digestmod=hashlib.sha1).hexdigest()
    if request.headers["X-Hub-Signature"] != computed_signature:
        print("Error")  # Signature Mismatch means the webhook was triggered by a 3rd party.
    else:
        print(json.dumps(request.get_json(), indent=2))  # This is the actual label result
    return "ok"


if __name__ == '__main__':
    app.run(debug=True)
  1. Install ngrok on your system. Instructions on installing ngrok can be found here.

  2. Once ngrok is installed, from the command line/terminal, run ngrok http 127.0.0.1:5000

  3. You will see a screen like the following. Copy the URL highlighted in red.

  1. Go to your Ango Hub project and set up your workflow to have a Webhook stage plugged in. In this case, for example, the Webhook stage will fire every time a labeler submits a task in the Label stage:

  1. Click on the Webhook plugin to open its settings.

  2. In the URL field, paste the URL we copied before, adding /hook at the end. For example, if the URL provided by ngrok was https://47f2-88-243-68-208.ngrok.io, you will paste it and add /hook at the end, forming https://47f2-88-243-68-208.ngrok.io/hook.

  3. In the Secret field, type the secret key you entered in the Python script during step 1.

  4. Save your workflow.

  5. In your project, perform an action which would trigger a webhook. In our example above, it would be submitting a tasl from the Label stage.

If the webhook worked correctly, you will see a 200 OK code in the ngrok window:

And the webhook content will be sent to your server where you ran the Python script. If you ran it in PyCharm, for example, you will see the webhook contents in the Run tab:

Last updated