Skip to content
Internal product

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.

crm.webdev07.techInternal

Overview

Leads

+ Lead

120

contacts

30

active

0

errors

LeadSourceStage

Анна Орлова

@anna_ops

TelegramNew

Михаил Ковалёв

m.kovalev@example.com

PortfolioQualified

Ирина Соколова

@irina_smm

TelegramNew

Денис Морозов

@denis_build

AI OPSContacted
n8n outboxretry + HMAC

120+

Telegram contacts

30

active conversations

10+

features

1

user

HIGHLIGHT

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

01

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.

02

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.

03 — AI SYNC & ROUTING

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.

What AI does

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.

Routing parameters
sourcestagetemperaturescore 0–100budgetlanguagetimezonecontact channellast activitylead ageSLA without replyreply / no replyfollow-uptagsdelivery status
01

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.

02

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.

03

No duplicates

A repeated sync updates the same card. Dedupe by Telegram, email and phone; timeline and tasks are idempotent.

TASKS

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.

01Review
02Plan by dates
03Task queue
04Auto-close
04 — ARCHITECTURE

Architecture

Next.js accepts leads, SQLite stores leads and the outbox, and a worker delivers to n8n. Everything runs on one server behind Caddy.

01

Sources

Portfolio, AI OPS, Telegram JSON and manual entry.

02

API

Bearer key, idempotency and contact-based dedupe.

03

SQLite

Leads, events, tasks and the delivery queue in one file.

04

n8n

Webhook with HMAC, retries and a response log.

Contract with n8nlead.v1
{
  "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

Next.js 16SQLiten8nCaddysystemd

n8n receives lead.v1, verifies the HMAC signature and idempotency. On 5xx the CRM retries delivery.

05 — DECISIONS

Key decisions

01

One user, no roles

I did not build a team model and permissions that do not exist. One login, one owner, minimal entities.

02

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.

03

Outbox instead of direct fetch

If n8n is down, the delivery stays queued. A worker retries, and failures are visible in the journal.

04

Canonical lead.v1 payload

The CRM does not depend on the receiver format: one contract goes out, and n8n parses it in its workflow.

05

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.

06

State is never lost

Filters, sorting and columns live in the URL and sessionStorage: returning from a card opens the same working view.

06 — FEATURES

What is inside

01

Flexible columns: 21 fields, selection persisted in the URL

02

Inline editing for stage, temperature, score, budget and next-action date

03

Saved views: filters + sorting + columns

04

Advanced filters: score, contact channel, activity and age

05

SLA badge “N days without a reply”

06

Global search ⌘K / Alt+K across the whole database

07

Bulk actions and export of only the selected leads

08

Pinned leads and j/k row navigation

09

Tasks and next steps in one work screen

010

n8n outbox: HMAC, retries and a delivery log

011

Telegram lead import and dedupe by email / Telegram / phone

012

Intake API, SQLite, backup and systemd

013

AI-powered Telegram → CRM sync every 20 minutes

014

Routing by 15 parameters: score, budget, language, SLA and more

015

Task plan: first touch, follow-up, reply review, retry

07 — UI

What it looks like

Demo data: names, contacts and messages are fictional. No real leads are shown in the screenshots.

Overview01
CRM: leads, tasks and n8n errors overview
Leads and filters02
CRM: lead list with stages, score, budget and next action
Lead card03
CRM: lead card with stage, tags, tasks and n8n delivery
Tasks04
CRM: tasks screen with deadlines and next action
Filters05
CRM: filters by stage, source, temperature, tags, score, budget and next action