This article explains how you can use the webhooks external integration to setup your workflows
What are webhooks?
From the zapier blog: "Webhooks are automated messages sent from apps when something happens"
Keeping this definition in mind, let's think about how webhooks can apply to your Nanonets model.
After you upload a document or image onto your Nanonets model, there's 2 ways you can pull this information out.
1. Polling
You can query an API for the extracted result via the following APIs
https://nanonets.com/documentation/#operation/OCRModelListPredictionFiles
https://nanonets.com/documentation/#operation/OCRModelGetPredictionFileById
2. Webhooks
Nanonets can notify you when the processing is complete and send you the information. Over here you can configure an URL onto our platform to set this up. Whenever a file is processed or verified, we will send a message to this URL with the results
How can you set it up?
Step 1: Go to the Auto export section
1. Go to the Extract data section of your model: https://app.nanonets.com/#/ocr/test/<MY_MODEL_ID>
2. Click on the Auto Export button
Step 2: Setup the webhooks
1. Choose webhooks from the dropdown
2. Enter a name for the integration: For eg: "my first webhook"
3. Enter your endpoint URL
4. Activate either
4. Hit Save
What is export after inference?
If you want to get the data after the file has been processed, you can enable this switch when setting up the integration
What is export after verification?
If you want to get the data after the file has been manually verified by someone on your team, you can enable this switch when setting up the integration
What will the data format look like?
Data contains prediction results for all pages in the file uploaded. The response contains a field "message" for every page result. message field can have values from "success", "failure", "pending", which mentions the current status of the predictions.
{
"result": [{
"message": "Success",
"result": [{
"message": "success",
"input": "10388917.PDF",
"prediction": [{
"id": "be28574d-9cac-40ff-8f3f-ec7bbfe6b5ad",
"label": "vendor_name",
"xmin": 1526,
"ymin": 752,
"xmax": 1750,
"ymax": 795,
"score": 0.9999815,
"ocr_text": "Fun Express",
"status": "correctly_predicted"
}, {
"id": "ab3a32fc-3536-46ad-afe0-30b1a74c8f14",
"label": "Invoice_Number",
"xmin": 477,
"ymin": 1476,
"xmax": 728,
"ymax": 1511,
"score": 0.9998122,
"ocr_text": "713525457-01",
"status": "correctly_predicted"
}],
"predicted_boxes": [{
"id": "be28574d-9cac-40ff-8f3f-ec7bbfe6b5ad",
"label": "vendor_name",
"xmin": 1526,
"ymin": 752,
"xmax": 1750,
"ymax": 795,
"score": 0.9999815,
"ocr_text": "Fun Express",
"status": "correctly_predicted"
}, {
"id": "ab3a32fc-3536-46ad-afe0-30b1a74c8f14",
"label": "Invoice_Number",
"xmin": 477,
"ymin": 1476,
"xmax": 728,
"ymax": 1511,
"score": 0.9998122,
"ocr_text": "713525457-01",
"status": "correctly_predicted"
}],
"moderated_boxes": [],
"custom_response": null,
"page": 0,
"day_since_epoch": 19001,
"hour_of_day": 7,
"request_file_id": "b556e1a8-1567-4cc3-aea9-ac0701dd9470",
"filepath": "uploadedfiles/279237c4-c419-4119-819c-c7d9a202a8b8/PredictionImages/141471135-1.jpeg",
"id": "460d1663-711f-11ec-92ac-d2aeaec044d4",
"is_moderated": false,
"rotation": 0,
"updated_at": "460d1663-711f-11ec-92ac-d2aeaec044d4",
"model_id": "279237c4-c419-4119-819c-c7d9a202a8b8",
"url": "uploadedfiles/279237c4-c419-4119-819c-c7d9a202a8b8/PredictionImages/141471135-1.jpeg",
"size": {
"width": 2541,
"height": 3367
},
"original_file_name": "10388917.PDF",
"source": "api",
"no_of_fields": 9,
"status": "success",
"current_stage_id": "ffffffff-ffff-ffff-ffff-ffffffffffff"
}],
"signed_urls": null
}, {
"message": "Image is being processed. Please try again later",
"result": [{
"message": "pending",
"input": "10388917.PDF",
"prediction": [],
"predicted_boxes": [],
"moderated_boxes": [],
"custom_response": null,
"page": 1,
"day_since_epoch": 19001,
"hour_of_day": 7,
"request_file_id": "b556e1a8-1567-4cc3-aea9-ac0701dd9470",
"filepath": "uploadedfiles/279237c4-c419-4119-819c-c7d9a202a8b8/PredictionImages/141471135-2.jpeg",
"id": "460d16a8-711f-11ec-92ad-d2aeaec044d4",
"is_moderated": false,
"rotation": 0,
"updated_at": "460d16a8-711f-11ec-92ad-d2aeaec044d4",
"model_id": "279237c4-c419-4119-819c-c7d9a202a8b8",
"url": "uploadedfiles/279237c4-c419-4119-819c-c7d9a202a8b8/PredictionImages/141471135-2.jpeg",
"size": {
"width": 2403,
"height": 3214
},
"original_file_name": "10388917.PDF",
"source": "api",
"no_of_fields": 9,
"status": "pending",
"current_stage_id": "00000000-0000-0000-0000-000000000000"
}],
"signed_urls": null
}, {
"message": "Image is being processed. Please try again later",
"result": [{
"message": "pending",
"input": "10388917.PDF",
"prediction": [],
"predicted_boxes": [],
"moderated_boxes": [],
"custom_response": null,
"page": 2,
"day_since_epoch": 19001,
"hour_of_day": 7,
"request_file_id": "b556e1a8-1567-4cc3-aea9-ac0701dd9470",
"filepath": "uploadedfiles/279237c4-c419-4119-819c-c7d9a202a8b8/PredictionImages/141471135-3.jpeg",
"id": "460d16bd-711f-11ec-92ae-d2aeaec044d4",
"is_moderated": false,
"rotation": 0,
"updated_at": "460d16bd-711f-11ec-92ae-d2aeaec044d4",
"model_id": "279237c4-c419-4119-819c-c7d9a202a8b8",
"url": "uploadedfiles/279237c4-c419-4119-819c-c7d9a202a8b8/PredictionImages/141471135-3.jpeg",
"size": {
"width": 2403,
"height": 3214
},
"original_file_name": "10388917.PDF",
"source": "api",
"no_of_fields": 9,
"status": "pending",
"current_stage_id": "00000000-0000-0000-0000-000000000000"
}],
"signed_urls": null
}]
}