feat(pos): WhatsApp Business API integration — send/receive messages, quotations
Add full WhatsApp Cloud API integration for Nexus POS: - Service layer (whatsapp_service.py): send text, templates, quotations, order confirmations, stock alerts; process incoming webhooks with AI auto-reply - Blueprint (whatsapp_bp.py): public webhook endpoints for Meta verification + incoming messages; authenticated endpoints for send, send-quote, conversations - Conversation UI (whatsapp.html + whatsapp.js): split-panel messenger with conversation list, chat bubbles, send input, quote sending; both themes - Migration v1.4: whatsapp_messages table with phone/direction/status indexes - Config: WHATSAPP_TOKEN, WHATSAPP_PHONE_ID, WHATSAPP_VERIFY_TOKEN env vars - Sidebar: WhatsApp nav item under Gestion with message-bubble icon - Ready for Meta Business credentials (infrastructure complete, no API keys needed) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,8 @@ MIGRATIONS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
MIGRATIONS = {
|
||||
'v1.0': 'v1.0_initial.sql',
|
||||
'v1.1': 'v1.1_pos_tables.sql',
|
||||
'v1.3': 'v1.3_fleet.sql',
|
||||
'v1.4': 'v1.4_whatsapp.sql',
|
||||
}
|
||||
|
||||
|
||||
|
||||
18
pos/migrations/v1.4_whatsapp.sql
Normal file
18
pos/migrations/v1.4_whatsapp.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- v1.4_whatsapp.sql — WhatsApp message history
|
||||
-- Applied per-tenant database
|
||||
|
||||
CREATE TABLE IF NOT EXISTS whatsapp_messages (
|
||||
id SERIAL PRIMARY KEY,
|
||||
phone VARCHAR(20) NOT NULL,
|
||||
direction VARCHAR(10) NOT NULL, -- 'incoming' or 'outgoing'
|
||||
message_text TEXT,
|
||||
message_type VARCHAR(20) DEFAULT 'text',
|
||||
wa_message_id VARCHAR(100),
|
||||
status VARCHAR(20) DEFAULT 'sent',
|
||||
related_type VARCHAR(50), -- 'quotation', 'sale', 'alert'
|
||||
related_id INTEGER,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_wa_messages_phone ON whatsapp_messages(phone);
|
||||
CREATE INDEX IF NOT EXISTS idx_wa_messages_created ON whatsapp_messages(created_at DESC);
|
||||
Reference in New Issue
Block a user