Procurement Workflow Fixes: Vendor Query Logic, Contact Creation, 163 IMAP Disabling, Encoding Fix
Issues Fixed
1. Vendor Query Logic (Filter by Product Name)
File: server/tools/procurement-workflow-v2.js
- Step1 SCSAI Query AML adds name condition="like" filter by product name: %${product}%
- If no match by product name, perform a broad query for all Vendors (maxRecords="50", no filter conditions)
- Only if the broad query also finds nothing, then automatically create a vendor
2. Contact Creation Failure (Bypass Contact, directly write to Vendor.contact_email)
File: server/tools/procurement-workflow-v2.js
- findOrCreateVendor() rewritten: Skip the three-step pattern of Contact → Vendor → VendorContact
- Changed to one-step Vendor creation, directly writing the contact_email field: { name, contact_name, contact_email }
- Error logs now output complete fault details
3. Vendor Naming Convention
File: server/tools/procurement-workflow-v2.js
- Automatically created vendor names changed to {product}供应商{sequence number}
- For example, purchasing "Servo Motor" creates "Servo Motor供应商1", "Servo Motor供应商2"
- Facilitates subsequent searches by product name
4. Comprehensive 163 Email Disabling
File: server/services/email-service.js
- getImapConfigs() adds DISABLE_163_IMAP environment variable switch
- By default, skip 163 IMAP (skip when DISABLE_163_IMAP is not set or is true)
- Only enabled when explicitly set to false
File: server/tools/procurement-workflow-v2.js
- Added skipEmails filter to vendor creation list: 18601921816@163.com, tuan_zhang@sina.com
- Second fallback entry also filtered
5. IMAP duplicate fetching
File: server/services/email-service.js
- Added _lastProcessedSeq[label] tracking in fetchNewEmails()
- Skip directly if no new emails (startSeq > total)
6. Encoding fixes
- nodemailer already set defaults: { charset: 'UTF-8' }, email Subject automatically UTF-8 base64 encoded
- All ?? display issues are caused by terminal encoding (strings in Node.js memory are correct)
Environment variable changes
- DISABLE_163_IMAP=true - Disable 163 IMAP (already set, needs injection via .env or at startup)
- SKIP_EMAILS - Comma-separated list of emails to skip (default 163/sina)
- COZE_SUPPLIER_1/2/3 - Custom backup supplier emails
Trigger method
After DS-PROC-001 Procurement Assistant starts:
- Query SCSAI Vendor where name LIKE '%servo motor%'
- If found → use; if not found → full query (no filter)
- If still not found → automatically create "Servo Motor Supplier 1/2" (skip 163/sina emails)
- Send RFQ emails (filter own email + 163/sina)
- Wait for quotes (only QQ IMAP listening, 163 not started)
- Compare prices + report + confirm + PO
File modification list
- D:\openclaw\bossagents\server\tools\procurement-workflow-v2.js: Vendor query AML, findOrCreateVendor, fallback supplier name, 163 filter, self-email filter
- D:\openclaw\bossagents\server\services\email-service.js: 163 IMAP disable switch, IMAP deduplication tracking
BossAgents