Skip to content

renesul/Next

Repository files navigation

 ███╗   ██╗███████╗██╗  ██╗████████╗
 ████╗  ██║██╔════╝╚██╗██╔╝╚══██╔══╝
 ██╔██╗ ██║█████╗   ╚███╔╝    ██║
 ██║╚██╗██║██╔══╝   ██╔██╗    ██║
 ██║ ╚████║███████╗██╔╝ ██╗   ██║
 ╚═╝  ╚═══╝╚══════╝╚═╝  ╚═╝   ╚═╝

IA que atende por você

Intelligent WhatsApp secretary — an AI agent on your personal number,
powered by any OpenAI-compatible LLM, with a full web UI for management.

Self-hosted · No Business API · Any LLM · Zero build step



Go 1.25+ Docker Platform License


Features · Quick Start · Built-in Tools · Architecture · Development · Tech Stack · License


✨ Features

📱 WhatsApp via QR code
Uses your personal number, no Business API
🤖 Any OpenAI-compatible LLM
OpenAI, Groq, Ollama, Together, LM Studio…
🔧 16 built-in tools
Plus custom API tools and MCP protocol
📚 Knowledge base (RAG)
FTS5 full-text search + embedding similarity
👥 Up to 10 agents
Independent personality, model, provider + chaining
🛡️ Guardrails
Whitelist/blacklist, anti-injection, PII filtering
Message debounce
Groups rapid messages before sending to AI
🧠 Session management
Auto-summaries prevent hallucination
🖥️ Full web UI
Config, conversations, logs, knowledge, reports, chat
🔐 Multi-user auth
Admin/user roles, bcrypt, persistent sessions
Scheduled messages
Hourly, daily, weekly, monthly, cron expressions
🔌 MCP server
Exposes all tools via SSE protocol
💬 WhatsApp groups
Optional, configurable per group
🗄️ External databases
Query MySQL and PostgreSQL from the AI

🚀 Quick Start

git clone https://github.com/renesul/Next.git
cd Next
make run
  1. Open http://localhost:8080
  2. Login with admin / admin123
  3. Set your AI provider API key and base URL
  4. Scan the WhatsApp QR code
  5. Done — start chatting
🐳 Docker
docker compose up -d

Or build manually:

docker build -t next .
docker run -d -p 8080:8080 -v next-data:/data next
📋 Requirements
Requirement Details
Go 1.25+
CGO Enabled (gcc / build-essential must be installed)
OS Linux, macOS (Windows via WSL)
⚙️ Configuration
Variable Default Description
PORT 8080 HTTP server port
DB_PATH ~/.next/ Data directory (databases, logs)

Both are optional. Set them in .env or as environment variables.

Everything else (AI provider, system prompt, tools, guardrails, agents, etc.) is configured through the web UI and stored in SQLite.


🛠️ Built-in Tools

Category Tool Description
Time get_datetime Current date, time, and day of week
Tasks create_task Create a task/reminder for the contact
list_tasks List tasks, optionally filtered by status
complete_task Mark a task as completed
Knowledge search_knowledge Search the knowledge base (RAG)
save_note Save persistent notes about a contact
get_notes Retrieve saved notes
Web search_web Web search via DuckDuckGo
fetch_url Fetch and extract text from a URL
weather Current weather for any location
currency Currency conversion with live rates
Scheduling schedule_message Schedule a message with optional recurrence
list_scheduled List pending scheduled messages
cancel_scheduled Cancel scheduled messages
Data calculate Evaluate math expressions
query_database Read-only SQL queries (local + external DBs)

You can also add custom API tools (any REST endpoint) and MCP tools (via SSE transport) through the web UI.


🏗️ Architecture

Message Flow

flowchart TD
    A["📱 WhatsApp Message"] --> B["🔍 Filter"]
    B --> C["⏳ Debounce"]
    C --> D["🛡️ Guardrails Pre-filter"]
    D --> E["👥 Agent Lookup"]
    E --> F["🧠 Session"]
    F --> G["📚 RAG Search"]
    G --> H["🤖 LLM + Tools"]
    H --> I["🛡️ Guardrails Post-filter"]
    I --> J["📱 WhatsApp Response"]

    style A fill:#25D366,color:#fff
    style J fill:#25D366,color:#fff
    style H fill:#2563eb,color:#fff
Loading

Project Structure

main.go                       Entry point, wiring, signal handling, migrations

app/                          Business logic
  types/types.go              Shared types (Message, Agent, Contact, etc.)
  ai/ai.go                   OpenAI-compatible client (reply, summarize, embed)
  memory/memory.go            Sessions, history, summaries, token budget
  rag/rag.go                  Knowledge base with FTS5 + embeddings
  guardrails/guardrails.go    Pre/post-AI message filtering
  tools/tools.go              Function calling registry, built-in + custom tools
  tools/mcp.go                MCP client + MCP server
  pipeline/pipeline.go        Message processing pipeline

internal/                     Infrastructure
  config/config.go            Config struct + SQLite key-value store
  logger/logger.go            JSON file (always) + SQLite (debug mode)
  auth/auth.go                Multi-user auth (bcrypt, sessions, middleware)
  whatsapp/whatsapp.go        WhatsApp connection (QR, send, receive)
  debounce/debounce.go        Message grouping per contact
  web/web.go                  HTTP routes and API handlers

templates/                    HTML pages (inline CSS/JS, no build step)

🧑‍💻 Development

make build               # Build binary (output: next)
make test                # Run all tests
make lint                # Run golangci-lint
make fmt                 # Format code
make check               # deps + fmt + vet + test (full CI check)
make install             # Build and install to ~/.next
make generate            # Run go generate
make run                 # Build and run
make clean               # Remove binary

Databases

Stored in ~/.next/ (or DB_PATH):

File Purpose
next.db App data (config, messages, summaries, knowledge, tasks, tools, agents, users, sessions, logs)
whatsapp.db WhatsApp session store (managed by whatsmeow)

📦 Tech Stack

Component Technology
Language Go
Database SQLite with FTS5
WhatsApp whatsmeow (Web multidevice protocol)
AI Client go-openai (any OpenAI-compatible API)
MCP mcp-go (SSE transport)
Auth bcrypt (golang.org/x/crypto)
External DBs MySQL (go-sql-driver), PostgreSQL (lib/pq)

📄 License

This project is licensed under the MIT License.


No frameworks, no build steps, no nonsense.


GitHub · MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors