How to automatically parse receipts in Flow Builder

In this guide, you’ll learn how to automatically extract information from incoming photos of receipts 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!

Recommendations:

  • 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 receipt 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 examples below.

Example input

Example output

"total_amount": 140,

"purchase_timestamp": "1578418800",

"supplier_name": "Museumfoto",

"supplier_address": "Eggertstraat 2\n1012 NN Amsterdam\nNederland",

"total_tax_amount": 24.3,

"currency": "EUR"

Step-by-step: Setting up a receipt 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 Receipt.

  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 receipts from the “Museumfoto” company, so we will match the image_content.supplier_name with “Museumfoto”.

  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