# Preview every post, page, HTML file, and FAQ note ready for RAG
wp bridgechat-ai preview-docs
# Build or incrementally update MySQL embeddings (sha256 skip unchanged)
wp bridgechat-ai index
# Inspect top-K cosine similarity chunks directly from shell
wp bridgechat-ai search "How does Telegram handoff work?"
# Verify Forum Supergroup permissions & register webhook secret
wp bridgechat-ai test-telegram
wp bridgechat-ai register-webhook
POST /wp-json/bridgechat-ai/v1/session
-> Issues HMAC-signed { session_id, token } (no HTML WP nonce needed)
POST /wp-json/bridgechat-ai/v1/chat
-> Runs MySQL RAG retrieval + OpenAI/Gemini JSON structured reply
POST /wp-json/bridgechat-ai/v1/handoff
-> Calls Telegram createForumTopic & switches session mode='human'
GET /wp-json/bridgechat-ai/v1/messages?after_id=42
-> Polls live operator replies with Cache-Control: no-store
POST /wp-json/bridgechat-ai/v1/telegram-webhook
-> Validated by X-Telegram-Bot-Api-Secret-Token
{$wpdb->prefix}bridgechat_ai_chunks
source_key, source_type, title, url, chunk_index,
content, content_hash (sha256), provider, model, dimensions, embedding
{$wpdb->prefix}bridgechat_ai_sessions
session_uuid, mode ('ai'|'human'|'closed'),
telegram_chat_id, telegram_thread_id, visitor_name, page_url
{$wpdb->prefix}bridgechat_ai_messages
session_id, sender ('visitor'|'ai'|'human'|'system'),
content, citations_json, telegram_message_id, created_at
# Inside any visitor's Telegram Forum Topic:
Reply normally -> Sent straight to the visitor's browser widget
/ai -> Hands conversation back to grounded RAG AI
/close -> Marks session resolved and closes Forum Topic
# Setup checklist:
1. Create dedicated bot via @BotFather (/newbot)
2. Enable Topics in private Supergroup settings
3. Promote bot to Administrator with Manage Topics permission
4. Click Detect Group Chat ID -> Test Bot -> Register Webhook