Skip to content

ERP Template 🟑 BETA

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

Dialog 2: Check Stock Levels

Dialog 3: Ship an Order

Dialog 4: Transfer Stock

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

  1. Always Verify Quantities: Confirm counts before processing
  2. Maintain Audit Trail: Log all inventory movements
  3. Regular Cycle Counts: Schedule periodic physical inventory
  4. Monitor Reorder Points: Act on low stock alerts promptly
  5. Validate PO/SO Numbers: Check document existence before processing
  6. Cost Tracking: Maintain accurate cost records for COGS