Webhook Configuration

Lucy Webhooks   

Webhooks provide a means to integrate and share data with Lucy through any system that supports making API calls. A Lucy admin would have to set up a webhook project and share the details with a user. A sample json can be provided upon request.

Upload File

Use this API to share new content with Lucy directly. This allows sending a file along with metadata. 

curl -L -g -X POST 'https://bswebhook.lucy.ai/hooks/accounts/{{Lucy-admin-provided-account}}/files' \ -H 'Authorization: Basic CREDENTIALS' \ -F 'filename="TEST.ignore"' \ -F 'file=@"path-to-file"' \ -F 'metadata1="some metadata"' \ -F 'report_url="https://source.example.com/myfile"
ParameterComment

filename

Name that is used is display within Lucy

report_url

This is where we carry the user when user wants to see the document

completed_at

When was this report published / created

Table 1 – File metadata.

Additional metadata is supported and can be used for custom integrations (e.g., metadata1).

Response:

If credentials are wrong user will receive a HTTP 401 response.

SuccessErrorComment

true

 

File uploaded successfully

false

File name is required

File name is the key we use against the file. File name must contain its extension or file will be treated as unsupported

false

Account doesn't permit webhooks

Account is not setup to accept files

false

OS service error

We were not able to receive the file. User will have to retry sending

false

IO error

We were not able to receive the file. User will have to retry sending

Table 2 – Webhook responses.

Upload / Update Metadata File

This allows for bulk update of metadata against files in Lucy’s indexing engine without sending the files again. 

curl -L -g -X POST 'https://bswebhook.lucy.ai/hooks/accounts/{{Lucy-admin-provided-account}}/files/meta' \ -H 'Authorization: Basic CREDENTIALS' \ -H 'Content-Type: application/json' \ --data-raw '[{ "filename":"TEST.ignore", "report_url":"https://example.com/file", "report_clearance": "private",  "completed_at": "2020-03-10T14:47:24Z" }]'
ParameterComment

filename

Name that is used is display within Lucy. It is the unique id to identify which file to update

report_url

This is where we carry the user when user wants to see the document

report_clearance

This is used to control what is brought in

completed_at

When was this report published / created

Table 3 – File update metadata.

Users are free to send any additional metadata that they want to share, this is often used for custom integrations.

Response:

Response returns high level status “success” along with file level status.

SuccessErrorComment

true

 

When successful messages are available against each file

false

Error parsing json data

Invalid request was sent

Table 4 – Webhook update responses. 

There is a message against each file to indicate if the file update was successful.

MessageComment

saved

file metadata was updated, and Lucy will reprocess it

file not found

Entry for this file does not exist in Lucy’s indexing engine

filename not found

Invalid json sent. We could not identify a filename to operate against

 Table 5 – Webhook update file responses.

Delete File

If you need to delete content from Lucy against your account users can use this endpoint. It is designed to support bulk deletion of data. 

curl -L -g -X DELETE 'https://bswebhook.lucy.ai/hooks/accounts/{{Lucy-admin-provided-account}}/files/delete' \ -H 'Authorization: Basic CREDENTIALS' \ -H 'Content-Type: application/json' \ --data-raw '[{ "filename":"filename.jpg" }]'

Response:

{"success":true,"items":[{"filename":"filename.jpg","message":"deleted"}],"warnings":0}

High level success indicates that the request was received and processed.

SuccessErrorComment

true

 

When successful messages are available against each file

false

Error parsing json data

Invalid request was sent

false

Not found

Account doesn’t exist

 Table 6 – Webhook delete responses.

Warnings tell users if there were issues against individual files. This will be 0 if operations against all files were successful. 

There is a message against each file to indicate if the file delete was successful.

MessageComment

deleted

File metadata and answers were deleted from Lucy’s answer engine

error deleting answers from Lucy

Answers could not be deleted from Lucy’s answer engine

file not found

Entry for this file does not exist in Lucy’s indexing engine

filename not found

Invalid json sent. We could not identify a filename to operate against

 Table 7 – Webhook delete file responses.

File Listing

Users can fetch a list of all files in their account using the file listing account.

curl -L -g -X GET 'https://bswebhook.lucy.ai/hooks/accounts/{{Lucy-admin-provided-account}}/files' \ -H 'Authorization: Basic CREDENTIALS'

Response:

{     "success": true,     "files": [         {             "filename": "abc.json",             "size": 11614,             "status": "completed",             "uploaded_on": "2021-07-13 17:49:56.389"         },         {             "filename": "def.json",             "size": 12058,             "status": "completed",             "uploaded_on": "2021-07-13 19:44:22.45"         },         {             "filename": "ghi.json",             "size": 4053,             "status": "completed",             "uploaded_on": "2021-05-12 19:17:39.398"         },         {             "filename": "jkl.json",             "size": 5713,             "status": "completed",             "uploaded_on": "2021-05-07 15:44:22.062"         },         {             "filename": "mno.json",             "size": 5771089,             "status": "manual_intervention",             "uploaded_on": "2021-03-26 13:36:37.868"         },         {             "filename": "pqr.json",             "size": 2195,             "status": "completed",             "uploaded_on": "2021-02-24 21:23:55.034"         },         {             "filename": "stu.json",             "size": 967596,             "status": "completed",             "uploaded_on": "2021-02-20 06:09:44.351"         }     ] }

File Details

Further details and number of answers against a file are available by fetching the file details.

curl -L -g -X GET 'http://bswebhook.lucy.ai/hooks/accounts/{{Lucy-admin-provided-account}}/files/filename.ext' \ -H 'Authorization: Basic CREDENTIALS'

Response:

{     "success": true,     "details": {         "filename": "filename.ext",         "size": 5771089,         "status": "manual_intervention",         "uploaded_on": "2021-03-26 13:36:37.868",         "ingested_on": "null",         "answer_count": 0     } }



Was this article helpful?