How to automatically Parse Invoices in Flow Builder

In this guide, you’ll learn how to automatically extract information from incoming photos of invoices using the Analyze Image step in Flow Builder.

What you'll need

Image quality best practices

When working with text recognition (OCR), it’s a good idea to provide your customers with tips on how to upload quality images that will allow for correct text extraction. If you’ve ever had to sign up for an online banking service and uploaded a photo of your ID, you’ll probably be familiar with some of these guidelines!


  • Placement: Make sure that the whole document is visible within the image. Don’t cut off any corners.

  • Orientation: Position the document with its original orientation. Avoid tilted images.

  • Supported file types: JPEG, PNG, and PDF.

Input and output examples

When the Analyze Image step is configured for parsing invoice documents, the output will be a JSON object containing all detected properties. You can choose to make use of the whole object, or a certain property. Take a look at the example below.

Example input

Example output

"invoice_id": "US-001", "total_amount": 154.06, "supplier_name": "East Repair Inc.", "supplier_address": "1912 Harvest Lane\nNew York, NY 12210", "total_tax_amount": 9.06, "freight_amount": 15, "currency": "USD", "purchase_order": "2312/2019", "payment_terms": "Payment is due within 15 days", "ship_to_address": "3787 Pineview Drive\nCambridge, MA 12210", "receiver_name": "John Smith", "receiver_address": "2 Court Square\nNew York, NY 12210", "receiver_tax_id": "2312/2019", "net_amount": "145", "remit_to_name": "East Repair Inc.", "vat": "9.06"

Step-by-step: Setting up an invoice parsing flow

In this quickstart, we'll set up a flow that demonstrates how to automatically extract data from a receipt image and send it back to the user is the receipt belongs to a certain company.

  1. Log in to your MessageBird Dashboard and navigate to Flow Builder.

  2. Select an existing flow or create a new one. For this example, we're going to create a new custom flow with a Telegram trigger.

  3. Add the Analyze Image step to your flow.

  4. In the step's settings, under Image content to recognize, select Document.

  5. Under Document type, select Invoice.

  6. In the Output variable field, type image_content

  7. Click Save.

  8. Add a branch step and check if the value of image_content.supplier_name matches the company name you would expect with a custom condition. For this example, we only want to consider invoices from the “Messagebird” company, so we will match the image_content.supplier_name with “Messagebird”.

  9. In the success branch, add a Reply to channel message step. Add the image_content variable as the content. This will access the whole raw output instead of a single property.

  10. Publish your flow in the top-right corner of your screen, and you're good to go!

  11. Here's how it should look when you test it!

Last updated