Communitygithub.com

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Cài chatbot AI dạng floating widget góc dưới phải vào project Next.js có sẵn (App Router hoặc Pages Router), responsive đầy đủ web + tablet + mobile, gọi LLM qua OpenRouter (mặc định google/gemini-3-flash-preview, có thể đổi sang anthropic/claude-sonnet-4.6), streaming response, RENDER MARKDOWN trong assistant bubble (bold / list / link / code) qua react-markdown + remark-gfm — KHÔNG hiện raw **bold** dạng text — có knowledge base từ FAQ + tài liệu sản phẩm/khóa học do user cung cấp để chatbot tự động trả lời khách hàng, và TỰ ĐỘNG EXTRACT + LƯU LEAD (tên + SĐT + email) vào Upstash Redis/Vercel KV dưới namespace `chat-lead:{phone}` khi user cung cấp đầy đủ thông tin trong chat — dedupe theo SĐT, TTL 90 ngày, fire-and-forget không block stream. Skill tự detect số lượng project Next.js — nếu có nhiều hơn 1 sẽ hỏi user chọn project nào để cài; tự detect TypeScript/JS, App Router/Pages Router, Tailwind/CSS module, KV/Upstash availability (skip auto-save nếu chưa có); tự install react-markd

Qu'est-ce que MKT.LANDINGPAGE.SKILLS ?

MKT.LANDINGPAGE.SKILLS is a Claude Code agent skill that cài chatbot AI dạng floating widget góc dưới phải vào project Next.js có sẵn (App Router hoặc Pages Router), responsive đầy đủ web + tablet + mobile, gọi LLM qua OpenRouter (mặc định google/gemini-3-flash-preview, có thể đổi sang anthropic/claude-sonnet-4.6), streaming response, RENDER MARKDOWN trong assistant bubble (bold / list / link / code) qua react-markdown + remark-gfm — KHÔNG hiện raw **bold** dạng text — có knowledge base từ FAQ + tài liệu sản phẩm/khóa học do user cung cấp để chatbot tự động trả lời khách hàng, và TỰ ĐỘNG EXTRACT + LƯU LEAD (tên + SĐT + email) vào Upstash Redis/Vercel KV dưới namespace `chat-lead:{phone}` khi user cung cấp đầy đủ thông tin trong chat — dedupe theo SĐT, TTL 90 ngày, fire-and-forget không block stream. Skill tự detect số lượng project Next.js — nếu có nhiều hơn 1 sẽ hỏi user chọn project nào để cài; tự detect TypeScript/JS, App Router/Pages Router, Tailwind/CSS module, KV/Upstash availability (skip auto-save nếu chưa có); tự install react-markd.

Compatible avec✓Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/lexuanthanhhy/MKT.LANDINGPAGE.SKILLS/tree/main/.claude/skills/biz-nextjs-chatbot-openrouter

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Biz Next.js Chatbot OpenRouter — Cài chatbot AI floating vào website 1 phát

Skill này gắn 1 chatbot AI dạng floating widget vào project Next.js có sẵn. Widget nằm góc dưới phải, responsive đầy đủ 3 màn hình, gọi LLM qua OpenRouter với knowledge base từ FAQ + tài liệu khóa học/sản phẩm, render markdown trong assistant bubble (bold cho số/giá, bullet list, link clickable, code inline) bằng react-markdown + remark-gfm, và tự động extract + lưu lead (tên + SĐT + email) vào KV (Upstash Redis / Vercel KV) khi user cung cấp đầy đủ thông tin trong chat — admin xem được qua /admin dashboard. Mục tiêu: solopreneur / course creator có support bot tự động 24/7 + lead capture passive ngay trên landing page bán khóa học, không bỏ sót khách hỏi qua chat.

Tinh thần: Tự detect mọi thứ có thể (Next.js version, App/Pages Router, TS/JS, Tailwind/CSS), chỉ hỏi user 4 thứ thật sự cần: (1) project nào nếu có nhiều, (2) FAQ, (3) tài liệu sản phẩm, (4) tone/brand name. Còn lại là code → live trong vài phút.

Khi nào dùng

User muốn:

  • Gắn chatbot AI hỗ trợ khách hàng vào landing page bán khóa học / dịch vụ
  • Giảm tải trả lời câu hỏi lặp lại (giá, lộ trình, hoàn tiền, đối tượng phù hợp...)
  • Cần widget chat nhỏ gọn góc dưới phải, không che nội dung
  • Cần chatbot hiểu chính xác nội dung khóa học / sản phẩm của họ (FAQ-driven)
  • Đã có Next.js project (vừa chạy /biz-sales-page-layout xong, hoặc project cũ)

Khi nào KHÔNG dùng

  • Project không phải Next.js (React thuần Vite, Vue, Svelte, plain HTML) → skill này chuyên Next.js. Có thể adapt nhưng không tối ưu.
  • Cần chatbot có RAG (retrieval-augmented) với knowledge base hàng ngàn trang → cần vector DB (Pinecone/Supabase pgvector), skill này dùng system prompt đơn giản phù hợp ≤ 20K token kiến thức.
  • Cần chatbot voice / multimodal (gửi ảnh) → skill này text-only.
  • Cần chatbot lưu lịch sử chat per-user vào DB → skill này stateless, ephemeral session, có thể mở rộng sau.
  • Backend không phải Vercel-friendly (cần long polling, WebSocket persistent) → OpenRouter streaming hoạt động OK trên Vercel Edge, nhưng nếu cần WS riêng thì khác.

Output user sẽ nhận

Sau khi skill chạy xong:

  1. File mới trong project Next.js của user:

    • components/Chatbot.tsx (hoặc .jsx) — widget UI (render markdown qua react-markdown + remark-gfm)
    • app/api/chat/route.ts (App Router) HOẶC pages/api/chat.ts (Pages Router) — API proxy gọi OpenRouter + auto extract lead sau stream
    • lib/chatbot-knowledge.ts (hoặc .js) — knowledge base + system prompt (có block ĐỊNH DẠNG TRẢ LỜI + block THU THẬP LEAD CHỦ ĐỘNG)
    • lib/chat-lead.ts — CHỈ tạo nếu project có KV/Upstash — extractor + saver, dedupe theo SĐT, TTL 90 ngày, namespace chat-lead:{phone}
    • Markdown styles .chatbot-md append vào app/globals.css (từ templates/chatbot-markdown-styles.css)
    • .env.local được tạo/append với OPENROUTER_API_KEY= (placeholder)
    • .env.example (nếu chưa có) để document biến môi trường
    • Mount <Chatbot /> vào app/layout.tsx hoặc pages/_app.tsx
  2. Packages cài thêm (qua package manager đã detect từ lockfile):

    • react-markdown — render markdown an toàn (không cần dangerouslySetInnerHTML)
    • remark-gfm — GitHub Flavored Markdown (table, autolink, strikethrough)
  3. Hướng dẫn rõ ràng cuối session:

    • 3 bước user phải tự làm: (a) lấy OpenRouter API key, (b) paste vào .env.local, (c) npm run dev test
    • Cách đổi model giữa Gemini và Sonnet
    • Cách update knowledge base sau này

Workflow

Bước 1 — Detect Next.js project

Tìm các Next.js project candidate. Chạy:

# Tìm package.json có chứa "next" trong dependencies, độ sâu tối đa 4
find /Users/tonyhoang/Documents/GitHub -maxdepth 4 -name "package.json" -not -path "*/node_modules/*" 2>/dev/null | xargs grep -l '"next"' 2>/dev/null | head -20

(Nếu user đang ở trong 1 working directory cụ thể, ưu tiên tìm từ cwd xuống trước, fallback ra ~/Documents/GitHub nếu không thấy.)

Phân nhánh:

  • 0 project: Báo user và dừng. Đề xuất: "Anh/chị có project Next.js nào chưa? Nếu chưa, có muốn em tạo 1 cái mới với /biz-sales-page-layout rồi quay lại không?"
  • 1 project: Confirm path với user trước khi proceed: "Em sẽ cài chatbot vào [path]. Anh/chị OK chứ?"
  • ≥ 2 project: Liệt kê path + tên (name từ package.json) ra list đánh số, hỏi user pick: "Em thấy có N project Next.js. Anh/chị muốn cài vào cái nào?"

Bước 2 — Probe project context

Sau khi user xác nhận project, đọc:

  1. package.json → check:

    • TypeScript (có typescript trong deps?)
    • Tailwind (có tailwindcss trong devDeps?)
    • Package manager (lockfile: pnpm-lock.yaml → pnpm, yarn.lock → yarn, default npm)
    • Next.js version
  2. Cấu trúc thư mục → check:

    • app/ directory tồn tại → App Router
    • pages/ directory tồn tại (và không có app/) → Pages Router
    • Cả 2 cùng tồn tại → ưu tiên App Router cho file mới (Next.js đang chuyển sang)
    • src/ wrapper → adjust path (vd. src/app/, src/components/)
  3. tsconfig.json → check path alias (@/* → ./src/* hay ./*)

  4. .env.local, .env.example → check đã tồn tại chưa

  5. KV/Upstash availability (cho auto lead capture):

    • package.json có @upstash/redis HOẶC @vercel/kv → có KV → SCAFFOLD chat-lead.ts + wire vào route
    • Có file src/lib/kv.ts (hoặc lib/kv.ts) export kv → dùng luôn helper sẵn (camp pattern)
    • Không có KV → SKIP scaffold chat-lead.ts, báo user: "Project chưa có KV — auto lead capture không bật. Em có thể chạy /biz-setup-sepay-payment để cài KV trước rồi quay lại bật lead capture, hoặc skip."

Lưu các quan sát này thành 1 bảng nhỏ để dùng ở các bước sau.

Bước 3 — Thu thập knowledge base từ user

Hỏi user 4 câu (gộp trong 1 message để user trả lời 1 lần, đỡ qua lại):

Để chatbot trả lời chính xác, em cần 4 thứ:

1. **FAQ** — danh sách câu hỏi thường gặp + câu trả lời (giá, lộ trình, hoàn tiền, đối tượng, thời gian học, hỗ trợ sau khóa...). 
   Anh/chị paste trực tiếp vào đây, HOẶC chỉ đường dẫn file (.md / .txt / .docx).

2. **Tài liệu sản phẩm / khóa học** — mô tả chi tiết khóa học: tên, nội dung từng module, kết quả đầu ra, giảng viên, bonus, giá tier nếu có nhiều.
   Cũng paste hoặc chỉ đường dẫn file.

3. **Brand name + tone** — Tên brand/khóa học để chatbot xưng hô (vd. "trợ lý của AI Mastery"). Tone bot dùng: thân thiện anh/chị (mặc định) / formal / casual em-bạn.

4. **Model** — mặc định `google/gemini-3-flash-preview` (nhanh, rẻ, đủ tốt cho support). Muốn dùng `anthropic/claude-sonnet-4.6` (chất lượng cao hơn, đắt hơn ~10x) cho early stage chatlượng đầu vẫn thấp thì nói em.

Anh/chị trả lời 1 lượt được không?

Khi user trả lời:

  • Nếu chỉ đường dẫn file → đọc file đó bằng Read tool.
  • Nếu paste nội dung trực tiếp → dùng nội dung paste.
  • Nếu user nói "tự generate placeholder dùm em" → tạo FAQ placeholder generic và đánh dấu // TODO: user fill in để user biết phải cập nhật.
  • Brand name không có → default "Trợ lý AI" và xưng anh/chị.

Bước 4 — Generate các file vào project

Đọc các template trong templates/ của skill này và adapt vào project. Các template:

  • templates/chatbot-knowledge.ts — Module export knowledge base + systemPrompt. Inject FAQ, product info, brand name, tone vào đây. Có sẵn block ĐỊNH DẠNG TRẢ LỜI (markdown rules) + block THU THẬP LEAD CHỦ ĐỘNG (dạy LLM xin tên/SĐT/email khi buyer signal, cảm ơn + confirm khi user cung cấp, KHÔNG nói "đã lưu database").
  • templates/Chatbot.tsx — Widget component, Tailwind-first. Đã import react-markdown + remark-gfm, render assistant message bằng <ReactMarkdown remarkPlugins={[remarkGfm]}> (chỉ assistant — user message vẫn plain whitespace-pre-wrap). Nếu project KHÔNG có Tailwind → fallback templates/Chatbot-noTailwind.tsx + templates/chatbot.module.css.
  • templates/chat-route-app.ts — API route cho App Router (app/api/chat/route.ts). Có sẵn hook persistLeadIfReady chạy fire-and-forget sau khi stream close — không block response.
  • templates/chat-route-pages.ts — API route cho Pages Router (pages/api/chat.ts).
  • templates/chat-lead.ts — CHỈ scaffold nếu project có KV/Upstash — regex extract VN phone + email + name heuristic (intro patterns "tên X" / "tôi là X" / "tên: X"), saveChatLead dedupe theo SĐT, TTL 90 ngày, key namespace chat-lead:{phone}.
  • templates/chatbot-markdown-styles.css — Snippet CSS cho class .chatbot-md. PHẢI append vào cuối app/globals.css (hoặc src/app/globals.css / styles/globals.css). Đổi accent color (#fde68a / #f59e0b) theo brand palette của project trước khi append.
  • templates/env-instructions.md — Snippet hướng dẫn lấy OpenRouter key, dùng ở bước cuối.

Quy tắc khi adapt template:

  1. TS vs JS: nếu project chỉ có JS, đổi extension .ts/.tsx → .js/.jsx và bỏ type annotations (không chỉ đổi tên file). Đọc file mẫu, parse, bỏ types, ghi ra.

  2. Path alias: nếu tsconfig map @/* → ./src/*, các import trong template phải dùng @/lib/chatbot-knowledge và file đặt vào src/lib/. Nếu không có alias, dùng relative path.

  3. Model: replace placeholder __MODEL_ID__ bằng model user chọn (google/gemini-3-flash-preview hoặc anthropic/claude-sonnet-4.6).

  4. Brand: replace __BRAND_NAME__, __BRAND_TONE__.

  5. Knowledge: build systemPrompt từ FAQ + product info dạng cấu trúc rõ ràng (xem template). Giữ nguyên block ĐỊNH DẠNG TRẢ LỜI trong systemPrompt — đây là cái dạy LLM xuất markdown phù hợp với bubble chat nhỏ (bold thay vì heading, bullet ngắn 1 dòng).

  6. Install packages markdown rendering (BẮT BUỘC — nếu skip thì chatbot hiện raw **bold** thay vì in đậm trong bubble):

    # detect lockfile → chọn đúng package manager
    npm install react-markdown remark-gfm
    # hoặc: pnpm add react-markdown remark-gfm
    # hoặc: yarn add react-markdown remark-gfm
    
  7. Append markdown styles: đọc templates/chatbot-markdown-styles.css, swap accent color theo brand palette của project (check globals.css tìm --color-primary hoặc tương đương), rồi append vào cuối app/globals.css (hoặc src/app/globals.css / styles/globals.css).

  8. Mount widget:

    • App Router: edit app/layout.tsx (hoặc src/app/layout.tsx), thêm import Chatbot from '@/components/Chatbot' và <Chatbot /> ngay trước </body>. Đọc layout.tsx hiện tại trước khi edit để giữ nguyên metadata, fonts, providers.
    • Pages Router: edit pages/_app.tsx, wrap return: <><Component {...pageProps} /><Chatbot /></>. Đọc _app trước, giữ nguyên existing providers.
  9. Auto lead capture wire-up (chỉ làm nếu đã detect KV ở Bước 2):

    • Copy templates/chat-lead.ts vào lib/chat-lead.ts (hoặc src/lib/chat-lead.ts).
    • Nếu project CHƯA có lib/kv.ts → tạo: import { Redis } from "@upstash/redis"; export const kv = Redis.fromEnv();
    • Route handler import: import { extractLeadFromMessages, saveChatLead } from "@/lib/chat-lead".
    • Trong stream loop: track assistantText (accumulate delta), khi stream close → gọi persistLeadIfReady(history, assistantText) (fire-and-forget, KHÔNG await trong response path).
    • System prompt: đảm bảo block THU THẬP LEAD CHỦ ĐỘNG đã có trong chatbot-knowledge.ts (template đã có sẵn).
    • Confirm với user: "Em đã bật auto lead capture — khi khách paste tên/SĐT/email vào chat, hệ thống tự lưu KV namespace chat-lead:{SĐT}. Anh/chị xem leads qua /admin (nếu đã cài /biz-admin-leads-dashboard)."

Bước 5 — Setup .env.local + .gitignore

  1. Check .env.local đã tồn tại?

    • Chưa: tạo mới với:
      # OpenRouter API key — Lấy ở https://openrouter.ai/keys
      OPENROUTER_API_KEY=
      
      # Optional: site URL để OpenRouter tracking referrer (giúp rate limit tốt hơn)
      NEXT_PUBLIC_SITE_URL=http://localhost:3000
      
    • Đã có: append 2 biến trên nếu chưa có, không ghi đè biến cũ.
  2. Update .env.example (tạo mới nếu chưa có):

    OPENROUTER_API_KEY=sk-or-v1-xxxxx
    NEXT_PUBLIC_SITE_URL=https://your-domain.com
    
  3. Check .gitignore đã có .env.local? Nếu chưa → append .env.local và .env*.local.

Bước 6 — Báo cáo cho user

In ra 1 message tóm tắt rõ ràng với 4 phần:

✅ Chatbot đã cài xong vào [project name]

📁 Files đã tạo:
  - components/Chatbot.tsx (render markdown qua react-markdown + remark-gfm)
  - app/api/chat/route.ts
  - lib/chatbot-knowledge.ts
  - app/globals.css (append markdown styles .chatbot-md)
  - .env.local (placeholder)

📦 Packages đã cài: react-markdown, remark-gfm

🔑 3 bước anh/chị cần tự làm để chatbot chạy:

1. Lấy OpenRouter API key:
   - Vào https://openrouter.ai → Sign up (có thể login bằng Google)
   - Vào https://openrouter.ai/keys → Create Key
   - Nạp credit (https://openrouter.ai/credits) — Gemini 3 Flash rẻ, $5 đủ chạy hàng nghìn câu chat
   - Copy key dạng `sk-or-v1-xxxxx`

2. Paste vào file `.env.local`:
   OPENROUTER_API_KEY=sk-or-v1-xxxxx-paste-vào-đây

3. Chạy thử:
   [npm/pnpm/yarn] run dev
   Mở http://localhost:3000 → click bong bóng góc dưới phải

🔄 Đổi model giữa Gemini ↔ Sonnet:
  Mở `app/api/chat/route.ts`, sửa biến `model:` ở đầu file.
  - `google/gemini-3-flash-preview` (mặc định, $0.075/1M input, nhanh)
  - `anthropic/claude-sonnet-4.6` (cao cấp, ~$3/1M input, chất lượng tốt hơn)

📚 Update knowledge base sau này:
  Edit `lib/chatbot-knowledge.ts` — thêm/sửa FAQ và productInfo, save, hot reload.

Mobile-first responsive design

Widget phải đạt 3 breakpoint:

BreakpointHành vi
≤ 640px (mobile)Click bubble → mở fullscreen overlay (z-index 9999), header có nút X close. Input docked bottom với safe-area-inset để không bị che bởi keyboard.
641–1023px (tablet)Panel 380px × 70vh, anchored bottom-right margin 16px.
≥ 1024px (desktop)Panel 400px × 600px, anchored bottom-right margin 24px. Bubble 60px tròn.

Lý do mobile fullscreen: VN traffic 70%+ là mobile, panel 380px trên màn 360px sẽ overflow + bàn phím che gần hết. Fullscreen là UX chuẩn (Intercom, Tidio, Crisp đều làm vậy).

Template Chatbot.tsx đã có sẵn các Tailwind class implement chuẩn này. Khi adapt, giữ nguyên responsive logic, chỉ thay đổi màu/text theo brand.

OpenRouter API — Quick reference

OpenRouter endpoint: https://openrouter.ai/api/v1/chat/completions

Headers bắt buộc:

  • Authorization: Bearer <OPENROUTER_API_KEY>
  • Content-Type: application/json

Headers khuyến nghị (giúp rate limit + analytics):

  • HTTP-Referer: <site URL>
  • X-Title: <app name> (vd. "AI Mastery Chatbot")

Body:

{
  "model": "google/gemini-3-flash-preview",
  "messages": [
    {"role": "system", "content": "..."},
    {"role": "user", "content": "..."}
  ],
  "stream": true
}

Streaming response: SSE format (data: {...}\n\n). Template chat-route-app.ts đã handle pass-through stream từ OpenRouter về client, frontend parse SSE bằng ReadableStream reader. Không cần SDK — fetch thuần đủ.

Chi tiết thêm: xem references/openrouter-api.md.

Edge cases cần xử lý

  1. Project có src/ wrapper: tất cả path phải tiền tố src/ (vd. src/components/Chatbot.tsx, src/app/layout.tsx). Detect bằng cách check src/app hoặc src/pages tồn tại.

  2. Project đã có file trùng tên (vd. components/Chatbot.tsx đã có): hỏi user — overwrite hay đổi tên (vd. AIChatbot.tsx). Mặc định đổi tên để không destroy work cũ.

  3. Tailwind chưa cài:

    • Hỏi user: cài Tailwind không (recommended), hay dùng CSS module fallback?
    • Nếu chọn Tailwind: chạy npx tailwindcss init -p và setup, hoặc nếu phức tạp thì dùng fallback và note lại cho user.
    • Mặc định fallback CSS module — an toàn hơn, không invasive với project.
  4. Project dùng React 19 / Server Components strict: Chatbot.tsx phải có 'use client' directive ở dòng đầu. Template đã có.

  5. Conflict với existing /api/chat route: kiểm tra trước khi tạo. Nếu trùng → đổi tên route thành /api/chatbot hoặc tương tự, update fetch URL trong widget.

  6. Knowledge base quá dài (>15K token): chia thành 2 phần — coreKnowledge (system prompt, luôn load) và extendedKnowledge (optional, kèm khi user hỏi về chi tiết cụ thể). Tạm thời implement đơn giản: cảnh báo user nếu >15K chars, gợi ý cắt gọn FAQ.

  7. User trả lời thiếu (vd. có FAQ nhưng không có product info): vẫn proceed với phần có, để placeholder // TODO: user add product details here ở chỗ thiếu.

  8. Project không có KV/Upstash: SKIP scaffold chat-lead.ts. Vẫn cài chatbot full markdown + knowledge base — chỉ thiếu auto-save lead. Báo user 1 dòng: "Auto lead capture skip vì chưa có KV. Cài KV trước qua /biz-setup-sepay-payment (hoặc tự cài @upstash/redis + Vercel KV) rồi báo em bật sau."

  9. Project đã có /api/register hoặc lead store khác (vd. biz pipeline đã chạy /biz-setup-sepay-payment): dùng namespace KHÁC (chat-lead:{phone}) để không xung đột với lead:DH... của form đăng ký. Admin dashboard /admin có thể được mở rộng để show cả 2 type sau.

  10. Admin dashboard tích hợp: Nếu project đã cài /biz-admin-leads-dashboard, cần update query để include chat-lead:* keys song song với lead:*. Skill này KHÔNG tự update dashboard — báo user để chạy lại /biz-admin-leads-dashboard với extension cho chat-lead namespace.

Cấu trúc system prompt (built từ knowledge base)

Template chatbot-knowledge.ts build systemPrompt theo cấu trúc:

Bạn là trợ lý AI của [BRAND_NAME].

NHIỆM VỤ:
- Trả lời câu hỏi của khách hàng về sản phẩm/khóa học của [BRAND_NAME]
- Hỗ trợ khách hàng quyết định mua / đăng ký
- KHÔNG bịa thông tin. Nếu không chắc, nói "Em sẽ kiểm tra và phản hồi anh/chị qua email/SĐT".
- KHÔNG trả lời câu hỏi off-topic (chính trị, ý kiến cá nhân, code task...). Lịch sự đổi chủ đề về sản phẩm.

GIỌNG ĐIỆU:
- Xưng [em] - gọi khách [anh/chị] (hoặc theo tone user chỉ định)
- Thân thiện, ngắn gọn, action-oriented
- Mỗi câu trả lời ≤ 4 câu trừ khi cần list chi tiết

ĐỊNH DẠNG TRẢ LỜI (Markdown — chatbot UI có render markdown):
- Dùng **bold** cho số liệu / từ khóa quan trọng (vd. **499.000đ**, **Tier Premium**).
- Dùng bullet list `-` khi liệt kê 2+ items.
- Dùng numbered list `1. 2. 3.` khi nói các bước.
- KHÔNG dùng heading lớn (# / ##) — bubble chat nhỏ, heading vỡ layout.
- KHÔNG dùng table trừ khi so sánh 3+ items.

THÔNG TIN SẢN PHẨM:
[productInfo từ user]

FAQ:
[Q-A pairs từ user]

NẾU KHÁCH MUỐN ĐĂNG KÝ / MUA:
- Hướng dẫn họ scroll lên form đăng ký trên trang (tên/SĐT/email)
- Hoặc cung cấp link đăng ký nếu có

Quan trọng: block ĐỊNH DẠNG TRẢ LỜI là cái dạy LLM xuất markdown đúng phong cách bubble chat. Phải có 2 chiều cùng lúc:

  • Server-side (system prompt): yêu cầu LLM dùng **bold** / - bullet / 1. numbered, KHÔNG dùng heading.
  • Client-side (Chatbot.tsx): render markdown bằng react-markdown + class .chatbot-md styled trong globals.css.

Thiếu 1 trong 2 → chatbot hiện raw **bold** dạng text (nếu thiếu client render) hoặc LLM trả về flat text không format (nếu thiếu system prompt guidance).

Tone block thay đổi theo user input. FAQ format dạng:

Q: [câu hỏi]
A: [câu trả lời]

Anti-patterns — tránh các sai lầm này

  • Không hardcode API key vào code (luôn dùng process.env.OPENROUTER_API_KEY)
  • Không expose key ra client (NEXT_PUBLIC_*) — API route chạy server-side proxy
  • Không dùng dangerouslySetInnerHTML để render message — XSS risk. Dùng react-markdown (đã có trong template) — nó sanitize HTML mặc định, an toàn.
  • Không quên install react-markdown + remark-gfm. Quên 1 trong 2 → chatbot crash hoặc hiện raw **bold** dạng text thay vì in đậm.
  • Không quên append .chatbot-md CSS vào globals.css. Quên thì markdown render OK nhưng không có style (no bold color, no list indent...).
  • Không apply class .chatbot-md lên user bubble — markdown của user là text họ gõ (vd. họ hỏi "giá bao nhiêu?"), không nên parse thành bold. Chỉ assistant bubble mới render markdown.
  • Không await persistLeadIfReady trong response path — phải fire-and-forget (void (async () => {...})()). Await sẽ delay UI close stream → user thấy "đang trả lời" thêm vài giây.
  • Không để LLM nói "tôi đã lưu thông tin của bạn vào hệ thống" — creepy + lộ cơ chế. System prompt phải dạy: "em đã ghi nhận, team sẽ liên hệ trong 24h".
  • Không dùng cùng namespace lead: với form đăng ký — chat lead dùng chat-lead:{phone} để dedupe riêng + không ghi đè order data.
  • Không lưu lead khi chỉ có 1-2 trường trong 3 (tên + SĐT + email). Extractor trả null → save skip. Đợi user trả đủ rồi mới lưu.
  • Không rate limit ở client (dễ bypass) — nếu cần, thêm Upstash Ratelimit ở API route. Skill này skip rate limit để tối giản; lưu ý cho user.
  • Không mount widget vào head hoặc trước hydration — phải client component, mount trong body.
  • Không dùng position: fixed mà thiếu safe-area-inset-bottom trên mobile (iPhone notch).
  • Không dùng z-index < 50 cho widget — sẽ bị các modal khác che. Mặc định z-9999.

Khi user yêu cầu mở rộng sau này

Sau khi skill chạy xong, user có thể yêu cầu:

  • "Thêm streaming text typing effect" → đã có sẵn trong template, chỉ cần verify
  • "Lưu lịch sử chat vào localStorage" → thêm useEffect save/load messages từ localStorage
  • "Thêm rate limit" → cài @upstash/ratelimit + @upstash/redis, wrap API route
  • "Đổi sang model khác" (vd. meta-llama/llama-3.3-70b-instruct) → chỉ sửa biến model: trong API route
  • "Thêm RAG với knowledge dài hơn" → setup Supabase pgvector hoặc Pinecone, embed FAQ, query top-k khi user hỏi
  • "Đa ngôn ngữ" → detect user language, swap system prompt theo locale

Các yêu cầu này nằm ngoài scope skill base, nhưng skill đã đặt foundation tốt để mở rộng — code clean, knowledge tách module, API route stateless.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Best practices for Remotion - Video creation in React

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Scaffold trang `/admin` CRM-style trực quan vào Next.js project (Supabase backend) — KHÔNG còn variant Vercel KV. Layout 1CRM-inspired: sidebar 3 tab (Tổng quan / Khách hàng / Email marketing) + popup nhập mã đăng nhập. **Tab Tổng quan**: 4 KPI cards (Tổng leads / Đã thanh toán / Tỷ lệ chuyển đổi / Doanh thu) có delta arrow vs kỳ trước, line chart leads+paid+revenue theo ngày dùng `recharts`, donut trạng thái paid/pending/expired, period selector pill 7d/30d/90d, list 5 thanh toán gần nhất. **Tab Khách hàng**: bảng leads + search + filter trạng thái + filter ngày + CSV export. **Tab Email marketing**: form soạn chiến dịch (tên + tiêu đề + body chọn định dạng **văn bản thường HOẶC HTML** + placeholder `{{name}}` + audience 4 loại all/paid/pending/last_days + tên người gửi) — có nút **Xem trước** mở modal iframe render đúng email thật (text → auto convert + wrap khung; HTML fragment → wrap khung, HTML đầy đủ giữ nguyên) → gửi bulk qua SMTP (reuse `nodemailer` của `biz-email-setup` — KHÔN

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Deploy landing page / website (React, Next.js, Vite, static HTML) lên Vercel — tự kiểm tra Vercel CLI hoặc Vercel MCP đã cài chưa, nếu chưa thì cài qua npm/pnpm và hướng dẫn user authenticate (vercel login), tự detect framework (Next.js / Vite / CRA / static), auto-generate vercel.json khi cần, chạy `vercel --prod`, trả về live URL + inspect URL + hướng dẫn custom domain. USE WHEN user says 'deploy lên vercel', 'đẩy landing page lên vercel', 'publish website', 'go live', 'deploy nextjs', 'deploy react', 'deploy vite', 'tạo URL live', 'đưa lên production', 'biz-deploy-vercel', 'host landing page', 'vercel deploy', 'ship lên vercel', 'đẩy code lên vercel'. Skill này áp dụng cho cả case dùng Vercel CLI lẫn Vercel MCP server.

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Setup SMTP-based email auto-responder cho landing page bán hàng — tự động gửi email sau khi user điền form (tên/SĐT/email), KHÔNG cố định vào provider nào. Skill này (1) hỏi user chọn SMTP provider (Gmail/Google Workspace, Resend SMTP, SendGrid, Mailgun, Brevo, Zoho, hoặc SMTP custom của hosting VN) và detect Next.js stack đang dùng, (2) đọc context từ `offer.json` + `conversion-copy.md` (từ `/biz-offer-alex-hormozi`) HOẶC đọc trực tiếp Next.js project đã build qua `ui-ux-pro-max` (file `app/page.tsx`) HOẶC đọc HTML landing page đã deploy để hiểu offer, dream outcome, mechanism, bonus. Lưu ý: skill `biz-sales-page-layout` đã DEPRECATED 2026-05-14 — pipeline mới skip layout/copy.json, (3) **draft 2 email**: email A — auto-responder gửi cho lead (warm welcome + deliver lead magnet/booking confirm/payment link tuỳ offer type), email B — notification gửi cho owner (lead alert + thông tin liên hệ), (4) **show draft cho user duyệt và chỉnh sửa** trước khi wire vào code, (5) cài `nodemailer`

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Đóng gói offer **không thể chối từ** (grand slam offer) theo phương pháp Alex Hormozi ($100M Offers) — nhận input pains/gains/customer jobs theo Value Proposition Design (Osterwalder 2014) + sản phẩm/dịch vụ, rồi sinh ra: (1) markdown report tiếng Việt đầy đủ Value Equation scoring + Core Offer + 3-4 Bonus stack + Guarantee + Urgency + Pricing, (2) offer.json structured cho pipeline downstream (`ui-ux-pro-max` build sales page production-ready), (3) conversion copy block (headline + subheadline + CTA) sẵn sàng paste landing page. 2 input mode: (B) user paste sẵn pains + gains + product, (C) user chỉ có sản phẩm — skill phỏng vấn theo VPD framework để surface pain/gain trước. Bonus stack mode hybrid: skill brainstorm 5-7 candidate có justification value rồi user pick/chỉnh 3-4 cái. Tiếng Việt thuần (xưng anh/chị), giá VND charm pricing (X99K), 3-tier decoy structure. USE WHEN user says 'đóng gói offer', 'tạo offer', 'thiết kế offer Hormozi', 'grand slam offer', 'value stack', 'offer sta

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Nâng cấp copy sales page tiếng Việt — biến copy có sẵn (từ `offer.json` + `conversion-copy.md` của `/biz-offer-alex-hormozi`, HOẶC từ Next.js project đã build qua `ui-ux-pro-max`, HOẶC user paste block copy bất kỳ) thành **copy chất lượng cao chốt đơn**: headline punchy hơn, pain agitation đau hơn, mechanism rõ hơn, benefit cụ thể hơn, FAQ xử lý đúng objection của thị trường VN, CTA mạnh hơn. Skill này có 3 INTENSITY LEVEL: (1) **Polish** — light edit + power word + sửa nhịp; (2) **Conversion-optimized** — rewrite 5 block critical + tạo A/B variants cho hero/CTA; (3) **Sales-letter** — long-form story-driven full rewrite kèm P.S.. Mỗi section áp dụng đúng formula thuyết phục (PAR cho pain, BAB cho solution, FEP cho benefit, PVEN cho final CTA, Star-Chain-Hook cho testimonial). Output gồm 4 file: `copy-upgraded.md`, `copy-variants.md` (A/B test bank — 3 hero + 3 CTA + 3 final-CTA), `copy-changes.md` (diff Trước/Sau + lý do), `copy.json` (structured downstream). Giọng văn tiếng Việt thuầ

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

⚠️ DEPRECATED (2026-05-14) — Skill này KHÔNG còn trong pipeline chuẩn. Quy trình mới đã bỏ bước wireframe markdown trung gian: sau `/biz-offer-alex-hormozi` đi THẲNG sang `ui-ux-pro-max` để build Next.js sales page production-ready (có design language nhất quán: style + palette + font pairing, không phải Tailwind defaults). Lý do deprecate: wireframe markdown làm thêm 1 bước trung gian không tạo giá trị — `ui-ux-pro-max` đọc trực tiếp `offer.json` đã đầy đủ anchor + core + bonus + guarantee + urgency + pricing rồi ra HTML production luôn. Chỉ dùng skill này KHI user EXPLICITLY yêu cầu wireframe markdown để review/in/share trước khi build code (rare case). KHÔNG trigger trên các keyword 'tạo sales page', 'tạo landing page bán hàng' nữa — những keyword đó giờ trigger `ui-ux-pro-max`.

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

End-to-end Sepay VietQR payment infrastructure cho landing page Next.js — guide user setup Sepay account + bank linking + scaffold đầy đủ payment flow trong project. Skill này xử lý 7 phase: (0) detect Next.js stack + **HỎI user chọn lead store backend** (Vercel KV hoặc Supabase Free Postgres — default recommend Supabase do free tier rộng hơn ~50× + có SQL + admin UI), (1) GUIDE user đăng ký Sepay account tại my.sepay.vn + link bank account VN (Vietcombank/Techcombank/MB/ACB/VPBank/BIDV/...) + lấy API key + setup webhook URL trên Sepay dashboard, (2A nếu chọn KV) setup Vercel KV (install `@vercel/kv` + KV namespace + 4 env vars KV_*), (2B nếu chọn Supabase) setup Supabase project (tạo project tại Singapore region + chạy migration SQL tạo 4 bảng leads/phone_index/order_counter/webhook_dedup với pg_cron TTL cleanup + RLS deny-all + lấy SUPABASE_URL + SUPABASE_SERVICE_ROLE_KEY + Vercel Cron ping `/api/health` mỗi 6 ngày chống auto-pause), (3) scaffold `lib/leads-store.ts` (thin re-export

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Setup Telegram bot notification cho thanh toán thành công từ Sepay webhook trong Next.js project. Skill này: (1) hướng dẫn user 3 bước tạo Telegram bot riêng qua @BotFather + lấy bot token + chat_id (qua @userinfobot cho chat 1-1, hoặc /getUpdates API cho group), (2) tạo helper function `sendTelegramNotification()` reusable trong `lib/telegram.ts`, (3) detect existing Sepay webhook route trong project (thường là `/api/sepay-webhook`, `/api/payment-success`, hoặc tương đương) và wire Telegram call CÙNG CHỖ với email auto-responder (Resend) — gửi parallel qua `Promise.allSettled` để Telegram fail KHÔNG block 200 response trả Sepay (Sepay sẽ retry webhook nếu nhận non-200, gây duplicate notification), (4) draft message format mặc định tiếng Việt: emoji + tên khách + SĐT + email + amount (charm pricing VND định dạng `499.000đ`) + tên sản phẩm + timestamp giờ VN dd/mm/yyyy HH:mm, (5) update `.env.local` với `TELEGRAM_BOT_TOKEN` + `TELEGRAM_CHAT_ID`, add vào `.gitignore`, nhắc user paste vào

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Convert a single MP3 voiceover file into a single HeyGen avatar lip-sync MP4 video. Single-purpose — no planning, no SRT, no chunking, no Remotion compositing. Hybrid path — REST upload (helper script) + HeyGen MCP for video creation, because the post-2026 MCP no longer exposes an asset-upload tool. Reads avatar look pool (`HEYGEN_AVATAR_LOOKS`) from `.env` and HeyGen API key (`HEYGEN_API_KEY`) for the upload step. USE WHEN user says "tạo video heygen từ mp3", "mp3 to heygen", "heygen mp4 từ audio", "convert mp3 sang heygen video", "tạo avatar video từ file mp3", "lip sync mp3 heygen", "biến mp3 thành video heygen", or any time the user has exactly one MP3 file and wants exactly one HeyGen avatar MP4 out.

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Demand-side market research cho digital product / service ở Việt Nam — đo cầu thật + WTP + channel-market fit + defensibility qua keyword volume, marketplace sales (Shopee/Unica/Edumall/Gitiho/KyNa), community signal (FB groups, TikTok hashtag, Zalo OA), competitor pricing, unit economics — không phải macro PESTEL. Output: keyword portfolio + Niche Score 100 điểm 7-dimension có evidence + go/no-go decision + falsification protocol. Force triangulate ≥3 sources cho mỗi claim quan trọng. USE WHEN user says 'nghiên cứu thị trường', 'market research', 'validate niche', 'keyword research', 'demand validation', 'niche có nên làm không', 'có ai làm chưa', 'thị trường đủ lớn không', 'có lời không', 'chọn ngách', 'kiểm tra cầu'. Cũng trigger khi user mô tả 1 ý tưởng kinh doanh cụ thể và muốn check feasibility. Skill này KHÔNG fit: high-ticket transactional sale (BĐS, ô tô), B2B enterprise (sales cycle 6+ tháng), hyper-local geo micro-market (1 toà nhà, 1 phường). KHÔNG làm: macro PESTEL/Porter

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Transcribe an MP3 voiceover into an SRT subtitle file and a word-level segments JSON using local OpenAI Whisper. Input is a single MP3 path; output is `<stem>.srt` + `<stem>_segments.json` written next to the MP3 (or to a custom output dir). USE WHEN the user says 'extract srt from mp3', 'trích srt từ mp3', 'transcribe voiceover', 'tạo file srt và segments', 'whisper transcribe', 'bóc transcript có timestamp', 'extract voiceover segments', 'tách SRT từ audio', or any time a downstream skill (plan-short-video-edit, heygen-remotion-short-video-editor) needs an SRT + word-level segments JSON from a voiceover MP3 and one does not already exist.

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Convert Vietnamese/English script text to MP3 voiceover using ElevenLabs TTS API. Calls POST /v1/text-to-speech/{voice_id}, streams audio bytes, writes MP3 directly. Locked to Hoang's brand voice ID by default. USE WHEN user says 'tạo mp3 elevenlabs', 'elevenlabs tts', 'eleven labs voice', 'text to speech elevenlabs', 'tạo voiceover elevenlabs', 'đọc text bằng elevenlabs', 'tts elevenlabs to mp3', 'eleven labs script to mp3', 'voiceover bằng elevenlabs', 'giọng elevenlabs'.

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

End-to-end LANDSCAPE 16:9 (1920×1080) talking-head + slide knowledge video pipeline. Orchestrator 3 phase ghép `mkt-elevenlabs-tts-to-mp3` + `heygen-mp3-to-mp4` + HyperFrames để ra MP4 dạng "podcast keynote" — HeyGen avatar trong floating frame bo tròn bên phải (claude-orange border), slide modern AI / Claude editorial bên trái, có PIP zoom-out moments (slide full-screen, avatar shrink xuống corner thumbnail), breathing zoom + beat-driven punch-in trên avatar, optional cream-paper hand-drawn editorial infographic ở root layer (KHÔNG embed trong composition). Phase 3 fan-out N parallel LLM sub-agents (1 per scene) để author composition HTML từ visual-plan.json — không dùng Python template generator. Hỗ trợ listicle 6+ scenes (tip-1..tip-N) với scene-{num}.html naming. Resume mode: nếu MP3 + source.mp4 đã tồn tại thì skip Phase 1 + 2, vào thẳng Phase 3. USE WHEN user nói "tạo video 16:9", "video ngang", "video landscape", "podcast keynote video", "talking head + slide video", "slide + av

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

End-to-end short-video pipeline — từ kịch bản (Việt/Anh) ra MP4 TikTok/Reels 9:16 hoàn chỉnh. Orchestrator 3 phase ghép skill có sẵn — (1) TTS provider chọn được giữa `mkt-elevenlabs-tts-to-mp3` (default, voice của Hoàng) hoặc `mkt-video-script-to-mp3` (MiniMax speech-2.8-hd), (2) checkpoint user duyệt MP3, (3) `heygen-mp3-to-mp4` lip-sync avatar HeyGen, (4) delegate Phase 3 packaging cho sub-agent `mkt-full-video-phase3-packager` (transcribe + scene outline + checkpoint + fan-out N scene writers parallel + scaffold + preview Studio). API key + voice ID cho cả 2 provider lưu ở `.env`. USE WHEN user nói "tạo full video từ script", "script to tiktok video", "pipeline full video heygen + hyperframe", "tạo video từ kịch bản đến mp4", "elevenlabs heygen hyperframe full pipeline", "minimax heygen pipeline", "kịch bản ra video tiktok", hoặc có sẵn 1 script + (optional) ảnh b-roll và muốn ra MP4 9:16 đóng gói có captions, SFX, b-roll.

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Build a TikTok/Reels/YouTube **landscape 16:9 (1920×1080)** short video from a pre-recorded talking-head MP4 using HyperFrames — transcribe Vietnamese audio, scaffold a complete preview-ready 1920×1080 project with a slide pane (1200px) on the left and a floating avatar frame on the right, GSAP timeline có SPLIT↔PIP transitions (slide full-screen + avatar PIP corner thumbnail), breathing yoyo zoom + beat-driven punch-in trên avatar, 5 scene compositions kiểu "tier-row" pattern (post-stack hook / chats-stack problem / hero-orb solution / counter-row recap / terminal-row CTA), optional cream-paper editorial infographic image slots với `<img onerror>` fallback, 6 SFX wired tại scene boundaries, **NO captions** (giọng avatar là spine). USE WHEN user nói "edit video 16:9 từ HeyGen MP4", "scaffold project landscape", "podcast keynote editor", "talking head + slide editor", "build hyperframes 1920×1080", "tạo project 16:9 từ avatar mp4", "scaffold 16:9 hyperframes", "hyperframe landscape vide

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Build a TikTok/Reels 9:16 short video from a pre-recorded talking-head MP4 using HyperFrames — transcribe Vietnamese audio, auto-clean Whisper errors, generate synced caption groups, scaffold a complete preview-ready project with face-cam + 6 sound effects + 4 zoom hooks + ambient ken-burns drifts + full-screen b-roll scenes (each with rich GSAP effects: pulse rings, corner marks, word-slam titles, count-up numbers, light sweeps, scribble underlines, sparkles, particles) + caption track + CTA finale, then open the HyperFrames preview Studio for user review (NEVER auto-render MP4). USE WHEN user says "tạo video tiktok từ footage", "build hyperframe talking head", "tạo 9:16 video từ mp4 quay sẵn", "make tiktok video from face footage", "hyperframe video từ video quay", "tạo short video có caption + b-roll", "video chia sẻ kiến thức từ footage", "đóng gói video ngắn", or provides a 9:16 talking-head MP4 (with optional b-roll images/videos and stated purposes) asking to turn it into a fini

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Audit bài Facebook / Reels / YouTube để phát hiện 4 downward drivers (over-branding, over-production, stock imagery, standardized aesthetic) + frequency-over-quality. Mỗi anti-pattern bị drop ~75% performance nếu hiện diện. USE WHEN user says 'audit content', 'check anti pattern', 'content có lỗi gì không', 'kiểm tra over branding', 'vì sao video bị chết', 'vì sao post không ai xem', 'content audit', 'kiểm tra chất lượng content'.

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Tìm viral pattern ở ngành khác (bác sĩ, luật sư, tài chính, bất động sản, thủ công) có thể apply cho niche AI/automation của Hoang. Ngách AI educator VN còn ít format được khai thác — cross-industry adaptation là blue ocean. USE WHEN user says 'tìm format ngành khác', 'cross industry research', 'học format từ ngành khác', 'blue ocean format', 'tìm format chưa ai làm', 'adapt format từ niche khác', 'cross industry viral'.

lexuanthanhhy/MKT.LANDINGPAGE.SKILLS

Rewrite CTA kiểu autocratic (Mua ngay! Follow ngay! Đăng ký liền!) sang 3 variants Democratic / Benevolent / Laissez-faire — reach 85% dân số thay vì chỉ 5% (action-based). Áp dụng cho landing page, caption FB, CTA video, email. USE WHEN user says 'rewrite cta', 'sửa cta', 'cta không autocratic', 'viết lại kêu gọi hành động', 'cta cho landing page', 'cta nhẹ nhàng hơn', 'inclusive cta', 'cta democratic benevolent'.

Skills associés