Building an ERP Q&A bot: the hard part wasn't the model, it was defining "open deal"
Material-Link9151 · reddit · 2026-09-16
A developer shares lessons from building an internal Teams bot on Dynamics 365 Business Central. The write side (create customer, etc.) was fine; query side ("my open deals," "Q2 revenue by product group") kept failing:
- V1 had the model pick from a menu of 8 aggregate functions with params — worked in demos, collapsed on real questions, never converging as every reviewer found new edge cases.
- Current approach: the model writes a small plan, a compiler turns it into SQL, executed against an in-memory SQL store loaded from BC rows every few minutes.
- Biggest lesson: most pain was definitions, not the model. "Open deal" took days to pin down (status? invoiced qty below contract? tolerance? per deal or per unit?), plus traps like credit notes on cancelled invoices.
- Management's rule: a wrong number is worse than no number, so the bot refuses when it doesn't understand a term.
He asks the community about glossary handling, refresh strategy (timer reload / incremental / live BC), shipping criteria, whether AL query objects or custom API pages beat walking OData, and whether anyone did text-to-SQL and regretted it.
More from coding & agent
- Atom goes live on Stripe's Machine Payments Protocol, letting AI agents buy domains autonomously — jeff_weinstein · 2026-09-16
- Astra Is Flawless for Hours, Then Randomly Stops and Makes Up Excuses — altryne · 2026-09-16
- Agent-installed skill/CLI survives a VM temp files wipe — MurrLincoln · 2026-09-16
- ComfyUI MCP + Claude diagnosis cuts video gen workflow from 22 to 9 minutes — CanadianDocWild · 2026-09-16
- A senior Google AI engineer's 482-page doc on agentic design patterns — mdancho84 · 2026-09-16
- Developer adds reusable saved tasks to a browser agent, prompts now work across repos — Silly_Entertainer92 · 2026-09-16