An AI-powered automatic bookkeeping bot.
Core Experience:
- Automatic CLI Guidance: Guided setup via CLI upon the first
npm start, automatically writing to.env. - Seamless Setup: Automatically validates Feishu permissions and creates the Bitable (on first run).
- Real-time Interaction: Receives images/PDFs via Feishu bot through a WebSocket long connection.
- Intelligent Matching: Automatically pairs screenshots with invoices based on the amount and writes the data to the Bitable upon success.
- Human-in-the-Loop: Automatically sends reminders for unmatched entries after a timeout.
- Node.js
>= 20 - npm
>= 9 - A Feishu Custom App (Bot)
- OpenRouter API Key
npm installCreate a custom app on the Feishu Open Platform and enable Bot capabilities.
It is recommended to grant at least the following permissions (add others as needed based on actual interfaces):
im:messagedrive:drivebitable:app
Install the app to your company/team and ensure the bot can send and receive messages in the target session.
npm startIf no .env file exists, a CLI wizard will automatically appear and ask for:
OpenRouter API KeyFeishu App IDFeishu App Secret
After saving, the program will automatically:
- Validate Feishu permissions.
- Check for or create the
AI Automatic Accounting Book(Bitable). - Check for or create the
Bookkeeping Details(Table). - Automatically initialize fields:
DateAmountInvoice(Attachment)Order Screenshot(Attachment)
Once successful, the terminal will display the Bitable link and enter WebSocket listening mode.
# Development mode (run src directly)
npm run dev
# Build (TypeScript -> dist)
npm run build
# Automated tests
npm test
# Batch backfill (processes the ./pending directory by default)
npm run batch
# Specify any directory for batch matching and archiving
npm run dev -- --batch-dir ./your-folder- Send a payment screenshot (image) to the bot in Feishu.
- The bot will reply: "Received, identifying..."
- Send the corresponding PDF invoice.
- Once the system matches them by amount, it will automatically write to the table and send a success confirmation card.
- For entries that remain unmatched after a timeout, a reminder card will be sent.
Batch Backfill Mode:
- Place unmatched screenshots and PDFs in the same directory (subdirectories are supported).
- Execute
npm run dev -- --batch-dir ./pending. - The program uses VLM to identify screenshot amounts, parses PDF amounts, and pairs them.
- Successful matches are written to the same row in the Feishu Bitable (Date/Amount/Invoice/Screenshot).
- The terminal outputs a list of unmatched items for manual follow-up.
Refer to .env.example:
OPENROUTER_API_KEY=
OPENROUTER_VLM_MODEL=qwen/qwen2.5-vl-72b-instruct
LARK_APP_ID=
LARK_APP_SECRET=
LARK_BASE_NAME=AI自动记账本
LARK_TABLE_NAME=记账明细
LARK_BASE_TOKEN=
LARK_TABLE_ID=
UNMATCHED_REMINDER_MINUTES=120Notes:
LARK_BASE_TOKEN/LARK_TABLE_IDwill be automatically backfilled after the initial setup.UNMATCHED_REMINDER_MINUTEScontrols the timing for unmatched reminders.
src/
├─ index.ts # Entry point (CLI + Init + WS Start)
├─ cli/ # First-time setup guidance
├─ config/ # Environment variables and constants
├─ lark/ # Feishu API / WebSocket / Message Cards
├─ agent/ # PDF parsing and matching pool
├─ services/ # OpenRouter and business orchestration
├─ types/ # Type definitions
└─ utils/ # Utilities (e.g., amount formatting)
The program can be deployed as a long-running Node process (e.g., using PM2, systemd, or Docker).
Simplest method (PM2):
npm run build
pm2 start "node dist/index.js" --name accounting-tool
pm2 save-
Not receiving Feishu messages after launch
Check if the app is published and installed in the company, if the bot is visible in the session, and if Event Subscriptions are enabled. -
Messages received but Bitable write fails
Ensure the app hasbitableanddrivepermissions and that the target Bitable is accessible. -
Amount recognition discrepancies
Try changing theOPENROUTER_VLM_MODELor strengthen the prompt constraints for image recognition (e.g., "Extract only the actual amount paid").