ERP Template
The ERP (Enterprise Resource Planning) template provides comprehensive inventory management, purchasing, and warehouse operations through a conversational AI interface.
Topic: Enterprise Resource Planning & Inventory
This template is perfect for:
- Warehouse management
- Inventory tracking
- Purchase order processing
- Stock transfers
- Cycle counting and audits
The Code
ADD TOOL "inventory-management"
ADD TOOL "purchasing"
ADD TOOL "erp-jobs"
SET CONTEXT "erp" AS "You are an ERP assistant helping with inventory management, purchasing, and warehouse operations. Help users receive inventory, ship orders, check stock levels, transfer between warehouses, and conduct cycle counts."
CLEAR SUGGESTIONS
ADD SUGGESTION "receive" AS "Receive inventory"
ADD SUGGESTION "ship" AS "Ship order"
ADD SUGGESTION "stock" AS "Check stock"
ADD SUGGESTION "transfer" AS "Transfer stock"
ADD SUGGESTION "count" AS "Cycle count"
ADD SUGGESTION "purchase" AS "Create PO"
BEGIN TALK
**ERP Inventory Manager**
I can help you with:
• Receive inventory from purchase orders
• Ship orders to customers
• Check stock levels across warehouses
• Transfer stock between locations
• Conduct cycle counts
• Create and manage purchase orders
What would you like to do?
END TALK
BEGIN SYSTEM PROMPT
You are an ERP inventory management assistant.
Key operations:
- receive_inventory: Process incoming goods from POs
- ship_inventory: Process outgoing shipments for sales orders
- check_stock: Query inventory levels
- transfer_stock: Move inventory between warehouses
- cycle_count: Physical inventory verification
Always confirm quantities before processing.
Log all transactions for audit trail.
Alert on low stock and reorder points.
END SYSTEM PROMPT
Sample Dialogs
These conversations show how the ERP template works in real-world scenarios.
Dialog 1: Receiving Inventory
📦
ERP Manager
online
Today
Dialog 2: Check Stock Levels
📦
ERP Manager
online
Dialog 3: Ship an Order
📦
ERP Manager
online
Dialog 4: Transfer Stock
📦
ERP Manager
online
Keywords Used
| Keyword | Purpose |
|---|---|
ADD TOOL | Register ERP operation tools |
SET CONTEXT | Define ERP assistant behavior |
FIND | Query inventory and orders |
SAVE | Record transactions |
UPDATE | Modify stock levels |
SEND MAIL | Notify stakeholders |
Template Structure
erp.gbai/
├── erp.gbdialog/
│ ├── inventory-management.bas # Stock operations
│ ├── purchasing.bas # PO management
│ ├── erp-jobs.bas # Scheduled tasks
│ └── tables.bas # Data structures
└── erp.gbot/
└── config.csv # Configuration
Data Tables
Items Table
| Field | Description |
|---|---|
| id | Unique item identifier |
| item_code | SKU/product code |
| name | Item description |
| category | Product category |
| unit_of_measure | UOM (each, case, etc.) |
| minimum_stock_level | Reorder threshold |
| reorder_point | When to reorder |
| reorder_quantity | How much to order |
| average_cost | Weighted average cost |
| last_cost | Most recent purchase cost |
Inventory Stock Table
| Field | Description |
|---|---|
| item_id | Reference to item |
| warehouse_id | Location |
| quantity_on_hand | Physical count |
| quantity_reserved | Allocated to orders |
| quantity_available | On hand minus reserved |
| last_movement_date | Last transaction |
| last_counted_date | Last physical count |
Inventory Transactions Table
| Field | Description |
|---|---|
| transaction_type | receipt, shipment, transfer, adjustment |
| transaction_number | Unique reference |
| item_id | Item affected |
| warehouse_id | Location |
| quantity | Amount (+/-) |
| unit_cost | Cost per unit |
| reference_type | PO, SO, Transfer |
| reference_id | Source document |
Inventory Management Tool
PARAM action AS STRING LIKE "check_stock" DESCRIPTION "Action: receive_inventory, ship_inventory, check_stock, transfer_stock, cycle_count"
PARAM item_data AS OBJECT LIKE "{po_number: 'PO-123'}" DESCRIPTION "Data object with action-specific parameters"
DESCRIPTION "Manage inventory operations"
user_id = GET "session.user_id"
warehouse_id = GET "session.warehouse_id"
IF action = "receive_inventory" THEN
po_number = item_data.po_number
po = FIND "purchase_orders", "po_number = '" + po_number + "'"
IF NOT po THEN
TALK "Purchase order not found."
RETURN NULL
END IF
po_lines = FIND "purchase_order_lines", "po_id = '" + po.id + "'"
FOR EACH line IN po_lines
item = FIND "items", "id = '" + line.item_id + "'"
TALK "Receiving " + item.name + " - Ordered: " + line.quantity_ordered
TALK "Enter quantity received:"
HEAR qty_received AS INTEGER
' Update stock
stock = FIND "inventory_stock", "item_id = '" + item.id + "' AND warehouse_id = '" + warehouse_id + "'"
IF NOT stock THEN
WITH newStock
item_id = item.id
warehouse_id = warehouse_id
quantity_on_hand = qty_received
END WITH
SAVE "inventory_stock", newStock
ELSE
new_qty = stock.quantity_on_hand + qty_received
UPDATE "inventory_stock" SET quantity_on_hand = new_qty WHERE id = stock.id
END IF
' Create transaction record
WITH transaction
transaction_type = "receipt"
item_id = item.id
warehouse_id = warehouse_id
quantity = qty_received
unit_cost = line.unit_price
reference_type = "purchase_order"
reference_id = po.id
created_at = NOW()
END WITH
SAVE "inventory_transactions", transaction
NEXT
UPDATE "purchase_orders" SET status = "received" WHERE id = po.id
TALK "Purchase order " + po_number + " received."
END IF
IF action = "check_stock" THEN
item_search = item_data.item_search
items = FIND "items", "name LIKE '%" + item_search + "%'"
FOR EACH item IN items
TALK "📦 " + item.name + " (" + item.item_code + ")"
stocks = FIND "inventory_stock", "item_id = '" + item.id + "'"
total = 0
FOR EACH stock IN stocks
warehouse = FIND "warehouses", "id = '" + stock.warehouse_id + "'"
TALK " " + warehouse.name + ": " + stock.quantity_on_hand
total = total + stock.quantity_on_hand
NEXT
TALK " **TOTAL:** " + total
IF total < item.minimum_stock_level THEN
TALK " ⚠️ Below minimum (" + item.minimum_stock_level + ")"
END IF
NEXT
END IF
Scheduled Jobs: erp-jobs.bas
PARAM jobname AS STRING DESCRIPTION "Job to execute"
IF jobname = "low stock alert" THEN
SET SCHEDULE "0 8 * * *" ' Daily at 8 AM
' Find items below reorder point
low_items = SQL "SELECT i.*, s.quantity_on_hand
FROM items i
JOIN inventory_stock s ON i.id = s.item_id
WHERE s.quantity_on_hand <= i.reorder_point"
IF UBOUND(low_items) > 0 THEN
report = "Low Stock Alert\n\n"
FOR EACH item IN low_items
report = report + item.name + ": " + item.quantity_on_hand + " (reorder at " + item.reorder_point + ")\n"
NEXT
SEND MAIL "purchasing@company.com", "Daily Low Stock Alert", report
END IF
END IF
IF jobname = "pending shipments" THEN
SET SCHEDULE "0 7 * * *" ' Daily at 7 AM
pending = FIND "sales_orders", "status = 'ready_to_ship'"
TALK "📦 " + UBOUND(pending) + " orders ready to ship today."
SEND MAIL "warehouse@company.com", "Pending Shipments",
UBOUND(pending) + " orders need to be shipped today."
END IF
Best Practices
- Always Verify Quantities: Confirm counts before processing
- Maintain Audit Trail: Log all inventory movements
- Regular Cycle Counts: Schedule periodic physical inventory
- Monitor Reorder Points: Act on low stock alerts promptly
- Validate PO/SO Numbers: Check document existence before processing
- Cost Tracking: Maintain accurate cost records for COGS
Related Templates
- store.bas - E-commerce integration
- talk-to-data.bas - Inventory analytics
- backup.bas - Data backup procedures