Kazak automation backend
  • HTML 71.1%
  • JavaScript 28.9%
Find a file
2026-07-23 16:26:13 -06:00
dockerizer fixed port issues 2026-01-12 13:14:46 -06:00
references feat: save GPT diagnosis output as Kommo note 2026-02-19 03:29:12 +07:00
requirements_from_the_customer Session 4: meeting alignment, Kommo docs, prompt editor 2026-02-10 03:20:34 +07:00
scripts feat: save GPT diagnosis output as Kommo note 2026-02-19 03:29:12 +07:00
src feat: save GPT diagnosis output as Kommo note 2026-02-19 03:29:12 +07:00
test-results feat: save GPT diagnosis output as Kommo note 2026-02-19 03:29:12 +07:00
.dockerignore fixed port issues 2026-01-12 13:14:46 -06:00
.env.example feat: Gmail email service + Google Calendar integration 2026-02-19 02:51:57 +07:00
.gitignore Session 4: meeting alignment, Kommo docs, prompt editor 2026-02-10 03:20:34 +07:00
AGENTS.md feat(progress): Add progress tracking routes and documentation 2026-02-06 04:24:39 +07:00
deploy.js Target Kazak deployments at in2 2026-07-23 16:26:13 -06:00
KOMMO_SETUP.md Session 4: meeting alignment, Kommo docs, prompt editor 2026-02-10 03:20:34 +07:00
OUT_OF_SCOPE.md first commit 2026-01-05 08:12:18 -06:00
package-lock.json feat: Gmail email service + Google Calendar integration 2026-02-19 02:51:57 +07:00
package.json Target Kazak deployments at in2 2026-07-23 16:26:13 -06:00
previoud webhook URL.txt first commit 2026-01-05 08:12:18 -06:00
README.md Target Kazak deployments at in2 2026-07-23 16:26:13 -06:00
SPEC.md feat: update environment configuration and add Discord logging support 2026-01-23 14:04:21 -06:00
todo.md checkpoint 2026-02-06 03:06:40 +07:00

Kazak Automatizaciones Backend

Backend automation service for Kazak Consultores - Commercial Diagnosis workflow. Receives form submissions from Elementor, integrates with Kommo CRM and OpenAI, and manages leads through 3 pricing tiers (Free, $500, $1000).

Production URL: https://kazak.in2.altocontrastemexico.com/.

The former Banawork hostname forwards to production for the Google Apps Script webhook proxy. Deploy with npm run deploy.

Port is 3457, note we would need to change it in 2 places, the .env (if on easypanel it's changed on the .env interface, or if disabled on the file like usual) and the dockerizer/Dockerfile

Quick Start

# Install dependencies
npm install

# Copy environment template and fill in credentials
cp .env.example .env

# Start development server (with auto-reload)
npm run dev

# Start production server
npm start

Webhook URL

After starting the server, your webhook URL for Elementor is:

http://your-domain:3000/webhook/elementor

Or locally:

http://localhost:3000/webhook/elementor

Environment Variables

Create a .env file with:

# Server
PORT=3000

# PostgreSQL Database
DATABASE_URL=postgresql://user:password@host:port/database

# Kommo CRM (Long-lived access token)
KOMMO_SUBDOMAIN=your-subdomain
KOMMO_ACCESS_TOKEN=your-token

# OpenAI
OPENAI_API_KEY=sk-your-key

API Endpoints

Webhook

Method Endpoint Description
POST /webhook/elementor Receive Elementor form submissions
GET /webhook/test Test webhook route

Admin

Method Endpoint Description
GET /admin/logs View application logs
GET /admin/logs/errors View error logs only
GET /admin/db/init Initialize database tables
GET /admin/db/status Check database status
GET /admin/webhook-logs View stored webhook logs
GET /admin/leads View processed leads
GET /admin/gpt-outputs View GPT outputs
GET /admin/kommo/fields View Kommo lead/contact fields
GET /admin/kommo/pipelines View Kommo pipelines and stages
GET /admin/kommo/tags View Kommo tags
GET /admin/kommo/test Test Kommo API connection

Project Structure

├── src/
│   ├── index.js              # Express app entry point
│   ├── config/
│   │   ├── database.js       # PostgreSQL connection
│   │   └── db-init.js        # Database schema
│   ├── routes/
│   │   ├── webhook.js        # Webhook handlers
│   │   └── admin.js          # Admin dashboard
│   ├── services/
│   │   ├── kommoService.js   # Kommo CRM API client
│   │   ├── gptService.js     # OpenAI integration
│   │   └── leadProcessor.js  # Lead processing workflow
│   ├── prompts/
│   │   ├── PROMPT_GRATIS.md  # Free tier prompt
│   │   ├── PROMPT_500.md     # $500 tier prompt
│   │   └── PROMPT_1000.md    # $1000 tier prompt
│   └── utils/
│       └── logger.js         # Custom file logger
├── logs/                     # Log files
├── .env.example              # Environment template
└── package.json

Processing Flow

  1. Webhook Reception: Elementor form submits to /webhook/elementor
  2. Logging: Raw payload logged to database and files
  3. Option Detection: System detects Free/$500/$1000 based on form response
  4. Kommo Integration: Creates/updates contact and lead in CRM
  5. GPT Diagnosis: Generates diagnosis using appropriate prompt
  6. Task Creation: Creates follow-up tasks in Kommo if needed

First-Time Setup

  1. Start the server: npm run dev
  2. Visit http://localhost:3000/ to see available endpoints
  3. Set up database: Visit /admin/db/init
  4. Check Kommo connection: Visit /admin/kommo/account
  5. Send a test webhook to /webhook/elementor
  6. View webhook logs: /admin/webhook-logs

Notes