ChangAI - AI for ERPNext
How We Started Building an AI for Business Owners - and Where We're Headed
“How much mango should I stock before the season ends?”
That was the question a vegetable stockist asked our sales team while they were demonstrating our ERP system — and if you’re even slightly unfamiliar, ERP is the software backbone that runs everything in a business: sales, stock, accounts, you name it.
At first glance, it seemed like a simple question, even expected. After all, a good ERP should be able to help with that, right?
Our team responded in the traditional way:
“Take sales reports from the last two or three years, check the leftover stock at the end of each season, calculate the sales growth… then estimate how much to reorder.”
It was logical. It was standard. But it wasn’t enough.
The business owner shook his head and replied, “Are you guys still living in the age before AI? Haven’t you grown in the last 20 years?”
That stung. But he was right. From that moment on, we knew we had to do better. We set out to build something more than just a reporting tool — an AI assistant that could understand respond with clarity, context, and insight.
From Reports to Responses
After all, we’re ending the era of Excel sheet calculations and moving into an age where we can simply ask AI for answers. Right? We’re all becoming habitually hesitant to read reports or do manual calculations. Two generations ago, people moved from mental arithmetic to calculators. The generation after them shifted from calculators to Excel. And now, everyone is moving toward AI.
Is there any point in holding that back or delaying it? Or should we just go along with the change? As ERP providers, do we even have an option?
So, we started building an AI that works with Frappe ERPNext — the amazing, open-source ERP platform that businesses everywhere are turning to.
We haven’t built the all-knowing business AI. We’ve started.
And every day, we’re getting closer.
We at ERPGulf are building a retrieval-based AI chatbot for ERPNext users — it’s called #Changai. The goal? To save real business owners the time and effort of digging through reports just to get a simple answer.
For example, if you ask #changai
“Show me Blanket Orders expiring next month.”
A simple question, but beneath it, the gears are turning.
The How?
For the curious programmers wondering how — here’s a quick breakdown.
Before going through that, you may need to have some understanding of how AI works, what dataset and model etc. Youtube has millions of video on that, and if you hate all those millions you can watch our video starting from 42 minutes here.( https://youtu.be/WBMae6luW8o?t=2552 ) . We tried to explain the iconic research paper “Attention is all you need” which is the foundation of all AI things you see around.
The chatbot goes through two phases: Phase 1 generates the query, and Phase 2 executes it.
Phase 1: Getting the query
Listening comes first for #changai. Not all messages are worth answering. You might have read recently that, chatGPT gets many hellos and thanks and other niceties, for which they spend millions to process. We aren’t recommending dropping niceties all together, but in #changai we need to classify it.
So, the first model here to do that is RoBERTa —
In #changai We’re using RoBERTa to make sense of what users are really asking.
Is this small talk?
Is it a clear, complete question?
Is it a follow-up to a past question?
Or maybe just an incomplete thought?
RoBERTa helps us classify these inputs so our AI knows how to respond — whether that means fetching a report, continuing a past conversation, or just asking the user to rephrase. It’s like giving the chatbot some common sense.
When it’s a complete question, four models are at work, going through three stages:
Stage 1: RoBERTa, the Doctype Detective
When a user asks a question like “How many invoices were unpaid last month?”, the first challenge is knowing what they’re talking about. That’s where our RoBERTa model comes in. Trained for classification, it scans the question and smartly figures out the relevant doctype — like “Sales Invoice” in this case. No matter how the question is phrased, RoBERTa helps ground the query in the right doctype, setting the stage for deeper understanding.
Stage 2: sBERT & Flan T5-Base — Field Whisperers
Once we know the doctype, the next task is figuring out which fields in that doctype actually matter. sBERT (Sentence-BERT) helps match parts of the user’s question to the fields — like mapping “unpaid” to status, or “last month” to posting_date. Then our fine-tuned Flan T5-Base model takes it further — extracting the exact fields needed for output (like name, customer, amount) and the filters to apply (status = Unpaid, posting_date = last month). It’s like forming a clear shopping list from a vague wish.
Stage 3: Flan Query Generator — Turning Thought into Query
Now that we have the intent, the doctype, the filters, and the output fields, the final step is generating the actual Frappe query. That’s handled by our Flan-T5 based Query Generator. It neatly transforms all the structured info into a ready-to-execute frappe.get_list() or frappe.db.get_all() query. The result? A real-time, code-ready answer that makes your ERP feel like it actually gets you — no filters, no forms, just a question and an answer.
Each of these five models is trained on a carefully balanced dataset. Phase 1 concludes, and we have a clean Frappe query in hand, all set to execute.
Phase 2: Human-Like Replies, Data-Driven
Once the query is generated and executed, #changai doesn’t just dump the raw data on you — it speaks with clarity. Behind the scenes, it fetches results from your ERPNext backend and wraps them into a natural, human-like answer. For example, instead of just listing numbers, it might say: “You have 18 unpaid invoices totaling SAR 52,300 for the month of June.” It’s not just about retrieving data — it’s about making the data understandable at a glance, even if you haven’t touched an ERP filter in months.
We use Flan-T5 for this data human-like conversion. Yes, what you are thinking correctly, we used Flan-T5 for other way around in Phase-1. Its an amazing model that works both ways.
The Plan — Making #changai smarter every day
Teaching #changai to Remember, Not Repeat
Time’s too valuable for #changai to waste answering the same question twice. So, we’re teaching it to skip the rework.
Every clear question gets converted into a smart vector — a unique digital fingerprint — using an SBERT model. This vector then searches the semantic store, a memory bank of previously solved queries.
If there’s a match: Boom! #changai instantly reuses the earlier answer. Fast, efficient, no need to reinvent the wheel.
If there’s no match: #changai runs through its full pipeline like a pro, solves the new query, and — here’s the trick — remembers it.
Answers are cached short-term in Redis, and logged long-term in the semantic store, making future replies even quicker and smarter.
When we say “semantic store”, no big deal, its another doctype in Frappe !!
Now, what about questions that aren’t so clear?
Not all messages are perfect. Sometimes, it’s just small talk- “Hey, how’s it going?”, or an unfinished thought- “Give me delivery details of”, or a quick follow-up- “Now, what about last week?”.
We are teaching #changai to embrace imperfections, too.
Small talk?
#changai keeps things friendly using DialoGPT- a model that is just as chatty as you.
Follow-up and unfinished thoughts?
#changai racks its memory- Redis cache, a short-term memory bank to check if you are resuming a past question.
If there is an active thread:
Gets the thread ID,
Combining the new question with the old one,
Rewrites it for clarity and
Runs it through the general pipeline.
If there is no active thread:
Searches the thread pool- a library of past chats, for a match.
If a match is found, same deal: gets ID, rewrites and runs through the general pipeline.
If no match is found, #changai politely asks user to clarify, and repeats the check for active threads and continues.
No more “Check last year’s reports and calculate”.
Now, there’s #changai serving answers — fast, accurate and plain human.
It’s not perfect yet, but it’s getting smarter every day.
Privacy first for #changai — No secrets sold.
When a stockist asks,
“How many mangoes were sold last year?”
He isn’t just expecting answers, but also trusting that his business data wouldn’t be sold elsewhere.
Stock levels, margins, order details- these aren’t just data, they are trade secrets, the very essence of any business.
And #changai is not built to snitch. Your business data should never be someone else’s training data.
During the design stage, we considered using ChatGPT or similar APIs to perform the task. However, we discovered that these tools require sharing data to generate meaningful results. This posed a risk of exposing the data, metadata of private tables and custom doctypes created by our clients, compromising their privacy. As a result, we decided to drop that plan.
Everything from the models and pipeline to query execution, all live where your ERP lives. When you ask #changai a question, it gets the formula and processes everything locally.
#changai doesn’t send your figures or data to train any fellow model. All business data stays locked in and safe, and most importantly, yours.
The promise isn’t just quick answers, but also the trust along with it.
That’s how we are building #changai, as a loyal business partner, never careless with your secrets.
What We Aspire to Achieve, but not begun yet.
We’ve explored #Changai’s workings. But how will it get answers from your messy, unstructured data?
That’s where MCP — the plug-and-play mascot comes into play.
It’s not a surprise that business data is like a kid’s playroom — scattered, all shapes and sizes. And AI agents can’t naturally talk to all of it on their own.
MCP, aka Model Context Protocol, connects #changai to all your business data. No data discrimination — let it be an old school spreadsheet, relational database, NoSQL store or even an API you built last week. It’s a single standard — clean and reusable.
So, how does it work?
MCP Host — where #changai lives.
MCP Client — the agent inside the Host, that knows how to talk to the data.
MCP Server — a smart warehouse aware of where your data lives.
Data Sources — wherever your messy business data sits — database, APIs or local files.
Large Language Models — the orchestrator that picks the right tools, makes sense of raw data and replies in plain human text.
When you ask, “Fetch me the purchase invoices of last month.”
The Client checks with the server, “Hey, which tools can I use for this?”
The Server replies, “There’s a sales database, some APIs and some local code.”
The Client seeks the help of a large language model, the brain, to select the best tool.
The client calls the right MCP server, which executes locally, fetching from your database, API or file.
The Client hands the raw data to the LLM.
The LLM turns it into a friendly answer.
You get your list of purchase invoices, without caring what’s under the hood.
And #changai plans to use MCP to quietly handle all connections, because unstructured data isn’t your problem, but MCP’s mess to worry about.
Painstaking to Scalable: Synthetic Dataset to the Rescue..
Handcrafting datasets drains all your energy right off, like copying homework 500 times – exhausting, repetitive and bound to kill your patience.
At some point we asked: why not let one model help us train another?
That’s where synthetic dataset generation with OpenAI GPT-4 comes in.
How we do it
We take messy, everyday user queries people actually type – you know, things like ‘invoice ids’, ‘cust nos pls’, and generate them in batches with GPT.
We want our model to handle every accent of the same idea. So, each base question gets 100 different phrasings, across 50 unique base questions per doctype.
Clear and no-nonsense prompts for each model in our pipeline.
Out come structured records for each question.
But here’s the catch: not every answer is gold. We check everything to weed out assumptions and fields actually exist in our metadata. And because duplicates can sneak in, we keep a running list to track them.
This way, we save ourselves from all the manual labour and process becomes fast and scalable. More variety, less fatigue
We’re still early in the journey, and there’s a lot to learn. But with each question answered, #changai gets a little better. Our aim isn’t to replace reports or people, but to make everyday tasks easier for business owners and teams. If something can be asked and answered quickly, why not? That’s the goal — not to impress, but to help.
If you’re a developer, researcher, or just someone curious about making AI more practical in business, we’d love to collaborate. This project will stay open source — no black boxes, no locked-in tools. Let’s shape the future of AI-powered ERP together, one simple question at a time.
contact us on support@ERPGulf.com

Aysha Liya
Passionate about Data Science, Machine Learning and Coding |.
No comments yet. Login to start a new discussion Start a new discussion