Skip to main content

Custom recognition fields – How to write a good prompt?

Learn how to write an effective prompt for recognising data on your invoices.

Written by Martijn Cornelissen

Available in the Pro and Complete subscriptions.

When creating a custom recognition field in advanced mode, you write a prompt: an instruction in natural language that describes which information should be extracted from the invoice. The clearer and more specific the prompt, the better the result.

This article explains how to build a good prompt, what to do and avoid, and how to improve a prompt when the result is not what you expected.


How does a prompt work?

When using custom recognition fields, the contents of the invoice are analysed by advanced AI. The prompt is the instruction you provide to this AI: it tells the system in your own words what needs to be recognised.

The AI reads the full invoice and tries to return the correct value based on your instruction. The system looks at the text, the layout, and the context surrounding the requested value.


Basic principles of a good prompt

Be specific

Describe as precisely as possible where the value appears on the invoice. Mention the column name, label, or position on the page, for example.

Less effective

More effective

Recognise the amount.

Recognise the amount in the 'Netto' column after the line 'Reiskostenvergoeding'.

What is the licence plate?

Recognise the licence plate listed after the label 'Voertuig' on the first page.

Use the exact language from the invoice

Copy terms, labels, and column headings exactly as they appear on the invoice. The AI looks for exact matches. Do not write what you think is on the invoice — write what is actually there.

Provide context

If a value can appear in multiple places on the invoice, add extra context so the AI selects the correct location.

Example: Recognise the total amount below the barcode in the line after the word "Reiskostenvergoeding" under the column heading "Berekening vergoeding".

Specify the expected output

If you want the AI to return a specific format or value, state this explicitly in the prompt.

Example: Recognise the payment method on the invoice. This can be via direct debit or manual transfer. For direct debit, return the value: "IN". For manual transfer, return "30" or "14", depending on the payment term.


Calculations in a prompt

You can also ask the AI to perform a calculation on the recognised values. This is useful when you want to add up multiple amounts or calculate an amount exclusive of VAT, for example.

Example: Add together the amounts listed after "Emballage Geleverd" and "Emballage Retour" and make the result positive.

The following calculations are supported:

  • Making numbers absolute (converting a negative number to a positive one)

  • Addition

  • Subtraction

  • Multiplication

  • Division

  • Determining the number of days in a month

  • Calculating the number of days between two dates

  • Adding or subtracting days from a date

Please note: A maximum of five calculations per prompt are supported.


Using a lookup table in your prompt

When the recognised value on the invoice does not directly correspond to the value in Zenvoices, you can include a lookup table in your prompt. This is useful, for example, when a licence plate needs to be matched to a cost centre code.

Example: Recognise the licence plate on the invoice. Return the corresponding cost centre code based on the following lookup table: - 17-FGP-5 = KP001 - 34-HJK-2 = KP002 - 09-XLT-8 = KP003

This way, the AI directly returns the correct value without you needing to set up additional mappings.


Tips for improving your prompt

Is the result not matching what you expected? Work through the following steps:

  1. Check the recognised value. View the recognised data via the three dots in the top right of the transaction screen. See what was returned and compare it to what you expected.

  2. Make your prompt more specific. Add more context: refer to a column heading, a label name, or the position on the page.

  3. Check the data type. Make sure the data type in the recognition field matches what you are looking for. For an amount, choose Decimal; for a date, choose Date; for free text, choose Text; and for a from–to date, choose Period.

  4. Re-import the document. After adjusting the prompt, you need to re-import the document to activate the new recognition.

  5. Test with a clear example. Preferably use an invoice on which the value to be recognised is clearly and unambiguously stated.


Frequently asked questions

Do I always need to write a prompt?
No. If the field name appears literally on the invoice, you can also use simple mode and enter only the field name. A prompt is particularly useful when the value is not directly linked to a label, or when you want to apply a calculation or lookup.

How many characters can a prompt contain?

A prompt can contain a maximum of 1,000 characters.

Does a prompt work for e-invoices?

Yes. Prompts are supported for e-invoices (UBL) without an attached PDF.

Can I recognise multiple values with one prompt?

Yes, use the data type Text list, Integer list, or Decimal list for this. The AI will then return multiple found values.

Can a prompt be executed when I manually start the flow via the 'Line item recognition' button in the transaction screen?

No, this is currently not yet supported.

Did this answer your question?