A full-stack, enterprise-grade AI chatbot platform designed to manage and run specialized AI Agents for multiple business departments (Sales, Customer Support, and Lead Prospecting). Built with a highly responsive React + Vite frontend and a robust Node.js/Express backend, integrating the OpenAI API (GPT-4) with real-time response streaming.
A scaling business required AI assistants to interact with clients across 3 distinct commercial touchpoints. Off-the-shelf chatbot software was too expensive, generic, and lacked the deep contextual awareness of the company's private business data and brand tone.
I designed and built a proprietary AI Agent Ecosystem:
- Specialized Agent Prompts: 3 distinct agent profiles (Sales Closer, Technical Support Specialist, and Outbound Lead Prospector) with strict system prompt boundaries.
- Real-time Response Streaming: Implemented server-sent events (SSE) to stream responses chunk-by-chunk, eliminating perceived loading latency.
- Persistent Conversation History: Client-side context management coupled with session storage to maintain conversation continuity.
- Safety Guards: Strict input validation and sanitization filters preventing prompt injection attacks.
- Simultaneous Handling: Efficiently serves hundreds of concurrent conversations.
- Ultra-low Latency: Average time-to-first-token response reduced to 800ms.
- Increased Conversion: 24/7 instant response increased Sales Team qualification metrics and liberated human agents to handle high-value negotiations.
| AI Chatbot Lobby | Interactive Streaming Chat |
|---|---|
![]() |
![]() |
custom-ai-chatbot-agents-openai/
├── backend/ # Node.js + Express API, OpenAI integration, System Prompts
└── frontend/ # React (Vite) + Tailwind CSS, Streaming Client
-
OpenAI Stream Integration (Backend): Using Express response write headers to stream tokens back to the client as they are generated by GPT-4:
res.setHeader('Content-Type', 'text/event-stream'); res.setHeader('Cache-Control', 'no-cache'); const stream = await openai.chat.completions.create({ model: "gpt-4", messages: [{ role: "system", content: systemPrompt }, ...messages], stream: true, }); for await (const chunk of stream) { res.write(`data: ${JSON.stringify(chunk.choices[0]?.delta?.content || '')}\n\n`); }
-
Streaming Text Reader (Frontend): Utilizing the browser's
fetchAPI and reader streams to parse SSE text tokens dynamically, updating the React UI state in real-time.
- Node.js (v18 or v20+)
- An OpenAI API Key
-
Navigate to the backend folder:
cd backend -
Install dependencies:
npm install
-
Create a
.envfile from the template:cp .env.example .env
-
Populate the
.envfile with your credentials:OPENAI_API_KEY="your-openai-api-key-here" PORT=5000
-
Start the backend server:
npm start
The API will run on
http://localhost:5000.
-
Navigate to the frontend folder:
cd ../frontend/brio-react -
Install dependencies:
npm install
-
Start the Vite development server:
npm run dev
-
Open your browser to
http://localhost:5173.
O Ecossistema de IA Customizada é uma plataforma full-stack para gerenciar e executar agentes inteligentes de chat.
- Problema: Soluções prontas de chatbot de IA são genéricas, caras e não integram profundamente com as regras e dados de vendas/suporte da empresa.
- Solução: Backend Express integrado à API da OpenAI (GPT-4) com streaming de respostas em tempo real, controle de histórico e prompts customizados para 3 departamentos: Vendas, Suporte e Prospecção.
- Resultados: Tempo médio de resposta inicial de 800ms, suporte simultâneo a centenas de leads e aumento na eficiência comercial com atendimento 24/7.
Developed with ❤️ by João Melo

