> For the complete documentation index, see [llms.txt](https://docs.charted.com/ap-automation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.charted.com/ap-automation/charted-configuration/invoice-ai/ai-directions.md).

# AI Directions

This page covers writing a Direction, which tells Invoice AI **how to read a document**. It opens with how to choose between a Direction and the other tools, because choosing the wrong one will not produce the result you want.

Open **Charted > AP Automation > Settings**, then press **AI Directions** in the left navigation under Invoice Automation.

## Choosing the right tool

Invoice AI processes most documents correctly using its default logic and what it learns from your corrections. Directions, Rules and Auto-Fill Fields exist for what remains.

| What you are seeing                                                                                                     | The tool                                                                                                         |
| ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| A field in the default set is not populating correctly, and Invoice AI has not yet seen many documents from that vendor | None. Give learning time to work.                                                                                |
| A field outside the default set, which your team sets to the same value for a vendor every time                         | [Auto-Fill Fields](https://docs.charted.com/ap-automation/charted-configuration/invoice-ai/advanced-settings.md) |
| Invoice AI is reading a value from the document incorrectly                                                             | A Direction                                                                                                      |
| Invoice AI reads the value correctly, but something must happen to it afterwards                                        | A [Rule](https://docs.charted.com/ap-automation/charted-configuration/invoice-ai/rules.md)                       |

### Directions and Rules compared

A Direction governs extraction, how Invoice AI reads your document. A Rule governs handling, what Invoice AI does with a value after reading it. Invoice AI applies both while it scans, before anyone sees the draft.

| Concept                      | Directions                                               | Rules                                                            |
| ---------------------------- | -------------------------------------------------------- | ---------------------------------------------------------------- |
| What it acts on              | How Invoice AI reads the document                        | What Invoice AI does with the value afterwards                   |
| How you write it             | Instructions in ordinary language                        | Conditions and actions                                           |
| Does Invoice AI interpret it | Yes                                                      | No                                                               |
| What it can reach            | Header and line fields                                   | Header fields only                                               |
| Typical use                  | Unusual formats, translation, custom fields, page ranges | Assigning a vendor or subsidiary, routing a document to a person |

A Rule reaches header-level fields only. Where your requirement is at line level, the tool is a Direction, in most cases a [custom field extraction](https://docs.charted.com/ap-automation/charted-configuration/invoice-ai/custom-field-extraction.md).

### Where Directions sit in line coding

For line coding on documents without a purchase order (PO), Invoice AI works through three levels and stops at the first that produces an answer.

<table><thead><tr><th width="100">Priority</th><th width="200">Level</th><th>What it is</th></tr></thead><tbody><tr><td>1</td><td>Your Directions</td><td>Instructions that guide how Invoice AI codes the document during scanning</td></tr><tr><td>2</td><td>Learning</td><td>Patterns from that vendor's earlier documents</td></tr><tr><td>3</td><td>Configured defaults</td><td>Default Bill Line Type, plus defaults such as the expense account on your vendor record</td></tr></tbody></table>

On a document backed by a purchase order this does not apply. The purchase order supplies the line coding and is the source of truth.

Because a Direction outranks learning, one that matches a vendor's documents wins over the corrections your team has made. See [Why isn't Invoice AI coding this vendor the way we corrected it last time?](https://docs.charted.com/ap-automation/charted-faqs/invoice-ai/why-isnt-invoice-ai-coding-this-vendor-the-way-we-corrected-it-last-time.md)

## Before you write one

Invoice AI learns from the corrections your team makes, and most extraction problems resolve once it has seen a few documents from a vendor. Give that time to work. A Direction written too early locks in behavior that would have corrected itself, and logic written against a document you have not yet received tends to introduce errors rather than remove them.

Wait until you have real invoices from the vendor in front of you. You cannot write a good Direction from a hypothetical.

{% hint style="info" %}
Rules that assign a subsidiary or route documents to a person are the exception. Write those before go-live when your requirement is specific and defined, and you cannot wait for learning to begin.
{% endhint %}

## What to use a Direction for

| Your situation                                                                                   | Example                                                     |
| ------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- |
| Invoice AI consistently reads a value from the wrong place, and corrections have not resolved it | It captures the subtotal instead of the total               |
| A value sits in a specific spot on the page                                                      | The number next to "Contract #" in the header               |
| Your invoices arrive in another language                                                         | Translate from French before extracting                     |
| Only part of the document should be read                                                         | Your vendor sends 20-page packets and the invoice is page 1 |
| A field is not part of the default extraction set                                                | A meter number that belongs on a custom field               |

The last row is a [custom field extraction](https://docs.charted.com/ap-automation/charted-configuration/invoice-ai/custom-field-extraction.md), a specialized kind of Direction. A general Direction gives broad guidance about reading a document, such as translating it or handling an unusual layout, and is not intended for pulling out one specific value.

A general Direction can also include examples, and the output you expect from them, to improve accuracy.

## What a Direction cannot do

* It cannot apply if-then logic. Write a Rule for that.
* It cannot reference or change NetSuite data outside what Invoice AI extracts.
* It does not override values taken from a linked purchase order. Your purchase order is the source of truth for those bills.

## Writing a Direction

1. On the AI Directions list, press **Create AI Direction**.
2. Enter a descriptive **Direction Name**.
3. Enter **Identifying Document Keywords**. These tell Invoice AI which documents the Direction applies to. Separate several keywords with commas.
4. In the **AI Directions** field, write your instruction in plain language.
5. Leave **Page Start** and **Page End** blank unless the document has appended pages Invoice AI should not read, such as supporting documentation or terms-and-conditions sheets. Scanning those pages can add lines to the bill that you do not need. To stop after page 2, enter **2** in **Page End**.
6. Press **Save**.

A Direction applies to one set of documents. To apply the same instruction to several vendors, create a Direction for each.

## Choosing keywords

Your keywords decide when the Direction fires, so they matter more than the instruction text.

{% hint style="warning" %}
Keywords use "All" match logic rather than "Any". A document must contain every keyword you listed for the Direction to fire, so adding more keywords narrows the match rather than widening it.
{% endhint %}

Use something that appears consistently and uniquely on that vendor's documents, such as an account number, a tax identification number or the vendor's name. When in doubt, use the most specific keyword available.

Avoid common words that appear across many vendors. Invoice AI will fire the Direction on documents you did not intend and its accuracy on them will fall.

Entering a single period, `.`, and nothing else applies the Direction to every document Invoice AI processes. Use it only for something that genuinely should affect everything, such as translation in an account that receives exclusively non-English invoices.

## Translating invoices

Write the instruction plainly, such as "Translate this bill from Spanish to English before extracting fields."

Invoice AI supports English, Spanish, French, German, Italian and Portuguese with high confidence. It can process other languages, but extraction accuracy may be lower and translation results less reliable.

## Next

[Custom field extraction](https://docs.charted.com/ap-automation/charted-configuration/invoice-ai/custom-field-extraction.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.charted.com/ap-automation/charted-configuration/invoice-ai/ai-directions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
