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
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Trình Tạo Nội Dung Marketing AI</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script>
|
| 9 |
+
tailwind.config = {
|
| 10 |
+
theme: {
|
| 11 |
+
extend: {
|
| 12 |
+
colors: {
|
| 13 |
+
primary: '#1E3A8A',
|
| 14 |
+
secondary: '#60A5FA',
|
| 15 |
+
accent: '#F59E0B'
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
</script>
|
| 21 |
+
</head>
|
| 22 |
+
<body class="bg-gray-50 min-h-screen flex flex-col items-center justify-center p-4 font-sans">
|
| 23 |
+
<div class="bg-white p-8 rounded-xl shadow-2xl w-full max-w-3xl transform transition-all duration-300">
|
| 24 |
+
<h1 class="text-3xl font-bold mb-6 text-center text-primary">Trình Tạo Nội Dung Marketing AI</h1>
|
| 25 |
+
|
| 26 |
+
<!-- User Requirements Form -->
|
| 27 |
+
<div class="mb-8">
|
| 28 |
+
<h2 class="text-xl font-semibold mb-4 text-primary">Yêu Cầu Nội Dung</h2>
|
| 29 |
+
<div class="space-y-6">
|
| 30 |
+
<div class="relative group">
|
| 31 |
+
<label for="contentType" class="block text-sm font-medium text-gray-700">Loại Nội Dung</label>
|
| 32 |
+
<select id="contentType" class="mt-1 block w-full p-3 border border-gray-300 rounded-lg focus:ring-secondary focus:border-secondary transition duration-200">
|
| 33 |
+
<option value="social_media_post">Bài Đăng Mạng Xã Hội</option>
|
| 34 |
+
<option value="email_campaign">Chiến Dịch Email</option>
|
| 35 |
+
<option value="blog_post">Bài Viết Blog</option>
|
| 36 |
+
<option value="ad_copy">Quảng Cáo</option>
|
| 37 |
+
</select>
|
| 38 |
+
<span class="absolute hidden group-hover:block text-xs text-gray-500 mt-1">Chọn loại nội dung bạn muốn tạo</span>
|
| 39 |
+
</div>
|
| 40 |
+
<div class="relative group">
|
| 41 |
+
<label for="targetAudience" class="block text-sm font-medium text-gray-700">Đối Tượng Mục Tiêu</label>
|
| 42 |
+
<input id="targetAudience" type="text" class="mt-1 block w-full p-3 border border-gray-300 rounded-lg focus:ring-secondary focus:border-secondary transition duration-200" placeholder="Ví dụ: Người trẻ, 25-35 tuổi, thành thị">
|
| 43 |
+
<span class="absolute hidden group-hover:block text-xs text-gray-500 mt-1">Mô tả đối tượng mục tiêu của chiến dịch</span>
|
| 44 |
+
</div>
|
| 45 |
+
<div class="relative group">
|
| 46 |
+
<label for="tone" class="block text-sm font-medium text-gray-700">Phong Cách</label>
|
| 47 |
+
<select id="tone" class="mt-1 block w-full p-3 border border-gray-300 rounded-lg focus:ring-secondary focus:border-secondary transition duration-200">
|
| 48 |
+
<option value="professional">Chuyên Nghiệp</option>
|
| 49 |
+
<option value="casual">Thân Thiện</option>
|
| 50 |
+
<option value="humorous">Hài Hước</option>
|
| 51 |
+
<option value="inspirational">Truyền Cảm Hứng</option>
|
| 52 |
+
</select>
|
| 53 |
+
<span class="absolute hidden group-hover:block text-xs text-gray-500 mt-1">Chọn phong cách phù hợp với nội dung</span>
|
| 54 |
+
</div>
|
| 55 |
+
<div class="relative group">
|
| 56 |
+
<label for="campaignGoal" class="block text-sm font-medium text-gray-700">Mục Tiêu Chiến Dịch</label>
|
| 57 |
+
<input id="campaignGoal" type="text" class="mt-1 block w-full p-3 border border-gray-300 rounded-lg focus:ring-secondary focus:border-secondary transition duration-200" placeholder="Ví dụ: Tăng nhận diện thương hiệu">
|
| 58 |
+
<span class="absolute hidden group-hover:block text-xs text-gray-500 mt-1">Xác định mục tiêu chính của nội dung</span>
|
| 59 |
+
</div>
|
| 60 |
+
<div class="relative group">
|
| 61 |
+
<label for="contentLength" class="block text-sm font-medium text-gray-700">Độ Dài Nội Dung</label>
|
| 62 |
+
<select id="contentLength" class="mt-1 block w-full p-3 border border-gray-300 rounded-lg focus:ring-secondary focus:border-secondary transition duration-200">
|
| 63 |
+
<option value="short">Ngắn (50-100 từ)</option>
|
| 64 |
+
<option value="medium">Trung Bình (100-200 từ)</option>
|
| 65 |
+
<option value="long">Dài (200-500 từ)</option>
|
| 66 |
+
</select>
|
| 67 |
+
<span class="absolute hidden group-hover:block text-xs text-gray-500 mt-1">Chọn độ dài mong muốn cho nội dung</span>
|
| 68 |
+
</div>
|
| 69 |
+
</div>
|
| 70 |
+
</div>
|
| 71 |
+
|
| 72 |
+
<!-- Brand Knowledge Form (Collapsible) -->
|
| 73 |
+
<div class="mb-8">
|
| 74 |
+
<button id="toggleBrand" class="w-full flex justify-between items-center text-lg font-semibold mb-4 text-primary hover:text-secondary transition duration-200">
|
| 75 |
+
Thông Tin Thương Hiệu
|
| 76 |
+
<svg id="toggleIcon" class="w-5 h-5 transform transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 77 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
|
| 78 |
+
</svg>
|
| 79 |
+
</button>
|
| 80 |
+
<div id="brandSection" class="space-y-6 hidden">
|
| 81 |
+
<div class="relative group">
|
| 82 |
+
<label for="brandName" class="block text-sm font-medium text-gray-700">Tên Thương Hiệu</label>
|
| 83 |
+
<input id="brandName" type="text" class="mt-1 block w-full p-3 border border-gray-300 rounded-lg focus:ring-secondary focus:border-secondary transition duration-200" placeholder="Ví dụ: Sáng Tạo EcoTrend">
|
| 84 |
+
<span class="absolute hidden group-hover:block text-xs text-gray-500 mt-1">Nhập tên thương hiệu của bạn</span>
|
| 85 |
+
</div>
|
| 86 |
+
<div class="relative group">
|
| 87 |
+
<label for="brandVoice" class="block text-sm font-medium text-gray-700">Giọng Điệu Thương Hiệu</label>
|
| 88 |
+
<input id="brandVoice" type="text" class="mt-1 block w-full p-3 border border-gray-300 rounded-lg focus:ring-secondary focus:border-secondary transition duration-200" placeholder="Ví dụ: Thân thiện môi trường, sáng tạo, gần gũi">
|
| 89 |
+
<span class="absolute hidden group-hover:block text-xs text-gray-500 mt-1">Mô tả giọng điệu đặc trưng của thương hiệu</span>
|
| 90 |
+
</div>
|
| 91 |
+
<div class="relative group">
|
| 92 |
+
<label for="keyMessages" class="block text-sm font-medium text-gray-700">Thông Điệp Chính</label>
|
| 93 |
+
<textarea id="keyMessages" class="mt-1 block w-full p-3 border border-gray-300 rounded-lg focus:ring-secondary focus:border-secondary transition duration-200" rows="4" placeholder="Ví dụ: Sống bền vững, công nghệ tiên tiến, lấy khách hàng làm trung tâm"></textarea>
|
| 94 |
+
<span class="absolute hidden group-hover:block text-xs text-gray-500 mt-1">Liệt kê các thông điệp cốt lõi của thương hiệu</span>
|
| 95 |
+
</div>
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
|
| 99 |
+
<!-- Action Buttons -->
|
| 100 |
+
<div class="flex space-x-4">
|
| 101 |
+
<button id="generateButton" class="flex-1 bg-primary text-white p-3 rounded-lg hover:bg-secondary transition duration-200 flex items-center justify-center">
|
| 102 |
+
<span id="generateText">Tạo Nội Dung</span>
|
| 103 |
+
<svg id="loadingSpinner" class="hidden animate-spin h-5 w-5 ml-2 text-white" fill="none" viewBox="0 0 24 24">
|
| 104 |
+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
| 105 |
+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z "></path>
|
| 106 |
+
</svg>
|
| 107 |
+
</button>
|
| 108 |
+
<button id="clearButton" class="flex-1 bg-gray-300 text-gray-700 p-3 rounded-lg hover:bg-gray-400 transition duration-200">Xóa Form</button>
|
| 109 |
+
</div>
|
| 110 |
+
|
| 111 |
+
<!-- Output Section -->
|
| 112 |
+
<div id="output" class="mt-8 hidden">
|
| 113 |
+
<div class="flex justify-between items-center">
|
| 114 |
+
<h2 class="text-xl font-semibold text-primary">Nội Dung Được Tạo</h2>
|
| 115 |
+
<button id="copyButton" class="text-sm text-secondary hover:text-accent transition duration-200">Sao Chép</button>
|
| 116 |
+
</div>
|
| 117 |
+
<div id="contentOutput" class="mt-4 p-4 bg-gray-100 border border-gray-200 rounded-lg whitespace-pre-wrap"></div>
|
| 118 |
+
<div class="mt-4">
|
| 119 |
+
<label for="refineRequest" class="block text-sm font-medium text-gray-700">Yêu Cầu Tinh Chỉnh</label>
|
| 120 |
+
<select id="refineRequest" class="mt-1 block w-full p-3 border border-gray-300 rounded-lg focus:ring-secondary focus:border-secondary transition duration-200">
|
| 121 |
+
<option value="">Không tinh chỉnh</option>
|
| 122 |
+
<option value="more_creative">Sáng tạo hơn</option>
|
| 123 |
+
<option value="more_concise">Ngắn gọn hơn</option>
|
| 124 |
+
<option value="more_persuasive">Thuyết phục hơn</option>
|
| 125 |
+
<option value="more_emotional">Cảm xúc hơn</option>
|
| 126 |
+
</select>
|
| 127 |
+
<button id="refineButton" class="mt-2 w-full bg-accent text-white p-3 rounded-lg hover:bg-yellow-600 transition duration-200 flex items-center justify-center">
|
| 128 |
+
<span id="refineText">Tinh Chỉnh Nội Dung</span>
|
| 129 |
+
<svg id="refineSpinner" class="hidden animate-spin h-5 w-5 ml-2 text-white" fill="none" viewBox="0 0 24 24">
|
| 130 |
+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
| 131 |
+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
| 132 |
+
</svg>
|
| 133 |
+
</button>
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
|
| 138 |
+
<script>
|
| 139 |
+
let currentContent = '';
|
| 140 |
+
|
| 141 |
+
// Toggle Brand Section
|
| 142 |
+
const toggleButton = document.getElementById('toggleBrand');
|
| 143 |
+
const brandSection = document.getElementById('brandSection');
|
| 144 |
+
const toggleIcon = document.getElementById('toggleIcon');
|
| 145 |
+
toggleButton.addEventListener('click', () => {
|
| 146 |
+
brandSection.classList.toggle('hidden');
|
| 147 |
+
toggleIcon.classList.toggle('rotate-180');
|
| 148 |
+
});
|
| 149 |
+
|
| 150 |
+
// Clear Form
|
| 151 |
+
document.getElementById('clearButton').addEventListener('click', () => {
|
| 152 |
+
document.getElementById('contentType').value = 'social_media_post';
|
| 153 |
+
document.getElementById('targetAudience').value = '';
|
| 154 |
+
document.getElementById('tone').value = 'professional';
|
| 155 |
+
document.getElementById('campaignGoal').value = '';
|
| 156 |
+
document.getElementById('contentLength').value = 'medium';
|
| 157 |
+
document.getElementById('brandName').value = '';
|
| 158 |
+
document.getElementById('brandVoice').value = '';
|
| 159 |
+
document.getElementById('keyMessages').value = '';
|
| 160 |
+
document.getElementById('refineRequest').value = '';
|
| 161 |
+
document.getElementById('output').classList.add('hidden');
|
| 162 |
+
currentContent = '';
|
| 163 |
+
});
|
| 164 |
+
|
| 165 |
+
// Generate Content
|
| 166 |
+
document.getElementById('generateButton').addEventListener('click', async () => {
|
| 167 |
+
const contentType = document.getElementById('contentType').value;
|
| 168 |
+
const targetAudience = document.getElementById('targetAudience').value;
|
| 169 |
+
const tone = document.getElementById('tone').value;
|
| 170 |
+
const campaignGoal = document.getElementById('campaignGoal').value;
|
| 171 |
+
const contentLength = document.getElementById('contentLength').value;
|
| 172 |
+
const brandName = document.getElementById('brandName').value;
|
| 173 |
+
const brandVoice = document.getElementById('brandVoice').value;
|
| 174 |
+
const keyMessages = document.getElementById('keyMessages').value;
|
| 175 |
+
|
| 176 |
+
if (!contentType || !targetAudience || !tone || !campaignGoal || !contentLength || !brandName || !brandVoice || !keyMessages) {
|
| 177 |
+
alert('Vui lòng điền đầy đủ tất cả các trường.');
|
| 178 |
+
return;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
const lengthConstraints = {
|
| 182 |
+
short: '50-100 từ',
|
| 183 |
+
medium: '100-200 từ',
|
| 184 |
+
long: '200-500 từ'
|
| 185 |
+
};
|
| 186 |
+
|
| 187 |
+
const contentTypeDescriptions = {
|
| 188 |
+
social_media_post: 'Bài đăng mạng xã hội ngắn gọn, thu hút, phù hợp với nền tảng như Facebook, Instagram hoặc LinkedIn.',
|
| 189 |
+
email_campaign: 'Email marketing chuyên nghiệp, có lời kêu gọi hành động rõ ràng.',
|
| 190 |
+
blog_post: 'Bài viết blog chi tiết, cung cấp giá trị thông tin và phù hợp với SEO.',
|
| 191 |
+
ad_copy: 'Quảng cáo ngắn gọn, thuyết phục, tập trung vào việc thúc đẩy hành động.'
|
| 192 |
+
};
|
| 193 |
+
|
| 194 |
+
const prompt = `
|
| 195 |
+
Bạn là một chuyên gia sáng tạo nội dung marketing. Tạo một ${contentType.replace('_', ' ')} cho thương hiệu "${brandName}" với các yêu cầu sau:
|
| 196 |
+
- **Đối tượng mục tiêu**: ${targetAudience}.
|
| 197 |
+
- **Phong cách**: ${tone} (đảm bảo giọng điệu nhất quán và phù hợp).
|
| 198 |
+
- **Mục tiêu chiến dịch**: ${campaignGoal}.
|
| 199 |
+
- **Giọng điệu thương hiệu**: ${brandVoice}.
|
| 200 |
+
- **Thông điệp chính**: ${keyMessages}.
|
| 201 |
+
- **Độ dài**: ${lengthConstraints[contentLength]}.
|
| 202 |
+
- **Mô tả loại nội dung**: ${contentTypeDescriptions[contentType]}.
|
| 203 |
+
- **Yêu cầu bổ sung**:
|
| 204 |
+
- Nội dung phải sáng tạo, thu hút, và phù hợp với bản sắc thương hiệu.
|
| 205 |
+
- Sử dụng ngôn ngữ tự nhiên, gần gũi với người dùng Việt Nam.
|
| 206 |
+
- Tránh lặp lại từ ngữ hoặc ý tưởng một cách không cần thiết.
|
| 207 |
+
- Nếu là bài đăng mạng xã hội hoặc quảng cáo, hãy thêm lời kêu gọi hành động mạnh mẽ.
|
| 208 |
+
- Đảm bảo nội dung đúng ngữ pháp và không có lỗi chính tả.
|
| 209 |
+
- **Ví dụ** (nếu phù hợp):
|
| 210 |
+
- Bài đăng mạng xã hội: "Khám phá bộ sưu tập mới từ [Thương hiệu]! 🌟 Sản phẩm bền vững, thời thượng, dành riêng cho bạn. Mua ngay hôm nay!"
|
| 211 |
+
- Email: "Kính gửi [Khách hàng], chúng tôi mang đến ưu đãi đặc biệt dành cho bạn! Nhấn vào đây để nhận ngay 20% giảm giá."
|
| 212 |
+
Tạo nội dung bằng tiếng Việt, đảm bảo chất lượng cao và phù hợp với các yêu cầu trên.
|
| 213 |
+
`;
|
| 214 |
+
|
| 215 |
+
const generateButton = document.getElementById('generateButton');
|
| 216 |
+
const generateText = document.getElementById('generateText');
|
| 217 |
+
const loadingSpinner = document.getElementById('loadingSpinner');
|
| 218 |
+
generateButton.disabled = true;
|
| 219 |
+
generateText.textContent = 'Đang tạo...';
|
| 220 |
+
loadingSpinner.classList.remove('hidden');
|
| 221 |
+
|
| 222 |
+
try {
|
| 223 |
+
const response = await fetch('/api/generate', {
|
| 224 |
+
method: 'POST',
|
| 225 |
+
headers: { 'Content-Type': 'application/json' },
|
| 226 |
+
body: JSON.stringify({ prompt })
|
| 227 |
+
});
|
| 228 |
+
|
| 229 |
+
const data = await response.json();
|
| 230 |
+
const outputDiv = document.getElementById('output');
|
| 231 |
+
const contentOutput = document.getElementById('contentOutput');
|
| 232 |
+
|
| 233 |
+
if (data.content) {
|
| 234 |
+
currentContent = data.content;
|
| 235 |
+
contentOutput.textContent = currentContent;
|
| 236 |
+
outputDiv.classList.remove('hidden');
|
| 237 |
+
} else {
|
| 238 |
+
contentOutput.textContent = 'Lỗi khi tạo nội dung. Vui lòng thử lại.';
|
| 239 |
+
outputDiv.classList.remove('hidden');
|
| 240 |
+
}
|
| 241 |
+
} catch (error) {
|
| 242 |
+
console.error('Lỗi:', error);
|
| 243 |
+
document.getElementById('contentOutput').textContent = 'Lỗi kết nối với máy chủ.';
|
| 244 |
+
document.getElementById('output').classList.remove('hidden');
|
| 245 |
+
} finally {
|
| 246 |
+
generateButton.disabled = false;
|
| 247 |
+
generateText.textContent = 'Tạo Nội Dung';
|
| 248 |
+
loadingSpinner.classList.add('hidden');
|
| 249 |
+
}
|
| 250 |
+
});
|
| 251 |
+
|
| 252 |
+
// Refine Content
|
| 253 |
+
document.getElementById('refineButton').addEventListener('click', async () => {
|
| 254 |
+
const refineRequest = document.getElementById('refineRequest').value;
|
| 255 |
+
if (!currentContent || !refineRequest) {
|
| 256 |
+
alert('Vui lòng tạo nội dung trước và chọn yêu cầu tinh chỉnh.');
|
| 257 |
+
return;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
const refinePrompt = `
|
| 261 |
+
Dưới đây là nội dung marketing đã được tạo:
|
| 262 |
+
"${currentContent}"
|
| 263 |
+
|
| 264 |
+
Vui lòng tinh chỉnh nội dung trên theo yêu cầu sau: ${refineRequest.replace('_', ' ')}.
|
| 265 |
+
- Giữ nguyên bản sắc thương hiệu, đối tượng mục tiêu, và mục tiêu chiến dịch.
|
| 266 |
+
- Đảm bảo nội dung vẫn bằng tiếng Việt, đúng ngữ pháp, và thu hút.
|
| 267 |
+
- Nếu yêu cầu là "ngắn gọn hơn", giảm độ dài nhưng giữ thông điệp cốt lõi.
|
| 268 |
+
- Nếu yêu cầu là "sáng tạo hơn", thêm yếu tố độc đáo hoặc cách diễn đạt mới mẻ.
|
| 269 |
+
- Nếu yêu cầu là "thuyết phục hơn", tăng cường lời kêu gọi hành động hoặc lập luận mạnh mẽ.
|
| 270 |
+
- Nếu yêu cầu là "cảm xúc hơn", thêm yếu tố cảm xúc để kết nối với người đọc.
|
| 271 |
+
`;
|
| 272 |
+
|
| 273 |
+
const refineButton = document.getElementById('refineButton');
|
| 274 |
+
const refineText = document.getElementById('refineText');
|
| 275 |
+
const refineSpinner = document.getElementById('refineSpinner');
|
| 276 |
+
refineButton.disabled = true;
|
| 277 |
+
refineText.textContent = 'Đang tinh chỉnh...';
|
| 278 |
+
refineSpinner.classList.remove('hidden');
|
| 279 |
+
|
| 280 |
+
try {
|
| 281 |
+
const response = await fetch('/api/generate', {
|
| 282 |
+
method: 'POST',
|
| 283 |
+
headers: { 'Content-Type': 'application/json' },
|
| 284 |
+
body: JSON.stringify({ prompt: refinePrompt })
|
| 285 |
+
});
|
| 286 |
+
|
| 287 |
+
const data = await response.json();
|
| 288 |
+
const contentOutput = document.getElementById('contentOutput');
|
| 289 |
+
|
| 290 |
+
if (data.content) {
|
| 291 |
+
currentContent = data.content;
|
| 292 |
+
contentOutput.textContent = currentContent;
|
| 293 |
+
} else {
|
| 294 |
+
contentOutput.textContent = 'Lỗi khi tinh chỉnh nội dung. Vui lòng thử lại.';
|
| 295 |
+
}
|
| 296 |
+
} catch (error) {
|
| 297 |
+
console.error('Lỗi:', error);
|
| 298 |
+
document.getElementById('contentOutput').textContent = 'Lỗi kết nối với máy chủ.';
|
| 299 |
+
} finally {
|
| 300 |
+
refineButton.disabled = false;
|
| 301 |
+
refineText.textContent = 'Tinh Chỉnh Nội Dung';
|
| 302 |
+
refineSpinner.classList.add('hidden');
|
| 303 |
+
}
|
| 304 |
+
});
|
| 305 |
+
|
| 306 |
+
// Copy to Clipboard
|
| 307 |
+
document.getElementById('copyButton').addEventListener('click', () => {
|
| 308 |
+
const content = document.getElementById('contentOutput').textContent;
|
| 309 |
+
navigator.clipboard.writeText(content).then(() => {
|
| 310 |
+
const copyButton = document.getElementById('copyButton');
|
| 311 |
+
copyButton.textContent = 'Đã Sao Chép!';
|
| 312 |
+
setTimeout(() => { copyButton.textContent = 'Sao Chép'; }, 2000);
|
| 313 |
+
});
|
| 314 |
+
});
|
| 315 |
+
</script>
|
| 316 |
+
</body>
|
| 317 |
+
</html>
|