Quick overview
This workflow monitors an IMAP inbox for emails with invoice attachments, uses OpenAI to OCR and extract structured invoice data, looks up customers and tax/currency settings in Zoho Books, and then creates a new Zoho Books invoice with the original attachment included.
How it works
- Triggers when a new email arrives via IMAP.
- Filters for emails that contain attachments, then splits each attachment into its own item for processing.
- Normalizes each attachment’s binary data and routes it to OpenAI for OCR based on whether it is a PDF or an image.
- Fetches taxes, currencies, and active customer contacts from Zoho Books and prepares the data for matching and invoice creation.
- Sends the OCR text plus Zoho Books tax metadata to OpenAI to validate that the document is a sales invoice and to return invoice and customer details as JSON.
- Filters out non-invoice attachments, matches the extracted customer to an existing Zoho Books contact (with a configurable fallback), and posts a new invoice to Zoho Books using multipart upload to attach the original file.
Setup
- Add IMAP credentials for the mailbox that receives invoice emails.
- Add Zoho Books OAuth2 credentials and ensure the connection has permission to read contacts/settings and create invoices.
- Add an OpenAI API credential for the OCR and invoice-parsing steps.
- In “Define Workflow Constants”, set your Zoho data center domain (for example, com/eu), your Zoho Books organization ID, and an “unknown_customer_static_id” fallback contact ID.
- If you enable sender-based customer lookup, update “customerLookupIgnoreList” with internal/staff email addresses to prevent incorrect matches.