How to add AI agents to SAP Business One
Short answer
Build agents as a thin tool layer over the Service Layer (or DI API on older setups), start read-only, and let write actions land as draft documents that a person approves. The model can be a cloud API or an open-weight model on your own GPUs, because the agent only needs structured results from your B1 database.
Most SAP Business One shops are small to mid-size manufacturers and distributors where one or two people hold the whole picture in their heads: which sales orders are late, which items keep running short, which vendor always ships a week behind. Those same people spend their days in Query Manager, Crystal reports and Excel. An AI agent is attractive because it can do the repetitive reading and cross-checking for them.
The catch is that Business One is not a system you should let a model write into freely. Documents are tied to the general ledger, inventory valuation and approval procedures. The workable pattern is an agent that reads widely, reasons about it, and proposes. Where it writes at all, it writes drafts that go through the same approval route as a human entry.
This page walks through the tool layer, the order of build, and the traps that are specific to B1: licence consumption on the Service Layer, session handling, user-defined fields, and the difference between HANA and SQL Server editions.
What teams use it for
Late order and shortage triage
An agent reads open sales orders (ORDR/RDR1), on-hand and committed quantities (OITW), and open purchase orders (OPOR/POR1), then produces a ranked list of orders that cannot ship on time and why.
Purchase suggestion review
After the MRP wizard runs, the agent checks recommendations against vendor lead times, minimum order quantities and recent price history, and flags the ones that look wrong before a buyer converts them.
Draft purchase orders for approval
For approved shortages, the agent creates draft purchase orders through the Drafts entity so the buyer sees them in the normal draft list and approval procedure.
Production order exception watch
The agent scans released production orders for missing components, overdue due dates and issue-versus-plan variances, and writes a short morning summary for the planner.
Customer payment follow-up
Using open invoices and incoming payment data, the agent drafts reminder emails with the right invoice references and flags accounts that exceed credit limits.
Master data hygiene
The agent finds items with no warehouse default, business partners with missing tax data, and duplicate vendor names, and proposes corrections for a data steward to apply.
SAP Business One integration surface
- Service Layer: the REST/OData endpoint (commonly under /b1s/v1) that exposes business objects such as Orders, PurchaseOrders, Items, BusinessPartners, ProductionOrders and Drafts. Login returns a session cookie; sessions time out and must be renewed.
- SQLQueries and user query views: saved queries can be exposed through the Service Layer, which gives the agent pre-vetted read shapes instead of free-form SQL. Exact availability depends on the B1 version and patch level.
- DI API: the older COM-based API used by add-ons and some integrations. It still works on many installs but ties you to Windows and to the client library version.
- Direct database access (SAP HANA or Microsoft SQL Server): fastest for read-heavy analysis through a read-only database user, but bypasses B1 authorisations, so keep it to non-sensitive reads.
- Integration Framework (B1if) and event hooks such as the transaction notification stored procedure: useful for triggering an agent when a document is added or changed.
- User-defined fields and tables (UDFs, UDTs): most customised B1 systems keep important logic here, so the agent's tool schema must include them.
How it works
- 1
Pick one narrow workflow
Choose a job with clear inputs and a checkable output, such as shortage triage. Avoid starting with an agent that tries to run purchasing end to end.
- 2
Create a dedicated B1 user
Make an agent user with limited authorisations and no ledger access. Remember that Service Layer calls consume a licence, so plan for one named or concurrent licence rather than sharing a person's login.
- 3
Wrap the Service Layer as tools
Write small functions: get_open_sales_orders, get_item_availability, get_open_purchase_orders, get_vendor_history. Each returns trimmed JSON with only the fields the model needs, and uses $select, $filter and paging rather than dumping whole documents.
- 4
Handle sessions and errors
Cache the B1SESSION cookie, refresh on a 401, and respect Service Layer paging limits. Return clear error text to the model so it can retry or stop rather than invent an answer.
- 5
Add write tools as drafts only
Expose create_draft_purchase_order, not create_purchase_order. A buyer reviews it in B1 and approval procedures still apply. Log every draft the agent created with its reasoning.
- 6
Test on a copy of the company database
Restore a recent backup to a test company and replay real situations. Check that UDFs, multiple warehouses and unit-of-measure groups are handled correctly.
- 7
Schedule and monitor
Run the agent on a timer or from a B1if event, send results to email or chat, and track how often people accept its suggestions. Retire tools nobody uses.
Example flows
Morning shortage report
Trigger: Scheduled at 6:30 each weekday.
- Agent pulls open sales orders due in the next ten days.
- It checks available quantity per warehouse and open purchase order receipts.
- It looks up vendor lead time for each short item.
- It writes a ranked list with a one-line reason per line.
Result: The planner starts the day with a prioritised list instead of building it by hand.
Draft PO from approved shortage
Trigger: Planner clicks approve on a shortage line in a shared sheet or chat message.
- Agent re-reads current availability to confirm the shortage still exists.
- It selects the preferred vendor and last price from purchasing history.
- It posts a draft purchase order through the Drafts entity.
- It notifies the buyer with a link and the supporting numbers.
Result: The buyer reviews a prepared draft and converts it, with the approval procedure intact.
Keeping data on-prem
Business One is frequently run on a local server, so keeping the agent on-prem is natural. Run the tool layer on the same network as the Service Layer, and serve an open-weight model on a GPU server in your own rack or private cloud so that item costs, customer pricing and vendor terms never leave the building. Tool results are small structured payloads, which means a mid-sized model is often enough. If you prefer a cloud model for reasoning, send only the trimmed tool output and keep names and prices masked where possible. For air-gapped sites, the whole stack, model included, runs without internet access.
Security checklist
- Use a dedicated B1 user with the minimum authorisations; never reuse a manager's credentials.
- Keep the agent read-only by default and make every write a draft.
- Store the Service Layer credentials in a secrets manager, not in prompts or config files.
- Log every tool call with parameters and the document keys returned, for audit.
- Restrict network access so the Service Layer port is reachable only from the agent host.
Ways to get it done
SAP's own AI features and add-ons
Effort: Low, mostly configuration.
Fine if your version and licence already include the assistant you need and the use case is generic, such as simple search or summarisation.
Build in-house on the Service Layer
Effort: A few weeks for a first read-only agent, longer for drafts and monitoring.
Good when you have a developer who knows B1 and a narrow first workflow. You own the tool code and model choice.
Partner-delivered, including Netray with a B1 partner
Effort: Typically a scoped pilot first, then expansion by workflow.
Useful when you want an on-prem model, a tested tool layer and B1 domain knowledge delivered together.
Pitfalls
- !Letting the agent query tables directly and missing UDFs, which often carry the real business rules.
- !Forgetting that Service Layer sessions expire and that heavy parallel calls can exhaust licences.
- !Posting live documents instead of drafts and skipping the approval procedure.
- !Returning entire documents to the model, which wastes tokens and invites wrong answers.
- !Ignoring multi-warehouse and unit-of-measure conversions, so availability numbers are wrong.
Frequently asked questions
Can an AI agent write directly into SAP Business One?
Technically yes through the Service Layer, but it is wiser to have it create drafts. Drafts show up in the normal draft list, pass through approval procedures and let a person confirm before anything touches stock or the ledger. Keep direct posting for narrow, low-risk cases you have tested thoroughly.
Do I need the Service Layer or can I use the DI API?
The Service Layer is the better choice for new work because it is REST-based and platform independent. The DI API still works for existing add-ons and some older versions, but it is tied to Windows and the client library. Which one you can use also depends on your version and database.
Will it work on SQL Server and on HANA editions?
Yes, if you go through the Service Layer, since the objects are the same. Direct SQL differs between the two, so read queries need small dialect changes. Check your version's documentation for Service Layer support on your database.
Does the agent use up a B1 licence?
A Service Layer login normally consumes a licence of the type assigned to the user. Plan for a dedicated user and check your licence agreement for how indirect or integration access is treated. This varies by contract, so confirm with your SAP partner.
Can the model run without internet?
Yes. Open-weight models served with vLLM or Ollama on your own GPU hardware can drive the agent with no outbound connection. Sizing depends on how many users and how complex the tools are, so start small and measure.
Want AI agents working on your SAP Business One?
A free 30 minute assessment: we map the integration path for your version and setup, and where it should run.
Get a free assessment