Recognize VAT invoices with OCR
1. Component introduction
Prerequisites: None
Recommended subsequent component: Conditional Branch. You can use a branch condition to check whether the OCR call was successful and then design the subsequent flow.
This component uses OCR to recognize key fields on special, general, and electronic VAT invoices. These fields include the invoice code, number, and issue date. For more information, see Example.
2. Inputs
For information about each input, see the help text in the component panel of the application flow editor.
3. Outputs
For information about each output, see the help text in the component panel of the application flow editor.
3.1. Key API return results
This output returns a dictionary of key recognition results from the API. The following table describes the keys and values in the dictionary.
Key |
Key meaning |
Value data type |
invoiceCode |
Invoice code |
string |
invoiceNumber |
Invoice number |
string |
invoiceDate |
Issue date |
string |
machineCode |
Machine code |
string |
checkCode |
Check code |
string |
purchaserName |
Purchaser name |
string |
passwordArea |
Password area |
string |
invoiceAmountPreTax |
Amount before tax |
string |
invoiceTax |
Tax amount |
string |
totalAmountInWords |
Total amount in words |
string |
totalAmount |
Total amount |
string |
sellerName |
Seller name |
string |
sellerTaxNumber |
Seller tax ID |
string |
sellerContactInfo |
Seller address and phone number |
string |
sellerBankAccountInfo |
Seller bank and account number |
string |
drawer |
Issuer |
string |
title |
Title |
string |
invoiceType |
Invoice type (General Electronic Invoice, Special Electronic Invoice, Special Invoice, General Invoice, or Universal Invoice) |
string |
3.2. Error message
This output returns the error code and error message as a string. For more information, see the OCR Error Center.
https://next.api.aliyun.com/document/ocr-api/2021-07-07/errorCode
4. Component usage example
4.1. Component configuration example
For AI engine, select Alibaba Cloud OCR.
For Image file path to recognize, enter the path of the image file. This example uses the following image.

Keep the default values for the advanced options.
4.2. Example execution result

5. Flow example
5.1. Build the flow
Use the Recognize VAT Invoices with OCR component to specify the path of the image file to be recognized.
Use the Conditional Branch component to check whether the OCR call was successful. Set the condition so that `v_recognize_invoice_success_1` is equal to the Boolean value `True`.
In the success branch, use the Get Value of a Specified Key component to retrieve a specific key from the dictionary of API return results. This example retrieves `purchaserName` (Purchaser name).
Use the Log Record component to print the retrieved value.
In the failure branch, use the Log Record component to print the error message.

5.2. Execution result
As shown in the following figure, after the OCR service call succeeds, the recognition result is printed in the log panel.