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