CRM.
A scenario with 120+ Telegram contacts and 30 active conversations: inbound forms from the portfolio and AI OPS, filters, tasks, inline edits and n8n delivery. AI-powered Telegram → CRM sync every 20 minutes and smart routing by 15 parameters.
Role
Architecture, full-stack, deployment
Year
2026
Status
Next.js 16 · SQLite · n8n
No public link: the CRM is available only to the owner. Metrics are a single-server load scenario, not public analytics.
Overview
Leads
120
contacts
30
active
0
errors
Анна Орлова
@anna_ops
Михаил Ковалёв
m.kovalev@example.com
Ирина Соколова
@irina_smm
Денис Морозов
@denis_build
120+
Telegram contacts
30
active conversations
10+
features
1
user
Smart sync powered by AI
Replies, stages and tasks update themselves: 20 minutes, 15 parameters, one next action.
20 min
sync cycle
15
routing parameters
4
task steps
The task
Leads arrived from the portfolio form, AI OPS and Telegram exports. Some were lost, duplicates were not tracked, and sending to n8n was manual.
The solution
One SQLite database, one intake API and one screen. Forms create leads automatically, duplicates merge by email, Telegram and phone, and n8n receives a signed payload from a retrying outbox.
What happens every 20 minutes
The model reads new messages, updates stage and temperature, and the sync writes it into the CRM. No duplicates, no lost replies.
Reads new messages, understands context, tells a live client from a bot or aggregator, and updates stage, temperature and tags. A deterministic sync moves history, score, follow-up and delivery errors; re-running it does not create duplicates.
Replies are read for meaning
An incoming message is never lost: the model decides whether it is a client, a bot or an aggregator, and updates stage, temperature and tags.
The next step appears
Context and the plan produce a task: reply, follow up, retry after PEER_FLOOD. There is always exactly one next action.
No duplicates
A repeated sync updates the same card. Dedupe by Telegram, email and phone; timeline and tasks are idempotent.
Tasks: plan first
A plan by dates and priorities: first touch, follow-up in 3 days, reply review, retry after PEER_FLOOD. Tasks and the next action are built from it.
Architecture
Next.js accepts leads, SQLite stores leads and the outbox, and a worker delivers to n8n. Everything runs on one server behind Caddy.
Sources
Portfolio, AI OPS, Telegram JSON and manual entry.
API
Bearer key, idempotency and contact-based dedupe.
SQLite
Leads, events, tasks and the delivery queue in one file.
n8n
Webhook with HMAC, retries and a response log.
{
"schema": "lead.v1",
"event": "lead.created",
"lead": {
"id": "ld_...",
"name": "Ivan",
"email": "ivan@example.com",
"source": "portfolio",
"temperature": "hot",
"score": 70
},
"consent": { "granted": true },
"meta": { "attempt": 1 }
}Stack
n8n receives lead.v1, verifies the HMAC signature and idempotency. On 5xx the CRM retries delivery.
Key decisions
One user, no roles
I did not build a team model and permissions that do not exist. One login, one owner, minimal entities.
SQLite instead of Postgres
For one user and dozens of leads a day, SQLite is faster, simpler and cheaper. WAL and indexes cover the filters.
Outbox instead of direct fetch
If n8n is down, the delivery stays queued. A worker retries, and failures are visible in the journal.
Canonical lead.v1 payload
The CRM does not depend on the receiver format: one contract goes out, and n8n parses it in its workflow.
The list is the workspace, not a showcase
Sorting, inline edits, bulk actions and saved views let one person work dozens of leads without constantly opening cards.
State is never lost
Filters, sorting and columns live in the URL and sessionStorage: returning from a card opens the same working view.
What is inside
Flexible columns: 21 fields, selection persisted in the URL
Inline editing for stage, temperature, score, budget and next-action date
Saved views: filters + sorting + columns
Advanced filters: score, contact channel, activity and age
SLA badge “N days without a reply”
Global search ⌘K / Alt+K across the whole database
Bulk actions and export of only the selected leads
Pinned leads and j/k row navigation
Tasks and next steps in one work screen
n8n outbox: HMAC, retries and a delivery log
Telegram lead import and dedupe by email / Telegram / phone
Intake API, SQLite, backup and systemd
AI-powered Telegram → CRM sync every 20 minutes
Routing by 15 parameters: score, budget, language, SLA and more
Task plan: first touch, follow-up, reply review, retry
What it looks like
Demo data: names, contacts and messages are fictional. No real leads are shown in the screenshots.




