Skip to content

πŸŽ™οΈ PLANO: AI Support Widget (Assistente de Voz para Equipe) ​

Objetivo: Criar um widget de IA flutuante com suporte a voz para ajudar a equipe interna a tirar dΓΊvidas sobre processos, fluxos e uso do sistema.


πŸ“‹ VISΓƒO GERAL ​

O que Γ©? ​

Um assistente de IA integrado ao dashboard que permite Γ  equipe fazer perguntas sobre:

  • Como funciona cada etapa do processo de vendas
  • Onde encontrar informaΓ§Γ΅es no sistema
  • Como usar features especΓ­ficas
  • DΓΊvidas sobre leads, calls, agentes
  • ExplicaΓ§Γ΅es sobre mΓ©tricas e scores

Modos de InteraΓ§Γ£o ​

  1. Texto - Chat tradicional (sempre disponΓ­vel)
  2. Voz - Push-to-talk com transcriΓ§Γ£o (opcional)
  3. Voz ContΓ­nua - Modo hands-free com detecΓ§Γ£o de silΓͺncio

πŸ—οΈ ARQUITETURA ​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FRONTEND (React - localhost:3003)             β”‚
β”‚                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚                   AISupportWidget.tsx                       β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
β”‚  β”‚  β”‚ 🎀 Mic   β”‚  β”‚  Chat Messages Area                     β”‚ β”‚ β”‚
β”‚  β”‚  β”‚ Button   β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚ β”‚ β”‚
β”‚  β”‚  β”‚          β”‚  β”‚  β”‚ User: Como classifico um lead? β”‚   β”‚ β”‚ β”‚
β”‚  β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β” β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚ β”‚ β”‚
β”‚  β”‚  β”‚ β”‚Recordβ”‚ β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚ β”‚ β”‚
β”‚  β”‚  β”‚ β”‚ ing  β”‚ β”‚  β”‚  β”‚ AI: Para classificar um lead...β”‚   β”‚ β”‚ β”‚
β”‚  β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”˜ β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚ β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚ β”‚
β”‚  β”‚  β”‚ [πŸ’¬ Digite sua pergunta...]              [🎀] [πŸ“€]    β”‚β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                              β”‚                                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β–Ό WebSocket / HTTP
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        N8N WORKFLOWS                             β”‚
β”‚                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚         13-AI-Support-Widget.json                            β”‚β”‚
β”‚  β”‚                                                              β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚β”‚
β”‚  β”‚  β”‚ Webhook  │───▢│ Whisper  │───▢│   RAG Search         β”‚  β”‚β”‚
β”‚  β”‚  β”‚ Receiver β”‚    β”‚ (STT)    β”‚    β”‚   (Segundo CΓ©rebro)  β”‚  β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚β”‚
β”‚  β”‚                                            β”‚                 β”‚β”‚
β”‚  β”‚                                            β–Ό                 β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚β”‚
β”‚  β”‚  β”‚ ElevenLabs   │◀───│ Claude/GPT   │◀───│ Context      β”‚  β”‚β”‚
β”‚  β”‚  β”‚ TTS (voz)    β”‚    β”‚ (resposta)   β”‚    β”‚ Builder      β”‚  β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚β”‚
β”‚  β”‚         β”‚                                                    β”‚β”‚
β”‚  β”‚         β–Ό                                                    β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚β”‚
β”‚  β”‚  β”‚  Response: { text, audioUrl, sources, suggestions }  β”‚  β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        SUPABASE                                  β”‚
β”‚                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ support_chat_    β”‚  β”‚ rag_knowledge    β”‚  β”‚ support_       β”‚ β”‚
β”‚  β”‚ messages         β”‚  β”‚ (Segundo CΓ©rebro)β”‚  β”‚ feedback       β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ ESTRUTURA DE ARQUIVOS ​

Frontend (React) ​

front-factorai-mottivme-sales/
β”œβ”€β”€ components/
β”‚   └── AISupportWidget/
β”‚       β”œβ”€β”€ index.tsx                 # Componente principal
β”‚       β”œβ”€β”€ AISupportWidget.tsx       # Widget flutuante
β”‚       β”œβ”€β”€ ChatMessage.tsx           # Mensagem individual
β”‚       β”œβ”€β”€ VoiceRecorder.tsx         # Gravador de Γ‘udio
β”‚       β”œβ”€β”€ AudioPlayer.tsx           # Player de resposta
β”‚       β”œβ”€β”€ ContextIndicator.tsx      # Mostra contexto atual
β”‚       └── styles.ts                 # Estilos do widget
β”œβ”€β”€ hooks/
β”‚   β”œβ”€β”€ useAISupport.ts              # Hook principal
β”‚   β”œβ”€β”€ useVoiceRecording.ts         # Hook de gravaΓ§Γ£o
β”‚   └── useAudioPlayback.ts          # Hook de reproduΓ§Γ£o
β”œβ”€β”€ services/
β”‚   └── aiSupportService.ts          # API calls
└── types/
    └── aiSupport.ts                 # Tipos TypeScript

Workflows n8n ​

Fluxos n8n/AI-Factory- Mottivme Sales/
β”œβ”€β”€ 13-AI-Support-Widget.json        # Workflow principal
β”œβ”€β”€ 14-Support-Context-Builder.json  # Builder de contexto
└── 15-Support-Analytics.json        # Analytics de uso

SQL/Migrations ​

sql/migrations/
└── 013_ai_support_widget.sql        # Tabelas do widget

πŸ—„οΈ SCHEMA DO BANCO DE DADOS ​

sql
-- ============================================
-- TABELA: support_chat_sessions
-- SessΓ΅es de chat do widget
-- ============================================
CREATE TABLE support_chat_sessions (
    id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
    user_id TEXT NOT NULL,                    -- ID do usuΓ‘rio
    user_name TEXT,                           -- Nome do usuΓ‘rio
    user_role TEXT,                           -- Papel (cs, admin, etc)
    current_page TEXT,                        -- PΓ‘gina atual no dashboard
    session_context JSONB DEFAULT '{}',       -- Contexto da sessΓ£o
    started_at TIMESTAMPTZ DEFAULT NOW(),
    ended_at TIMESTAMPTZ,
    message_count INTEGER DEFAULT 0,
    avg_response_time_ms INTEGER,
    satisfaction_score INTEGER,               -- 1-5 (feedback final)
    created_at TIMESTAMPTZ DEFAULT NOW()
);

-- ============================================
-- TABELA: support_chat_messages
-- Mensagens do chat
-- ============================================
CREATE TABLE support_chat_messages (
    id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
    session_id UUID REFERENCES support_chat_sessions(id),
    role TEXT NOT NULL CHECK (role IN ('user', 'assistant', 'system')),
    content TEXT NOT NULL,                    -- Texto da mensagem
    audio_url TEXT,                           -- URL do Γ‘udio (se voz)
    input_type TEXT DEFAULT 'text',           -- 'text' ou 'voice'

    -- Metadados da resposta (se role = 'assistant')
    sources JSONB DEFAULT '[]',               -- Fontes do RAG usadas
    confidence_score NUMERIC(3,2),            -- ConfianΓ§a da resposta
    response_time_ms INTEGER,                 -- Tempo de resposta
    tokens_used INTEGER,                      -- Tokens consumidos

    -- Feedback do usuΓ‘rio
    was_helpful BOOLEAN,                      -- Útil?
    feedback_text TEXT,                       -- ComentΓ‘rio opcional

    created_at TIMESTAMPTZ DEFAULT NOW()
);

-- ============================================
-- TABELA: support_knowledge_gaps
-- Perguntas nΓ£o respondidas (para melhorar base)
-- ============================================
CREATE TABLE support_knowledge_gaps (
    id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
    question TEXT NOT NULL,                   -- Pergunta original
    similar_questions TEXT[],                 -- VariaΓ§Γ΅es da mesma pergunta
    occurrence_count INTEGER DEFAULT 1,       -- Quantas vezes perguntaram
    last_asked_at TIMESTAMPTZ DEFAULT NOW(),
    status TEXT DEFAULT 'pending' CHECK (status IN ('pending', 'documented', 'ignored')),
    resolution_notes TEXT,                    -- Como foi resolvido
    created_at TIMESTAMPTZ DEFAULT NOW()
);

-- ============================================
-- TABELA: support_quick_actions
-- AΓ§Γ΅es rΓ‘pidas sugeridas pela IA
-- ============================================
CREATE TABLE support_quick_actions (
    id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
    trigger_phrase TEXT NOT NULL,             -- Frase que ativa a aΓ§Γ£o
    action_type TEXT NOT NULL,                -- 'navigate', 'explain', 'tutorial'
    action_data JSONB NOT NULL,               -- Dados da aΓ§Γ£o
    priority INTEGER DEFAULT 0,               -- Prioridade de sugestΓ£o
    usage_count INTEGER DEFAULT 0,            -- Vezes que foi usada
    is_active BOOLEAN DEFAULT true,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Índices
CREATE INDEX idx_support_messages_session ON support_chat_messages(session_id);
CREATE INDEX idx_support_sessions_user ON support_chat_sessions(user_id);
CREATE INDEX idx_knowledge_gaps_status ON support_knowledge_gaps(status);

-- RLS
ALTER TABLE support_chat_sessions ENABLE ROW LEVEL SECURITY;
ALTER TABLE support_chat_messages ENABLE ROW LEVEL SECURITY;

🧩 COMPONENTES REACT ​

1. AISupportWidget.tsx (Componente Principal) ​

typescript
interface AISupportWidgetProps {
  userId: string;
  userName: string;
  userRole: 'cs' | 'admin' | 'viewer';
  currentPage: string;         // Ex: '/prompt-studio', '/leads'
  agentContext?: {             // Contexto do agente atual (se aplicΓ‘vel)
    agentId: string;
    agentName: string;
  };
}

// Estados do widget
type WidgetState =
  | 'minimized'    // Apenas botΓ£o flutuante
  | 'expanded'     // Chat aberto
  | 'recording'    // Gravando voz
  | 'processing'   // Processando resposta
  | 'playing';     // Reproduzindo Γ‘udio

// Features
- BotΓ£o flutuante fixo no canto inferior direito
- ExpansΓ£o suave com animaΓ§Γ£o
- Indicador de contexto atual ("VocΓͺ estΓ‘ em: Prompt Studio")
- HistΓ³rico de mensagens da sessΓ£o
- SugestΓ΅es de perguntas baseadas na pΓ‘gina atual
- Feedback thumbs up/down em cada resposta

2. VoiceRecorder.tsx ​

typescript
interface VoiceRecorderProps {
  onRecordingComplete: (audioBlob: Blob) => void;
  onRecordingStart: () => void;
  onRecordingCancel: () => void;
  maxDuration?: number;        // MΓ‘ximo em segundos (default: 60)
  silenceTimeout?: number;     // Auto-stop apΓ³s silΓͺncio (default: 2s)
}

// Features
- Push-to-talk (segurar para gravar)
- Click-to-toggle (clicar para iniciar/parar)
- VisualizaΓ§Γ£o de amplitude em tempo real
- DetecΓ§Γ£o de silΓͺncio para auto-stop
- Cancelamento por gesto (arrastar para fora)

3. ChatMessage.tsx ​

typescript
interface ChatMessageProps {
  message: {
    id: string;
    role: 'user' | 'assistant';
    content: string;
    audioUrl?: string;
    sources?: Array<{
      title: string;
      category: string;
      similarity: number;
    }>;
    timestamp: Date;
  };
  onFeedback: (messageId: string, helpful: boolean) => void;
  onPlayAudio: (audioUrl: string) => void;
}

// Features
- Avatar diferenciado (user vs AI)
- Player de Γ‘udio inline
- Expandir para ver fontes
- BotΓ΅es de feedback
- Copiar texto

πŸ”„ WORKFLOW N8N: 13-AI-Support-Widget.json ​

Fluxo Principal ​

[Webhook] ──▢ [Route by Type] ──┬──▢ [Text Query] ──▢ [RAG Search] ──┬──▢ [Build Context]
              (text/voice)      β”‚                                     β”‚
                                └──▢ [Voice Query] ──▢ [Whisper STT]β”€β”€β”˜
                                                            β”‚
                                                            β–Ό
[Response] ◀── [Format Response] ◀── [Claude/GPT] ◀── [Enrich Context]
    β”‚
    └──▢ [If Voice Mode] ──▢ [ElevenLabs TTS] ──▢ [Upload Audio] ──▢ [Add audioUrl]

Nodes Detalhados ​

javascript
// 1. WEBHOOK - Recebe requisiΓ§Γ΅es
{
  "path": "/ai-support",
  "method": "POST",
  "authentication": "headerAuth",
  "body": {
    "type": "text | voice",
    "query": "string (se texto)",
    "audioBase64": "string (se voz)",
    "sessionId": "uuid",
    "userId": "string",
    "context": {
      "currentPage": "/prompt-studio",
      "agentId": "uuid (opcional)",
      "selectedLeadId": "uuid (opcional)"
    }
  }
}

// 2. RAG SEARCH - Busca no Segundo CΓ©rebro
{
  "endpoint": "https://agenticoskevsacademy-production.up.railway.app/webhook/rag-search",
  "body": {
    "query": "{{ $json.query }}",
    "project_key": "mottivme-geral",
    "threshold": 0.5,
    "limit": 5
  }
}

// 3. CLAUDE/GPT - Gera resposta
{
  "model": "claude-3-5-sonnet",
  "system": `VocΓͺ Γ© o assistente de suporte interno da MOTTIVME Sales.

Seu papel Γ© ajudar a equipe a entender:
- Como usar o sistema (dashboard, features)
- Como funciona o processo de vendas
- O que significam mΓ©tricas e scores
- Onde encontrar informaΓ§Γ΅es

CONTEXTO ATUAL DO USUÁRIO:
- PΓ‘gina: {{ $json.context.currentPage }}
- Agente selecionado: {{ $json.context.agentName || 'Nenhum' }}

CONHECIMENTO RELEVANTE (do RAG):
{{ $json.ragResults }}

REGRAS:
1. Seja direto e objetivo
2. Use exemplos prΓ‘ticos quando possΓ­vel
3. Se nΓ£o souber, diga que vai escalar para documentaΓ§Γ£o
4. Sugira prΓ³ximos passos quando relevante
5. Fale em portuguΓͺs brasileiro informal mas profissional`,

  "messages": [
    { "role": "user", "content": "{{ $json.query }}" }
  ]
}

// 4. ELEVENLABS TTS (se modo voz)
{
  "endpoint": "https://api.elevenlabs.io/v1/text-to-speech/{{ voiceId }}",
  "body": {
    "text": "{{ $json.response }}",
    "model_id": "eleven_multilingual_v2",
    "voice_settings": {
      "stability": 0.5,
      "similarity_boost": 0.75
    }
  }
}

// 5. SALVAR NO SUPABASE
{
  "table": "support_chat_messages",
  "operation": "insert",
  "data": {
    "session_id": "{{ $json.sessionId }}",
    "role": "assistant",
    "content": "{{ $json.response }}",
    "audio_url": "{{ $json.audioUrl }}",
    "sources": "{{ $json.sources }}",
    "response_time_ms": "{{ $json.processingTime }}"
  }
}

🎯 SUGESTΓ•ES CONTEXTUAIS ​

Por PΓ‘gina ​

typescript
const CONTEXTUAL_SUGGESTIONS: Record<string, string[]> = {
  '/': [
    'O que significa cada mΓ©trica do dashboard?',
    'Como interpretar a taxa de conversΓ£o?',
    'Por que o score do agente caiu?'
  ],
  '/leads': [
    'Como classificar um lead como HOT?',
    'O que fazer quando um lead nΓ£o responde?',
    'Como funciona o scoring de leads?'
  ],
  '/prompt-studio': [
    'Como editar o prompt do agente?',
    'O que sΓ£o zonas editΓ‘veis vs protegidas?',
    'Como publicar uma nova versΓ£o?'
  ],
  '/reflection-loop': [
    'Como funciona o Reflection Loop?',
    'O que significam as sugestΓ΅es de melhoria?',
    'Como aprovar ou rejeitar uma sugestΓ£o?'
  ],
  '/calls': [
    'Como a IA analisa as calls?',
    'O que cada score significa?',
    'Como melhorar a taxa de follow-up?'
  ],
  '/configuracoes': [
    'Como alterar as configuraΓ§Γ΅es do agente?',
    'O que Γ© o intervalo de reflexΓ£o?',
    'Como ativar notificaΓ§Γ΅es?'
  ]
};

πŸ“Š ANALYTICS E MΓ‰TRICAS ​

MΓ©tricas a Coletar ​

MΓ©tricaDescriΓ§Γ£oUso
queries_per_dayPerguntas por diaVolume de uso
avg_response_timeTempo mΓ©dio de respostaPerformance
voice_vs_text_ratioProporΓ§Γ£o voz/textoPreferΓͺncia do usuΓ‘rio
helpful_rate% de respostas ΓΊteisQualidade
unanswered_rate% nΓ£o respondidasKnowledge gaps
top_questionsPerguntas mais frequentesDocumentaΓ§Γ£o
page_with_most_questionsPΓ‘gina com mais dΓΊvidasUX issues

Dashboard de Analytics (futuro) ​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AI Support Analytics                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                              β”‚
β”‚  πŸ“Š Esta Semana         πŸ“ˆ TendΓͺncia     🎯 Satisfaction    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚ 234 queries β”‚       β”‚  ↑ 12%    β”‚    β”‚  ⭐ 4.2/5   β”‚    β”‚
β”‚  β”‚ 89% helpful β”‚       β”‚  vs semanaβ”‚    β”‚  (156 votes)β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚  anterior β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚
β”‚                                                              β”‚
β”‚  πŸ”₯ Top Perguntas (knowledge gaps)                          β”‚
β”‚  1. "Como funciona o score do agente?" (23x)                β”‚
β”‚  2. "Onde vejo o histΓ³rico de versΓ΅es?" (18x)               β”‚
β”‚  3. "Como faΓ§o rollback de prompt?" (15x)                   β”‚
β”‚                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ ROADMAP DE IMPLEMENTAÇÃO ​

Fase 1: MVP Texto (1-2 dias) ​

  • [ ] Criar componente AISupportWidget.tsx
  • [ ] Implementar chat bΓ‘sico (sΓ³ texto)
  • [ ] Criar workflow n8n 13-AI-Support-Widget.json
  • [ ] Integrar com RAG existente
  • [ ] Salvar mensagens no Supabase
  • [ ] Adicionar ao Layout.tsx como widget flutuante

Fase 2: SugestΓ΅es Contextuais (1 dia) ​

  • [ ] Implementar CONTEXTUAL_SUGGESTIONS
  • [ ] Detectar pΓ‘gina atual via React Router
  • [ ] Mostrar 3 sugestΓ΅es ao abrir o widget
  • [ ] Analytics de quais sugestΓ΅es sΓ£o clicadas

Fase 3: Modo Voz (2-3 dias) ​

  • [ ] Criar VoiceRecorder.tsx com Web Audio API
  • [ ] Integrar Whisper para STT
  • [ ] Integrar ElevenLabs para TTS
  • [ ] Criar AudioPlayer.tsx para respostas
  • [ ] Adicionar toggle texto/voz

Fase 4: Feedback e Analytics (1 dia) ​

  • [ ] Implementar thumbs up/down
  • [ ] Criar tabela support_knowledge_gaps
  • [ ] Workflow para detectar perguntas nΓ£o respondidas
  • [ ] Dashboard bΓ‘sico de analytics

Fase 5: Melhorias (ongoing) ​

  • [ ] Modo hands-free (always listening)
  • [ ] Atalhos de teclado (Cmd+K para abrir)
  • [ ] IntegraΓ§Γ£o com Slack para escalar dΓΊvidas
  • [ ] Tutorial interativo guiado pela IA

πŸ’° ESTIMATIVA DE CUSTOS ​

Por MΓͺs (estimativa 500 queries) ​

ServiΓ§oCusto UnitΓ‘rioUso EstimadoTotal
Claude 3.5 Sonnet$3/1M tokens~100k tokens~$0.30
Whisper API$0.006/min50 min voz~$0.30
ElevenLabs$5/mo starterilimitado$5.00
SupabaseincluΓ­do-$0.00
TOTAL~$6/mΓͺs

Alternativas Gratuitas ​

  • Whisper local via n8n (CPU-only, mais lento)
  • Coqui TTS self-hosted (qualidade inferior)
  • gTTS (Google Text-to-Speech gratuito)

βœ… CHECKLIST DE IMPLEMENTAÇÃO ​

[ ] 1. Criar migration SQL (013_ai_support_widget.sql)
[ ] 2. Rodar migration no Supabase
[ ] 3. Criar estrutura de pastas no frontend
[ ] 4. Implementar AISupportWidget.tsx (MVP texto)
[ ] 5. Criar workflow n8n 13-AI-Support-Widget
[ ] 6. Testar integraΓ§Γ£o texto completa
[ ] 7. Adicionar sugestΓ΅es contextuais
[ ] 8. Implementar VoiceRecorder.tsx
[ ] 9. Integrar Whisper no n8n
[ ] 10. Integrar ElevenLabs no n8n
[ ] 11. Testar fluxo de voz completo
[ ] 12. Adicionar sistema de feedback
[ ] 13. Documentar no Segundo CΓ©rebro
[ ] 14. Deploy e testes em produΓ§Γ£o

πŸ“ NOTAS ADICIONAIS ​

Alternativa: Gemini Live API ​

Se quisermos mΓ‘xima qualidade de voz com emoΓ§Γ£o:

  • Usar Gemini 2.5 Flash Native Audio via Vertex AI
  • Requer conta GCP com billing
  • LatΓͺncia ~200ms (excelente)
  • 30 vozes em 24 idiomas
  • Custo: ~$0.075/1000 chars

Alternativa: OpenAI Realtime API ​

  • WebSocket bidirectional
  • Voice-to-voice sem intermediΓ‘rio
  • Custo: $0.06/min input + $0.24/min output
  • Mais caro mas menor latΓͺncia

RecomendaΓ§Γ£o ​

ComeΓ§ar com Whisper + Claude + ElevenLabs (mais barato e flexΓ­vel), depois migrar para Gemini Live se necessΓ‘rio.


Documento criado em: 2026-01-04Última atualização: 2026-01-04Autor: Claude Code + Marcos Daniels

AI Factory V3 - Mottivme Sales