Lazarus RikAI2 Async-6.930.1900
Input (Requirement)
- orgId
- authKey
- Question (one or more)
- Input URL or Base64 Text File
Input (Optional for additional infomation)
- Metadata (JSON Format)
- Webhook URL
- Output URL
Return Value
- Question and answers in a JSON format
Return Code
- 0 Success
- 1 misc. errors
Parameter Setting samples
The new API specification
- About the new API
The new API does not return answers to questions in response.
Answers are now sent per process via webhook.
For more information, please check the following :
https://docs.lazarusforms.com/docs/rikai-2/rikai2-overview
- How to use
For information on how to use the API, check the documentation at the following URL.
https://docs.lazarusforms.com/docs/rikai-2/rikai2/operations/create-a-rikai-bulk
- How to receive Webhook
The next method is to set up a server in Python to receive webhooks.
A sample script for a server to receive webhooks in Python looks like this :
import http.server import socketserver import datetime import base64 import json class MyHandler(http.server.BaseHTTPRequestHandler): def do_POST(self): content_length = int(self.headers['content-length']) # Get Body now = datetime.datetime.now() req_body = self.rfile.read(content_length).decode("utf-8") json_body = json.loads(req_body) if json_body["status"] == "SUCCESS": # Processing docId doc_id = json_body["metadata"]["docId"] doc_id_dec = base64.b64decode(doc_id).decode('utf-8') pam_id = str(doc_id_dec).split('+')[0] # Create Output JSON file_name = pam_id + '_' + str(doc_id) + '_' + now.strftime('%Y%m%d%H%M%S') + '.json' with open(file_name, 'w', encoding='utf-8') as f: json.dump(json_body, f, indent=3, ensure_ascii=False) # Response self.send_response(200) self.send_header('Content-Type', 'text/plain; charset=utf-8') self.end_headers() with socketserver.TCPServer(("", 80), MyHandler) as httpd: httpd.serve_forever()
Can download it from the following link :
Here, the ”docId” is set in the ”metadata” above, and a process is built in to disassemble and process it.
The ”docId” is set to “PAMID” + “Requests sent date and time” encoded in Base64.
Running this as a server will allow you to receive webhooks.
All that remains is to set the published URL or IP address as the WebhookURL.
If you want to set up a Webhook server using Docker, please refer to here:
https://docs.google.com/document/d/1u4moCaAa92nwkyuCn2cs40xDt92l4g6BG5QYN5rplOY/edit?usp=sharing