Nhúng vào trang của bạn
Bốn cách nối site sẵn có vào bộ máy này. Không cần dựng lại gì — mỗi phần là một đoạn mã dán vào.
1. Franki — cố vấn ảo (một thẻ script)
Dán vào ngay trước thẻ đóng </body>. Đổi data-source thành tên site của bạn để biết lượt đăng ký đến từ đâu. Khung chat nằm trong iframe nên không ảnh hưởng giao diện trang chủ nhà.
<script src="https://franchise-growth-engine.vercel.app/franki.js" data-source="your-site" defer></script>Chế độ gia sư (dùng trong khoá học)
Cùng một thẻ script, thêm hai thuộc tính. Franki sẽ chỉ trả lời trong phạm vi khoá học đó.
<script src="https://franchise-growth-engine.vercel.app/franki.js"
data-source="learning-hub"
data-mode="tutor"
data-course="Nhượng quyền căn bản"
defer></script>2. Trang chẩn đoán — gửi kết quả, chuyển sang báo cáo
Gọi sau khi người dùng làm xong bài, rồi chuyển họ tới report_url trả về. Điểm được lưu ẩn danh; email chỉ được lưu khi có ô đồng ý được tick.
// On diagnostic completion — send the result, then send the user to the report.
const res = await fetch("https://franchise-growth-engine.vercel.app/api/diagnostic/submit", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
diagnostic_type: "franchisor", // 'franchise_readiness' | 'franchisor' | 'franchisee'
score: 63, // 0-100
band: "Ready", // optional; derived from score if omitted
subscores: { concept: 78, finance: 45, ops: 52 },
market: "Vietnam", // country/region only — never an address
sector: "F&B",
persona: "franchisor", // brand_owner | franchisor | franchisee | investor
source: "franchisor-readiness", // which site this came from
locale: "vi",
// Optional, and ONLY with an explicit consent tick:
// email: "...", name: "...", consent: true,
}),
});
const { report_url } = await res.json();
window.location.href = report_url;3. Thẻ số liệu Chỉ số (cho FranPulse và bài viết)
Thẻ luôn hiện cỡ mẫu N cùng con số, và tự cập nhật khi dữ liệu đổi. dim nhận: overall, market, sector, persona.
<iframe src="https://franchise-growth-engine.vercel.app/embed/stat?dim=market"
width="100%" height="180" style="border:0"
loading="lazy" title="Asia Franchise Readiness Index"></iframe>Hoặc lấy số thô qua JSON
curl -s https://franchise-growth-engine.vercel.app/api/index.json4. Chứng chỉ hoàn thành có xác thực
Trả về mã, liên kết xác thực công khai và ảnh PNG của chứng chỉ.
// Issue a verifiable completion certificate.
const res = await fetch("https://franchise-growth-engine.vercel.app/api/certificate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
recipient_name: "Nguyễn Văn A",
course_title: "Nhượng quyền căn bản cho chủ thương hiệu",
course_slug: "franchise-basics",
locale: "vi",
}),
});
const { code, verify_url, image_url } = await res.json();5. "Vì sao hợp" cho FranchiseMatch
Không cần dựng thêm gì: Franki vốn là một điểm gọi hội thoại, nên chỉ cần đưa cặp hồ sơ–thương hiệu vào làm câu hỏi rồi hiển thị câu trả lời. Trả về kèm đúng một bước đi tiếp, hoặc null nếu không có gì thật sự hợp.
// "Why this match" — FranchiseMatch, powered by Franki's engine.
// Franki is a chat endpoint, so you pass the match as a question and render
// the answer. There is nothing new to build server-side.
const res = await fetch("https://franchise-growth-engine.vercel.app/api/franki", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
source: "franchisematch",
locale: lang, // 'vi' | 'en' — or omit to auto-detect
messages: [{
role: "user",
content:
"Explain in 2-3 sentences why this franchise brand fits this investor.\n" +
"Investor: capital " + profile.capital + ", experience " + profile.experience +
", sector preference " + profile.sector + ", city " + profile.city + ".\n" +
"Brand: " + brand.name + ", sector " + brand.sector +
", investment from " + brand.minInvestment + ".\n" +
"Name one thing they should check before committing.",
}],
}),
});
const { answer, tool } = await res.json();
// answer -> the explanation. tool -> the single best next step, or null.
// Capture works the same as anywhere else: POST /api/lead with consent: true.Ràng buộc bắt buộc khi nối vào
- Không bao giờ gửi email khi người dùng chưa tick đồng ý. Endpoint sẽ từ chối nếu thiếu consent.
- Trường market chỉ nhận quốc gia hoặc khu vực. Không gửi địa chỉ, không gửi số điện thoại.
- Điểm chẩn đoán và email được lưu ở hai bảng tách biệt, không nối với nhau.
- Luôn kiểm res.ok trước khi coi là thành công — fetch không tự báo lỗi khi máy chủ trả 4xx hay 5xx.