Connecting an AI assistant to an ERP system sounds simple: give it access to business data, let it understand a question, and return an answer.
But consider a question like:
Which products are available for delivery this week?
The answer may depend on warehouse, stock reservations, incoming shipments, product units and the meaning of "available" in that business.
Giving an AI model direct access to ERP tables does not solve this problem. It can create new risks, including incorrect queries, inconsistent business definitions and access to information the user should not see.
Before connecting AI to an ERP system, developers should also assess the quality, consistency and accessibility of the underlying data. This guide to preparing ERP data for AI applications explains the key readiness considerations to address before integration.
A better approach is to place a controlled data access layer between the AI application and the ERP.
1. Don't Let the Model Query the Database Directly
An ERP database contains relationships, internal fields and business rules that an AI model may not understand.
Instead of allowing the model to generate and execute arbitrary SQL, expose a limited set of application functions.
For example:
get_product_availabilityget_customer_order_statusget_sales_summaryget_purchase_order_details
Each function should have a clear purpose and a defined contract, including:
- Required and optional input parameters.
- Expected data types and validation rules.
- A predictable response structure.
- Defined error responses.
The AI can identify which function is relevant and provide the required parameters. The backend should treat these arguments as untrusted input, validate them against the function schema and enforce business constraints before retrieving data.
Database queries should use parameterized statements rather than directly inserting model-generated values into SQL. Functions should also operate with only the database permissions they need.
This keeps database access and business logic under application control.
2. Give Business Terms a Clear Meaning
A common problem in ERP applications is that everyday business terms can have different meanings.
Take the word "stock."
Does it mean:
- Physical quantity currently in the warehouse?
- Quantity available after reservations?
- Expected quantity after incoming and outgoing movements?
These values are not interchangeable.
The data access layer should define what each function returns. For example, a stock availability function might return the product, warehouse, on-hand quantity, reserved quantity and available quantity as separate fields.
The application should calculate these values using the ERP's established business logic rather than asking the model to work them out from unrelated database fields.
3. Preserve User Permissions
An AI assistant should not have broader access than the employee using it.
Authentication establishes who the user is. Authorization determines which records and actions that user is allowed to access.
Imagine a sales employee asking for customer information. The assistant should not return financial or operational records that the employee is not authorised to view.
The data access layer should:
- Use the authenticated user's identity from a trusted session or token.
- Apply the relevant access rights and record-level rules.
- Restrict the requested data to the user's permitted scope.
- Validate permissions before returning results.
Do not trust a user ID or company ID supplied by the model as proof of identity or permission. The application should derive or validate the permitted scope from trusted user context.
This is especially important when multiple companies, departments or business units share the same ERP. A request must not expose records from another company or tenant simply because the model supplies a different company identifier.
These checks must also apply when data comes from a cache, not just when it is retrieved directly from the ERP. Cache keys and stored results should be scoped appropriately so that one user's or company's data cannot be returned to another without authorization.
4. Handle Data Freshness
Not every ERP question needs the same update frequency.
A monthly sales summary may work with scheduled data updates. A warehouse assistant answering questions about current availability may need a live query or a much shorter refresh interval.
Caching can help reduce repeated queries, but its expiry and invalidation rules should reflect how quickly the underlying data changes.
For example, caching a monthly sales report is different from caching current stock availability.
The application should also make data freshness visible. A response can include when the data was retrieved and which warehouse or reporting period it covers.
If the source system is unavailable or the data is too old for the requested operation, the assistant should communicate that limitation rather than present outdated information as current.
5. Return Context the Model Can Actually Use
A good data access function should return structured, meaningful results rather than a large collection of raw database fields.
For example:
{
"product": "Product A",
"warehouse": "Main Warehouse",
"on_hand": 100,
"reserved": 25,
"available": 75,
"unit": "Units",
"retrieved_at": "2026-11-25T10:30:00Z"
}
These are illustrative values. The actual response should follow the ERP's business rules and data model.
The output should distinguish between a valid zero value, a missing value and a failed query. These situations mean different things and should not be treated as equivalent.
Keep responses focused on the information needed for the user's question. This reduces unnecessary context and makes the result easier for the model to interpret.
6. Test the Data Layer Before Expanding AI Access
Before connecting more ERP modules, test the functions with realistic questions and different user roles.
Check whether:
- The returned values match the ERP screens or reports.
- Business calculations use the correct definitions.
- Restricted records remain inaccessible.
- Company and tenant boundaries are enforced.
- Cached data is refreshed when required.
- Missing or outdated data is handled clearly.
- Errors do not turn into misleading AI answers.
- Concurrent requests and repeated function calls return consistent results without unintended side effects.
Also test edge cases, such as products with no stock, partially reserved quantities and users who have access to one warehouse but not another.
Final Thoughts
An AI assistant does not need unrestricted access to an ERP database to be useful.
It needs a reliable way to retrieve the right information, understand its business meaning and respect the permissions of the person asking the question.
A well-designed data access layer provides that boundary. It allows AI to work with business information while keeping data retrieval, validation and access control within the application.
The result is not just a better AI response. It is a more dependable way to connect AI with real business workflows.
This article was prepared with AI assistance and reviewed for technical accuracy by the author.
Top comments (0)