AI · 12 March 2025

For decades, Enterprise Resource Planning (ERP) systems have been the backbone of business operations, managing inventory, sales, procurement, HR, and finance.
For decades, Enterprise Resource Planning (ERP) systems have been the backbone of business operations, managing inventory, sales, procurement, HR, and finance. However, interacting with ERP software has remained largely unchanged—users must log in, navigate complex menus, find reports, and manually enter data.
This traditional approach is slow, prone to errors, and often frustrating for end-users.
What if your ERP system could talk back to you? What if instead of navigating through multiple screens, you could simply ask:
What are today’s total sales for the Hanoi branch?
Reorder 50kg of chicken for the central kitchen.
When is my next shift?
With AI-powered assistants like CopilotKit integrated into an ERPNext backend via FastAPI, this vision becomes a reality. In this article, we experiment with CopilotKit’s Python SDK (FastAPI actions) and ChatUI for handling AI-assistant frontend. On the other hand, ERPNext‘s RESTful services are used to access data from the backend.
CTOs, IT Managers, and software developers managing ERP implementations often face these challenges:
An AI-driven ERP assistant removes these bottlenecks by enabling users to query, update, and analyze ERP data conversationally—without ever touching a UI.
With CopilotKit, we can integrate AI-powered assistants into an ERPNext backend via FastAPI. Let’s explore how this works with real-life ERPNext actions.
Instead of navigating through ERPNext’s stock module, users can simply ask:
How much beef is in stock?
The AI assistant processes this request by calling a FastAPI function that interacts with ERPNext’s REST API:
FastAPI Backend (server.py):
from fastapi import FastAPI
import requests
from copilotkit.integrations.fastapi import add_fastapi_endpoint
from copilotkit import CopilotKitRemoteEndpoint, Action as CopilotAction
# Initialize FastAPI app
app = FastAPI()
# ERPNext API base URL and authentication (update these)
ERP_BASE_URL = "https://your-erp-instance/api/resource"
ERP_HEADERS = {"Authorization": "token your-api-key"}
# ----------------------- ACTIONS -----------------------
# Get Inventory Stock Level
async def get_stock_status(item_name: str):
response = requests.get(f"{ERP_BASE_URL}/Stock Ledger Entry",
headers=ERP_HEADERS,
params={"filters": f'[["item_code", "=", "{item_name}"]]'})
data = response.json()
total_stock = sum(entry["actual_qty"] for entry in data.get("data", []))
return {"item": item_name, "stock": total_stock}
# ... other actions
# -------------------- REGISTER ACTIONS WITH COPILOTKIT ---------------
actions = [
CopilotAction(
name="get_stock_status",
description="Fetches current stock level of a specified item.",
parameters=[{"name": "item_name", "type": "string", "required": True}],
handler=get_stock_status
),...
]
# Initialize CopilotKit SDK
sdk = CopilotKitRemoteEndpoint(actions=actions)
# Add CopilotKit endpoint to FastAPI
add_fastapi_endpoint(app, sdk, "/copilotkit_remote")
# ----------------------- RUN FASTAPI SERVER -----------------------
def main():
"""Run the uvicorn server."""
import uvicorn
uvicorn.run("server:app", host="0.0.0.0", port=8000, reload=True)
if __name__ == "__main__":
main()
You can then run your fastapi server at: http://localhost:8000/copilotkit_remote
We’ll use Nextjs for our front-end.
app/page.tsx – Next.js Frontend for CopilotKit
"use client";
import { useState } from "react";
import { CopilotSidebar, CopilotProvider, useCopilotChat } from "@copilotkit/react";
export default function Home() {
return (
<CopilotProvider url="http://localhost:8000/copilotkit_remote">
<div className="h-screen flex flex-col items-center justify-center bg-gray-100">
<h1 className="text-2xl font-bold mb-4">AI Assistant for Restaurant Operations</h1>
<ChatBox />
<CopilotSidebar />
</div>
</CopilotProvider>
);
}
function ChatBox() {
const { messages, input, setInput, sendMessage } = useCopilotChat();
return (
<div className="w-full max-w-md bg-white rounded-lg shadow p-4">
<div className="h-60 overflow-y-auto border-b pb-2">
{messages.map((msg, index) => (
<div key={index} className={`my-2 p-2 rounded ${msg.role === "user" ? "bg-blue-200" : "bg-gray-200"}`}>
<strong>{msg.role === "user" ? "You:" : "AI:"}</strong> {msg.content}
</div>
))}
</div>
<div className="mt-2 flex">
<input
type="text"
className="flex-1 border p-2 rounded-l"
placeholder="Ask AI Assistant..."
value={input}
onChange={(e) => setInput(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && sendMessage(input)}
/>
<button className="bg-blue-500 text-white px-4 rounded-r" onClick={() => sendMessage(input)}>Send</button>
</div>
</div>
);
}
A response from our Chat Agent could look something like this:
Stock for beef: 15 kg. It’s running low, do you want to reorder?
A restaurant manager no longer needs to manually create a purchase order in ERPNext. Instead, they simply say:
Reorder 20kg of salmon.
Instead of navigating multiple ERP screens, the AI assistant automatically creates the order, reducing processing time from 5 minutes to seconds.
The backend end action may look something like this:
async def create_purchase_order(item_code: str, quantity: int):
payload = {
"doctype": "Purchase Order",
"supplier": "Preferred Supplier",
"items": [{"item_code": item_code, "qty": quantity}]
}
response = requests.post(f"{ERP_BASE_URL}/Purchase Order", json=payload, headers=ERP_HEADERS)
return {"status": "Order Placed", "po": response.json().get("data", {}).get("name")}
Likewise, you may implement for the following scenario:
Suggest a new price for Wagyu Steak.
Response from assistant:
Wagyu Steak is popular! Suggested price increase: $55 → $60.
🚀 AI-driven ERP queries enable instant access to critical business data. Instead of navigating dashboards, filtering data, and running reports, managers get real-time insights in seconds.
Routine ERP tasks (inventory checks, order creation, report generation, etc.) are automated, allowing employees to focus on high-value work.
ERPNext like any other ERP systems out there, has a learning curve, requiring training for non-technical employees. AI chat interfaces eliminate complexity by allowing users to speak naturally to the system.
AI assistants can work via mobile, voice commands, or even chat apps—allowing business owners and managers to interact with ERP data on the go.
At LinxHQ, we can help you build AI-driven ERP solutions that enhance efficiency, reduce operational costs, and improve business agility.
Would you like to see how AI-driven ERP automation can streamline your operations?
👉 Contact us today for a consultation.
Agentic systems let small business owners scale before they can afford a hire, and keep the business running when a staff member leaves. Here's what that looks like in practice.
What Building 5 Apps with AI Coding Agents Taught Us Real numbers, real challenges, and why the human still matters most. Over the past few months, our team at Linx has been going deep with AI coding agents — specifically Claude Code — across a range of real client projects and our own products.
In today’s fast-changing digital landscape, artificial intelligence (AI) has become a critical enabler of smarter business operations. Yet, many organizations still struggle to connect their existing ERP and management systems to modern AI models like ChatGPT or GPT-4.