The Two Directions
Every RecordEngine integration involves data flowing in one or both directions:| Direction | Mechanism | Use case |
|---|---|---|
| Into RecordEngine | REST API (POST /api/documents/upload) | Upload documents from CRM attachments, email, or other systems |
| Out of RecordEngine | Outbound webhook (POST to your URL) | Push extracted data to accounting, CRM, or ERP when a document is exported |
The Standard Outbound Pattern
This pattern handles the most common use case: something happens in RecordEngine → data goes to an external system.- Trigger: Incoming webhook
- Action: Whatever the external system needs (create a Bill, update a CRM record, send a notification)
The Standard Inbound Pattern
This pattern handles uploading documents into RecordEngine from an external trigger.- A new email with an attachment
- A CRM stage change
- A file appearing in a shared folder
- A scheduled time (e.g. every morning at 8am)
document_id so you can query the document’s status or results later.
Handling the Async Gap
Document processing in RecordEngine is asynchronous — you upload a file and it’s processed in the background. There’s a gap between when you upload and when the extracted data is ready. There are two ways to handle this:Option A — Webhook Callback (Recommended)
Don’t poll for results. Instead, let RecordEngine tell you when it’s done:- Upload the document with
external_refscontaining a reference ID from your system - When the document is exported (status = Export), the outbound webhook fires with the full payload including
external_refs - Your automation uses
external_refsto match the webhook payload back to the originating record in your system
Option B — Status Polling
If you need the results synchronously (e.g. a user is waiting on a web page):Key Building Blocks
Parsing the Webhook Payload
The webhook payload is a JSON object. The most commonly used fields:Iterating Over Line Items
Line items come as an array. In your automation platform, use an iterator/loop to process each one:line_items from the payload.
Conditional Logic
Add conditions to your scenario to handle different document types differently:| Condition | Action |
|---|---|
confidence_score < 60 | Send a WeCom alert instead of creating the accounting record |
extracted_fields.currency == "CNY" | Route to the China accounting system |
contact_name == "Trusted Vendor" | Skip manual approval, create Bill directly |
line_items array is empty | Create a single-line Bill using total_amount |
Error Handling
Always add an error handler to your automation scenario. If the external system is down or returns an error, you want to:- Log the failure (save to a data store or spreadsheet)
- Send an alert (email or WeCom message)
- Optionally retry after a delay
Testing Your Integration
Use webhook.site for initial testing
Before building your full scenario, point the RecordEngine webhook at webhook.site. Export a document and inspect the exact payload shape — field names, data types, nesting. This prevents surprises later.
Test with a real document
Use a real invoice or document that represents your most common case. Verify every field maps correctly to the destination system.
Test edge cases
Test with: a document with no line items, a document with a missing field, a document in Chinese, a very low confidence document. Confirm your scenario handles each gracefully.