This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/workflow-automation/ai-capabilities-in-workflow/prompt-engineering.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Prompt engineering for AI features

In Nutrient Workflow Automation, a prompt is the instruction you give an AI model about what to do with a document or workflow task. Prompt quality affects how accurately fields are populated, how consistently the same input produces the same result, and how much manual cleanup is needed downstream.

This guide covers prompt engineering techniques that apply across AI features in Nutrient Workflow Automation, including the AI Data Extraction task and agentic approval.

The right mental model

Treat the AI as if it has no prior context about your document, business, or intent. It won’t ask clarifying questions, and it won’t fill gaps the way a human teammate does.

To get the best results, be explicit and write in natural language. The clearer the instruction, the more reliable the response.

Core principles

Effective prompts share four traits:

  • Clarity — State exactly what to extract. Don’t assume the model will infer intent.
  • Specificity — Describe each field so the AI knows what it’s looking for.
  • Grounding — Instruct the AI to rely only on the uploaded document, not on its training data.
  • Consistency — Use the same field names in the prompt that you use in mappings.

Anatomy of a good prompt

Structure each prompt in three parts:

  • Role — Tell the AI what it’s doing (for example, extracting invoice data, recommending approvals, generating a form).
  • Fields — List each field and describe what to extract.
  • Rules — Explain how to handle missing data and what not to do.

Example:

You are an invoice data extraction assistant. Extract the following information from the attached document:
1. Issue date — The date the invoice was created.
2. Customer ID — The unique identifier assigned to the customer.
3. Payment terms — When and how payment should be made.
4. Invoice due date — The date by which payment is due.
5. Total amount due — The full amount owed.
Rules:
- Use only information present in the document. Do not guess or infer values.
- If a field isn’t present, return "Not available."

Techniques that improve accuracy

Follow these techniques to improve the accuracy and reliability of AI results.

Describe each field

A field name alone is often ambiguous. Date often refers to an issue date, due date, or received date. Add a short description next to every field so the AI knows which value to return.

- Invoice date — The date printed at the top of the invoice, not the payment date.
- Due date — The final date payment is accepted without penalty.

Prevent hallucinations with explicit grounding

AI models sometimes produce plausible-looking values when data is missing. Reduce this risk by telling the AI to:

  • Use only information visible in the document.
  • Return a placeholder — for example, "Not available" — when a field is missing.
  • Avoid guessing, inferring, or completing partial data.
Only provide information you are 100 percent sure about. If you are unsure, or the data is not in the document, respond with "Not available."

Handle variation with conditional rules

Real-world documents vary. Add conditional rules so the AI knows how to handle edge cases:

- If the document contains multiple invoices, extract only the first.
- If "Bill To" and "Ship To" differ, use "Bill To" for customer name.
- If currency is not USD, include the ISO currency code alongside the amount.

Use examples for tricky fields, but sparingly

When a field format varies across documents — for example, addresses, tables, or multiline notes — show the AI one example input and the expected result. A single, well-chosen example often works better than several paragraphs of instructions.

Avoid adding too many examples. The AI often overfits to the patterns it has just seen, so a prompt with many invoice examples often produces results that resemble those examples, even when the actual document differs. One or two examples that illustrate a specific edge case usually work better than a long list of similar samples.

Keep prompts focused

Packing many unrelated fields into a single prompt reduces accuracy across the board. When a prompt grows unwieldy, split the work across multiple AI tasks or questions, each with a narrower scope.

Iterative testing

Treat prompts as configuration that you refine over time.

  1. Collect a small set of sample documents that reflect real variation — clean, messy, edge cases, and non-English if relevant.
  2. Run the prompt against each sample and review the AI response.
  3. Adjust the prompt one change at a time. Add a description, tighten a rule, or introduce an example. Then, retest.
  4. Confirm the mapped fields populate as expected.
  5. Repeat with additional samples before deploying the form or process.

Common pitfalls

Beware of these common pitfalls when writing prompts:

  • Vague field namesAmount is ambiguous. Prefer Total Amount Due or Subtotal Before Tax.
  • Missing format hints — Without guidance, the AI often returns March 14, 2026, 14/03/2026, or 2026-03-14 on different runs. State the expected format when precision matters.
  • Asking about real time or relative time — AI models do not have a reliable sense of “today.” Questions like “Is this date in the future?”, “Has this invoice expired?”, or “How many days until the due date?” often produce inconsistent or incorrect answers because the model’s internal reference date isn’t the current date. Extract the raw date instead and evaluate it in a later workflow step.
  • Expecting identical output on every run — Even at temperature 0, responses vary slightly. Design downstream logic to tolerate minor differences in whitespace, capitalization, or word order.
  • Ignoring document quality — Scanned, rotated, low-resolution, or handwritten documents often produce worse results than digital PDFs. If your workflow accepts scans, test with representative scanned samples.
  • Overloaded prompts — Combining unrelated extractions in a single prompt reduces accuracy. Split the work.
  • Over-specifying the response format — Workflow Automation handles response parsing. Focus the prompt on the information you want the AI to extract or generate.

Tuning model behavior

When a prompt is solid but responses still vary, tune the model parameters in Advanced Settings — especially Temperature and Top P. Adjust one setting at a time, not both, since the two parameters interact. Lowering temperature often makes outputs more consistent, but it doesn’t make a weak prompt more accurate. Grounding instructions in the prompt remains the primary defense against hallucinations. For more information, refer to the advanced AI settings guide.

Example: Refining a prompt over three iterations

The following example shows how to apply the principles above to refine a prompt for extracting data from invoices. The first iteration is vague and produces unreliable results. The second iteration is clearer but still leaves room for interpretation. The third iteration is production-ready, with explicit instructions, field descriptions, and grounding rules.

Iteration 1 — Vague, unreliable

Extract invoice data.

Iteration 2 — Clearer, but still loose

Extract the invoice number, date, customer, and total from the attached invoice.

Iteration 3 — Production-ready

You are an invoice data extraction assistant. Extract the following fields from the attached document:
1. Invoice number — The identifier printed at the top of the invoice.
2. Invoice date — The date the invoice was issued (not the due date).
3. Customer name — The name of the billed party under "Bill To".
4. Total amount due — The final amount owed, after tax and discounts.
Rules:
- Use only text that appears in the document. Do not infer or guess.
- If a field is missing, return "Not available."

Each iteration makes the prompt more precise, improves mapping reliability, and reduces downstream cleanup.