<meta name="google-site-verification" content="RYhL-TbvQz3cCC6131XbJJ6QMUeZ5-JHqKVjm3kSCdE" /> <script>(function() { var _fbq = window._fbq || (window._fbq = []); if (!_fbq.loaded) { var fbds = document.createElement('script'); fbds.async = true; fbds.src = '//connect.facebook.net/en_US/fbds.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(fbds, s); _fbq.loaded = true; } _fbq.push(['addPixelId', '705329632846177']); })(); window._fbq = window._fbq || []; window._fbq.push(['track', 'PixelInitialized', {}]); </script> <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?id=705329632846177&ev=PixelInitialized" /></noscript>
<meta name="google-site-verification" content="RYhL-TbvQz3cCC6131XbJJ6QMUeZ5-JHqKVjm3kSCdE" /> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-17161026-1', 'trituemedia.vn'); ga('send', 'pageview'); </script> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-HR6Q15J5MD"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-HR6Q15J5MD'); </script> <style> #hungai-widget-root{display:none;position:fixed;bottom:25px;right:25px;z-index:99999999;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;}#hungai-floating-btn{width:66px;height:66px;border-radius:50%;background:#0A0F1D;border:2.5px solid #F59E0B;box-shadow:0 8px 24px rgba(0,0,0,0.5),0 0 18px rgba(245,158,11,0.6);cursor:pointer;position:relative;transition:transform 0.25s ease,box-shadow 0.25s ease;display:flex;align-items:center;justify-content:center;}#hungai-floating-btn:hover{transform:scale(1.08);box-shadow:0 10px 30px rgba(0,0,0,0.6),0 0 28px rgba(245,158,11,0.9);}#hungai-floating-btn img{width:100%;height:100%;border-radius:50%;object-fit:cover;}.hungai-live-badge{position:absolute;bottom:-2px;right:-2px;background:#10B981;color:#FFFFFF;font-size:9px;font-weight:800;padding:2px 6px;border-radius:10px;border:1.5px solid #0A0F1D;display:flex;align-items:center;gap:3px;}.hungai-live-dot{width:5px;height:5px;background:#FFFFFF;border-radius:50%;animation:hungaiPulse 1s infinite alternate;}@keyframes hungaiPulse{0%{opacity:0.3;}100%{opacity:1;}}#hungai-chat-box{position:absolute;bottom:0;right:0;width:380px;height:630px;max-width:calc(100vw - 30px);max-height:calc(100vh - 40px);background:#0B111E;border:1.5px solid rgba(245,158,11,0.45);border-radius:20px;box-shadow:0 16px 50px rgba(0,0,0,0.8),0 0 30px rgba(245,158,11,0.3);display:none;flex-direction:column;overflow:hidden;animation:hungaiSlideIn 0.35s cubic-bezier(0.16,1,0.3,1);}@keyframes hungaiSlideIn{from{opacity:0;transform:translateY(20px) scale(0.96);}to{opacity:1;transform:translateY(0) scale(1);}}.hungai-chat-header{background:linear-gradient(135deg,#101726 0%,#1A263D 100%);border-bottom:1px solid rgba(245,158,11,0.3);padding:10px 14px;display:flex;align-items:center;gap:10px;flex-shrink:0;}.hungai-header-meta{flex:1;overflow:hidden;}.hungai-header-meta h4{color:#F8FAFC;font-size:14px;font-weight:700;margin:0;display:flex;align-items:center;gap:6px;}.hungai-header-meta p{color:#94A3B8;font-size:11px;margin:1px 0 0 0;}.hungai-header-btns{display:flex;gap:6px;align-items:center;}.hungai-head-btn{background:rgba(255,255,255,0.08);border:none;color:#CBD5E1;padding:4px 8px;border-radius:12px;cursor:pointer;font-size:11px;font-weight:600;text-decoration:none;display:flex;align-items:center;gap:4px;transition:background 0.2s,color 0.2s;}.hungai-head-btn:hover{background:rgba(245,158,11,0.35);color:#FFFFFF;}.hungai-video-stage{width:100%;height:190px;background:#000000;position:relative;overflow:hidden;flex-shrink:0;border-bottom:1.5px solid rgba(245,158,11,0.35);}.hungai-video-stage video{width:100%;height:100%;object-fit:cover;object-position:center 20%;position:absolute;top:0;left:0;display:block;transition:opacity 0.25s ease;}.hungai-video-stage.speaking-glow{box-shadow:inset 0 0 25px rgba(245,158,11,0.85);border-bottom-color:#F59E0B;}.hungai-video-tag-live{position:absolute;top:10px;right:12px;background:rgba(239,68,68,0.92);color:#FFFFFF;font-size:10px;font-weight:800;padding:3px 8px;border-radius:6px;display:none;align-items:center;gap:5px;box-shadow:0 2px 8px rgba(0,0,0,0.5);z-index:10;}.hungai-live-circle{width:6px;height:6px;background:#FFFFFF;border-radius:50%;animation:hungaiBlinkAnim 0.8s infinite;}.hungai-chat-messages{flex:1;padding:12px 14px;overflow-y:auto;display:flex;flex-direction:column;gap:10px;background:#080C14;}.hungai-chat-messages::-webkit-scrollbar{width:5px;}.hungai-chat-messages::-webkit-scrollbar-thumb{background:rgba(245,158,11,0.25);border-radius:3px;}.hungai-message{max-width:86%;padding:10px 14px;border-radius:14px;font-size:13px;line-height:1.5;word-break:break-word;}.hungai-msg-bot{background:#151F32;color:#F1F5F9;border:1px solid rgba(226,232,240,0.1);align-self:flex-start;border-bottom-left-radius:4px;}.hungai-msg-user{background:#F59E0B;color:#000000;font-weight:600;align-self:flex-end;border-bottom-right-radius:4px;}.hungai-chips-list{display:flex;flex-direction:column;gap:8px;margin-top:6px;width:100%;}.hungai-chip-item{background:#1C1608;border:1.5px solid #F59E0B;color:#FDE68A;font-size:12px;font-weight:600;padding:9px 14px;border-radius:16px;cursor:pointer;transition:all 0.25s ease;animation:hungaiChipSlide 0.4s ease-out;display:none;box-shadow:0 3px 10px rgba(0,0,0,0.4);line-height:1.4;}.hungai-chip-item:hover{background:#F59E0B;color:#000000;transform:translateX(4px);box-shadow:0 0 12px rgba(245,158,11,0.6);}@keyframes hungaiChipSlide{from{opacity:0;transform:translateY(8px);}to{opacity:1;transform:translateY(0);}}.hungai-chat-footer{padding:10px 12px;background:#0F172A;border-top:1px solid rgba(245,158,11,0.2);display:flex;gap:8px;align-items:center;flex-shrink:0;}.hungai-text-input{flex:1;background:#182235;border:1px solid rgba(226,232,240,0.15);border-radius:20px;padding:10px 14px;color:#FFFFFF;font-size:13px;outline:none;font-family:inherit;}.hungai-text-input:focus{border-color:#F59E0B;box-shadow:0 0 8px rgba(245,158,11,0.35);}.hungai-mic-btn{width:36px;height:36px;border-radius:50%;background:#182235;border:1.5px solid #CBD5E1;color:#FDE68A;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:15px;flex-shrink:0;transition:all 0.25s ease;}.hungai-mic-btn:hover{background:#25334D;border-color:#F59E0B;}.hungai-mic-btn.recording{background:#DC2626 !important;border-color:#EF4444 !important;color:#FFFFFF !important;animation:hungaiMicPulse 1.2s infinite;box-shadow:0 0 12px rgba(239,68,68,0.7);}@keyframes hungaiMicPulse{0%,100%{transform:scale(1);}50%{transform:scale(1.15);}}.hungai-send-btn{width:36px;height:36px;border-radius:50%;background:#F59E0B;border:none;color:#000000;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:13px;font-weight:700;flex-shrink:0;transition:transform 0.2s;}.hungai-send-btn:hover{transform:scale(1.08);}.hungai-typing-bar{display:none;align-self:flex-start;background:#151F32;padding:8px 12px;border-radius:14px;gap:4px;}.hungai-typing-circle{width:6px;height:6px;background:#F59E0B;border-radius:50%;animation:hungaiBlinkAnim 1.2s infinite;}.hungai-typing-circle:nth-child(2){animation-delay:0.2s;}.hungai-typing-circle:nth-child(3){animation-delay:0.4s;}@keyframes hungaiBlinkAnim{0%,100%{opacity:0.2;transform:scale(0.8);}50%{opacity:1;transform:scale(1.1);}}</style> <div id="hungai-widget-root"> <div id="hungai-chat-box"> <div class="hungai-chat-header"> <div class="hungai-header-meta"> <h4 id="hungai-header-name">Mai Lan</h4> <p id="hungai-header-role">Trợ lý tư vấn trực tuyến 24/7</p> </div> <div class="hungai-header-btns"> <button class="hungai-head-btn" id="hungai-tts-btn" onclick="hungaiToggleVoice()" title="Bật/Tắt giọng đọc trợ lý">Loa: Bật</button> <a href="https://zalo.me/0983607875" target="_blank" class="hungai-head-btn" title="Chat qua Zalo">Zalo</a> <a href="tel:0983607875" class="hungai-head-btn" title="Gọi Hotline 098.360.7875">Gọi</a> <button class="hungai-head-btn" onclick="hungaiOpenChat(false)" title="Thu nhỏ">_</button> </div> </div> <div class="hungai-video-stage" id="hungai-video-stage-box"> <video id="hungai-idle-video" src="/uploads/files/mai_lan_idle.mp4" autoplay loop muted playsinline style="opacity: 1;"></video> <video id="hungai-speaking-video" src="/uploads/files/mai_lan_talk.mp4" loop muted playsinline style="opacity: 0;"></video> <div class="hungai-video-tag-live" id="hungai-live-badge-box"> <span class="hungai-live-circle"></span> <span>LIVE</span> </div> </div> <div class="hungai-chat-messages" id="hungai-messages-wrap"> <div class="hungai-typing-bar" id="hungai-typing-indicator"> <div class="hungai-typing-circle"></div> <div class="hungai-typing-circle"></div> <div class="hungai-typing-circle"></div> </div> </div> <div class="hungai-chat-footer"> <button type="button" class="hungai-mic-btn" id="hungai-mic-button" onclick="hungaiToggleMic()" title="Bấm vào để nói qua Micro"> <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"> <path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"/> <path d="M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"/> </svg> </button> <input type="text" id="hungai-input-field" class="hungai-text-input" placeholder="Nhập câu hỏi hoặc bấm micro để nói..." onkeypress="if(event.key==='Enter') hungaiDoSend()"> <button class="hungai-send-btn" onclick="hungaiDoSend()">Gửi</button> </div> </div> <div id="hungai-floating-btn" onclick="hungaiOpenChat(true)"> <img src="/uploads/images/mai_lan_avatar.jpg" alt="Mai Lan"> <div class="hungai-live-badge"> <span class="hungai-live-dot"></span> <span>LIVE</span> </div> </div> </div> <script> (function() { var p = (window.location.pathname || "").toLowerCase().replace(/\/+$/, ""); var isHome = (p === "" || p === "/" || p === "/index.html" || p === "/index.php" || p === "/home" || p === "/hung-in.html" || p === "/hung-ai.html"); // Chỉ hiển thị khi vào đúng bài viết (link có đuôi -aXXX.html) var isArticle = /-a\d+\.html/.test(p); if (isHome || !isArticle) { var rootEl = document.getElementById("hungai-widget-root"); if (rootEl && rootEl.parentNode) rootEl.parentNode.removeChild(rootEl); return; } var rootEl = document.getElementById("hungai-widget-root"); if (rootEl) rootEl.style.display = "block"; function hungaiOpenChat(state) { var chatBox = document.getElementById("hungai-chat-box"); var floatBtn = document.getElementById("hungai-floating-btn"); var idleVid = document.getElementById("hungai-idle-video"); if (state === true) isOpen = true; else if (state === false) isOpen = false; else isOpen = !isOpen; if (chatBox) chatBox.style.display = isOpen ? "flex" : "none"; if (floatBtn) floatBtn.style.display = isOpen ? "none" : "flex"; if (isOpen) { if (idleVid && idleVid.paused) { idleVid.play().catch(function(){}); } setTimeout(function() { var inp = document.getElementById("hungai-input-field"); if (inp) inp.focus(); }, 100); triggerWelcomeSequence(); } else { if (idleVid) idleVid.pause(); var speakVid = document.getElementById("hungai-speaking-video"); if (speakVid) speakVid.pause(); var liveBadge = document.getElementById("hungai-live-badge-box"); if (liveBadge) liveBadge.style.display = "none"; var stageBox = document.getElementById("hungai-video-stage-box"); if (stageBox) stageBox.classList.remove("speaking-glow"); if ("speechSynthesis" in window) { window.speechSynthesis.cancel(); } } } window.hungaiOpenChat = hungaiOpenChat; // Tự thu hồi về khung tròn khi người dùng click ra ngoài khung chat document.addEventListener("mousedown", function(e) { if (!isOpen) return; var chatBox = document.getElementById("hungai-chat-box"); var floatBtn = document.getElementById("hungai-floating-btn"); if (chatBox && !chatBox.contains(e.target) && floatBtn && !floatBtn.contains(e.target)) { hungaiOpenChat(false); } }); var GEMINI_KEY = "AIzaSyD0DoEko2lCNA60FoUxJ4mQOYGZ8_WJW9Y"; var TELEGRAM_BOT = "8707005162:AAHUCoK43jijiXcRJipI65RI1hPR1e_EamA"; var TELEGRAM_CHAT = "8799202824"; var isOpen = false; var voiceEnabled = true; var isRecording = false; var recognition = null; var chatHistory = []; var userHasInteracted = false; var oneMinuteTimer = null; var autoCloseTimer = null; var currentHref = window.location.href.toLowerCase(); var breadcrumbEl = document.querySelector(".uk-breadcrumb, .breadcrumb, #breadcrumb"); var breadcrumbText = breadcrumbEl ? breadcrumbEl.innerText.toLowerCase() : ""; var h1El = document.querySelector(".uk-article-title, .article-title, h1"); var pageTitle = h1El ? h1El.innerText.trim() : (document.title || ""); var cleanTitle = pageTitle.replace(/^(dịch vụ|chuyên mục|bài viết|báo giá|hướng dẫn)\s+/i, "") .split(/[\-\|\:\–]/)[0].trim(); var tLower = cleanTitle.toLowerCase(); var fullTextCheck = (tLower + " " + breadcrumbText + " " + currentHref + " " + document.title.toLowerCase()); // NHẬN DIỆN CHUẨN XÁC TUYỆT ĐỐI HÙNG AI vs HÙNG IN var isAI = (document.documentElement && document.documentElement.classList.contains("brand-ai")) || currentHref.indexOf("hung-ai") !== -1 || breadcrumbText.indexOf("công nghệ.ai") !== -1 || breadcrumbText.indexOf("ai") !== -1 || /(ai|skill|prompt|agent|canva|veo|kling|runway|chatgpt|tự động|automation|trí tuệ nhân tạo)/i.test(fullTextCheck); var brandName = isAI ? "Hùng AI" : "Hùng In"; var bossName = isAI ? "anh Hùng AI" : "anh Hùng In"; var consultantName = "Mai Lan"; var consultantRole = "Trợ lý " + brandName + " - Tư vấn 24/7"; var currentTopic = "dịch vụ"; var currentChips = []; var currentSpokens = []; if (tLower.indexOf("catalogue") !== -1 || tLower.indexOf("catalog") !== -1 || tLower.indexOf("kẹp file") !== -1) { currentTopic = "thiết kế và in catalogue"; currentChips = [ "Báo giá thiết kế & in ấn catalogue trọn gói", "Tư vấn quy cách bấm ghim, đóng gáy keo nhiệt", "Xem các mẫu thiết kế catalogue ấn tượng đã làm" ]; currentSpokens = [ "Báo giá thiết kế và in ấn ca-ta-lốc trọn gói", "Tư vấn quy cách bấm ghim, đóng gáy keo nhiệt", "Xem các mẫu thiết kế ca-ta-lốc ấn tượng đã làm" ]; } else if (tLower.indexOf("bìa sách") !== -1 || tLower.indexOf("sách") !== -1) { currentTopic = "thiết kế bìa sách"; currentChips = [ "Báo giá và thời gian thiết kế bìa sách trọn gói", "Quy trình dàn trang & xuất file in chuẩn xuất bản", "Xem các mẫu bìa sách đẹp đã thực hiện" ]; currentSpokens = [ "Báo giá và thời gian thiết kế bìa sách trọn gói", "Quy trình dàn trang và xuất file in chuẩn xuất bản", "Xem các mẫu bìa sách đẹp đã thực hiện" ]; } else if (tLower.indexOf("hộp") !== -1 || tLower.indexOf("bao bì") !== -1) { currentTopic = "sản xuất bao bì, hộp giấy"; currentChips = [ "Báo giá in hộp giấy theo số lượng & kích thước", "Tư vấn chất liệu giấy & quy cách ép kim, dập nổi", "Tiến độ sản xuất & hỗ trợ làm mẫu test" ]; currentSpokens = [ "Báo giá in hộp giấy theo số lượng và kích thước", "Tư vấn chất liệu giấy và quy cách ép kim, dập nổi", "Tiến độ sản xuất và hỗ trợ làm mẫu test" ]; } else if (tLower.indexOf("lịch") !== -1) { currentTopic = "in lịch Tết"; currentChips = [ "Báo giá in lịch bàn, lịch treo tường độc quyền", "Tư vấn quy cách & thiết kế lịch Tết thương hiệu" ]; currentSpokens = [ "Báo giá in lịch bàn, lịch treo tường độc quyền", "Tư vấn quy cách và thiết kế lịch Tết thương hiệu" ]; } else if (tLower.indexOf("logo") !== -1 || tLower.indexOf("nhận diện") !== -1) { currentTopic = "thiết kế logo & nhận diện thương hiệu"; currentChips = [ "Báo giá thiết kế logo & bộ nhận diện thương hiệu", "Quy trình sáng tạo ý tưởng & bàn giao file gốc", "Xem các mẫu thiết kế logo tiêu biểu" ]; currentSpokens = [ "Báo giá thiết kế logo và bộ nhận diện thương hiệu", "Quy trình sáng tạo ý tưởng và bàn giao file gốc", "Xem các mẫu thiết kế logo tiêu biểu" ]; } else if (isAI || tLower.indexOf("ai") !== -1 || tLower.indexOf("canva") !== -1 || tLower.indexOf("veo") !== -1) { if (tLower.indexOf("veo") !== -1 || tLower.indexOf("canva") !== -1 || tLower.indexOf("video") !== -1) { currentTopic = "kiếm tiền & sản xuất video AI bằng Canva và Veo 3"; currentChips = [ "Quy trình sản xuất video quảng cáo ngắn bằng Canva & Veo 3", "Cách đóng gói dịch vụ video AI bán cho doanh nghiệp", "Tư vấn kịch bản & bộ Prompt tạo video triệu view" ]; currentSpokens = [ "Quy trình sản xuất video quảng cáo ngắn bằng Canva và Veo 3", "Cách đóng gói dịch vụ video AI bán cho doanh nghiệp", "Tư vấn kịch bản và bộ Prompt tạo video triệu view" ]; } else { currentTopic = cleanTitle.toLowerCase(); currentChips = [ "Chi phí triển khai giải pháp AI cho doanh nghiệp", "Quy trình tích hợp và tự động hóa vận hành", "Tư vấn giải pháp AI trực tiếp 1:1 với anh Hùng AI" ]; currentSpokens = [ "Chi phí triển khai giải pháp AI cho doanh nghiệp", "Quy trình tích hợp và tự động hóa vận hành", "Tư vấn giải pháp AI trực tiếp một một với anh Hùng AI" ]; } } else { currentTopic = cleanTitle.toLowerCase() || "dịch vụ"; currentChips = [ "Báo giá chi tiết theo yêu cầu", "Quy trình triển khai & thời gian hoàn thiện", "Tư vấn mẫu mã & quy cách thực tế" ]; currentSpokens = [ "Báo giá chi tiết theo yêu cầu", "Quy trình triển khai và thời gian hoàn thiện", "Tư vấn mẫu mã và quy cách thực tế" ]; } // CÂU ĐIỀU HƯỚNG ZALO KẾT NỐI ANH HÙNG (CÂU CHỐT CUỐI CÙNG) var zaloClosingChip = "Nếu anh chị cần báo giá hay tư vấn gấp, ngay bây giờ em sẽ bật Zalo chat để kết nối với anh Hùng để hỗ trợ, còn nếu anh chị muốn em tư vấn hay trao đổi thêm gì hãy bấm vào micro để nói chuyện hoặc gõ lên khung chat."; currentChips.push(zaloClosingChip); currentSpokens.push(zaloClosingChip); var introGreeting = "Dạ em chào anh/chị! Em là Mai Lan trợ lý của " + brandName + ". Anh/chị đang quan tâm đến vấn đề gì trong " + currentTopic + " ạ?"; var chipOptions = currentChips; var spokenTexts = currentSpokens; var headerNameEl = document.getElementById("hungai-header-name"); var headerRoleEl = document.getElementById("hungai-header-role"); if (headerNameEl) headerNameEl.innerText = consultantName; if (headerRoleEl) headerRoleEl.innerText = consultantRole; // CHUẨN HÓA PHÁT ÂM TIẾNG VIỆT function normalizeTextForSpeech(text) { var res = text; var rules = [ [/(\d+)\s*[xX*×]\s*(\d+)/g, "$1 nhân $2"], [/(\d+)\s*[xX*×]\s*(\d+)/g, "$1 nhân $2"], [/(\d+)\s*cm\b/gi, "$1 xăng ti mét"], [/(\d+)\s*mm\b/gi, "$1 mi li mét"], [/(\d+)\s*gsm\b/gi, "$1 gờ ét mờ"], [/(\d+)\s*k\b/gi, "$1 nghìn"], [/\b3D\b/gi, "ba đê"], [/\bUV\b/gi, "U Vê"], [/\boffset\b/gi, "ốp sét"], [/\bembossing\b/gi, "dập nổi"], [/\bmetallic\b/gi, "me-ta-lic"], [/\bCouche\b/gi, "cút xê"], [/\bKraft\b/gi, "cờ ráp"], [/\bIvory\b/gi, "ai vô ri"], [/\bDuplex\b/gi, "đu plếch"], [/anh\/chị/gi, "anh chị"], [/\b24\/7\b/gi, "hai tư trên bảy"], [/\bcatalogue\b/gi, "ca-ta-lô"], [/\bcatalog\b/gi, "ca-ta-lô"], [/\bbrochure\b/gi, "bờ-rô-xua"], [/1:1/g, "một một"], [/\bAI Agent\b/gi, "trợ lý trí tuệ nhân tạo"], [/\bAI\b/gi, "A I"], [/\bAgent\b/gi, "trợ lý"], [/\bAutomation\b/gi, "tự động hóa"], [/\bn8n\b/gi, "nờ tám nờ"], [/\bSecond Brain\b/gi, "bộ não thứ hai"], [/\bSĐT\b/gi, "số điện thoại"], [/\bsđt\b/gi, "số điện thoại"], [/\bHotline\b/gi, "hót lai"], [/\bZalo\b/gi, "da-lô"], [/098\.360\.7875/g, "không chín tám, ba sáu không, bảy tám bảy năm"], [/0889\.699\.855/g, "không tám tám chín, sáu chín chín, tám năm năm"], [/[*_#`\(\)\[\]\/]/g, " "], [/https?:\/\/\S+/g, " "] ]; for (var i = 0; i < rules.length; i++) { res = res.replace(rules[i][0], rules[i][1]); } return res.replace(/\s+/g, " ").trim(); } // ĐỒNG BỘ TUYỆT ĐỐI GIỌNG NÓI & CHỮ CHẠY (CHỮ CHỈ CHẠY CÙNG LÚC KHI CẤT TIẾNG) function speakAndType(targetEl, text, onCompleteCallback) { var idleVid = document.getElementById("hungai-idle-video"); var speakVid = document.getElementById("hungai-speaking-video"); var liveBadge = document.getElementById("hungai-live-badge-box"); var stageBox = document.getElementById("hungai-video-stage-box"); if (targetEl) targetEl.innerText = ""; var tokens = text.split(" "); var tokenIdx = 0; var typeInterval = null; var hasStopped = false; var safetyTimer = null; function startTalking() { if (speakVid) { speakVid.currentTime = 0; speakVid.style.opacity = "1"; speakVid.play().catch(function(){}); } if (idleVid) idleVid.style.opacity = "0"; if (liveBadge) liveBadge.style.display = "flex"; if (stageBox) stageBox.classList.add("speaking-glow"); if (targetEl && !typeInterval) { var stepMs = 230; typeInterval = setInterval(function() { if (tokenIdx < tokens.length) { targetEl.innerText += (tokenIdx === 0 ? "" : " ") + tokens[tokenIdx]; tokenIdx++; var wrap = document.getElementById("hungai-messages-wrap"); if (wrap) wrap.scrollTop = wrap.scrollHeight; } else { clearInterval(typeInterval); typeInterval = null; } }, stepMs); } } function stopTalking() { if (hasStopped) return; hasStopped = true; if (safetyTimer) { clearTimeout(safetyTimer); safetyTimer = null; } if (typeInterval) { clearInterval(typeInterval); typeInterval = null; } if (targetEl) { targetEl.innerText = text; var wrap = document.getElementById("hungai-messages-wrap"); if (wrap) wrap.scrollTop = wrap.scrollHeight; } if (speakVid) { speakVid.style.opacity = "0"; speakVid.pause(); } if (idleVid) { idleVid.style.opacity = "1"; idleVid.play().catch(function(){}); } if (liveBadge) liveBadge.style.display = "none"; if (stageBox) stageBox.classList.remove("speaking-glow"); if (onCompleteCallback) onCompleteCallback(); } // Luôn có bộ hẹn giờ dự phòng bảo đảm 100% stopTalking và callback được gọi var maxSpeechMs = Math.max(2000, tokens.length * 240 + 1200); safetyTimer = setTimeout(function() { stopTalking(); }, maxSpeechMs); if (!voiceEnabled || !("speechSynthesis" in window)) { startTalking(); return; } try { window.speechSynthesis.cancel(); var clean = normalizeTextForSpeech(text); var utter = new SpeechSynthesisUtterance(clean); window.__currentUtter = utter; // Chống Chrome GC giải phóng bộ nhớ giữa chừng utter.lang = "vi-VN"; utter.rate = 1.30; utter.pitch = 1.0; utter.onstart = startTalking; utter.onend = stopTalking; utter.onerror = stopTalking; var voices = window.speechSynthesis.getVoices(); for (var i = 0; i < voices.length; i++) { if (voices[i].lang.indexOf("vi") !== -1) { utter.voice = voices[i]; break; } } window.speechSynthesis.speak(utter); } catch(e) { startTalking(); } } window.hungaiToggleVoice = function() { voiceEnabled = !voiceEnabled; var btn = document.getElementById("hungai-tts-btn"); if (btn) { btn.innerText = voiceEnabled ? "Loa: Bật" : "Loa: Tắt"; btn.style.color = voiceEnabled ? "#10B981" : "#EF4444"; } if (!voiceEnabled && ("speechSynthesis" in window)) { window.speechSynthesis.cancel(); } }; // MICRO ĐÀM THOẠI window.hungaiToggleMic = function() { userHasInteracted = true; if (oneMinuteTimer) clearTimeout(oneMinuteTimer); if (autoCloseTimer) clearTimeout(autoCloseTimer); var micBtn = document.getElementById("hungai-mic-button"); var inputField = document.getElementById("hungai-input-field"); var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; if (!SpeechRecognition) { alert("Trình duyệt chưa hỗ trợ Micro. Anh chị nhập phím giúp em nhé!"); return; } if (isRecording && recognition) { recognition.stop(); return; } try { recognition = new SpeechRecognition(); recognition.lang = "vi-VN"; recognition.continuous = false; recognition.interimResults = true; recognition.onstart = function() { isRecording = true; if (micBtn) micBtn.classList.add("recording"); if (inputField) inputField.placeholder = "Đang lắng nghe anh chị nói..."; }; recognition.onresult = function(event) { var transcript = ""; for (var i = event.resultIndex; i < event.results.length; ++i) { transcript += event.results[i][0].transcript; } if (inputField) inputField.value = transcript; }; recognition.onend = function() { isRecording = false; if (micBtn) micBtn.classList.remove("recording"); if (inputField) { inputField.placeholder = "Nhập câu hỏi hoặc bấm micro để nói..."; if (inputField.value.trim().length > 0) { hungaiDoSend(); } } }; recognition.onerror = function() { isRecording = false; if (micBtn) micBtn.classList.remove("recording"); if (inputField) inputField.placeholder = "Nhập câu hỏi hoặc bấm micro để nói..."; }; recognition.start(); } catch(err) { isRecording = false; if (micBtn) micBtn.classList.remove("recording"); } }; // LỜI CHÀO BAN ĐẦU + DÒNG CHỮ CHẠY THEO LỜI NÓI function initWelcome() { var wrap = document.getElementById("hungai-messages-wrap"); var typing = document.getElementById("hungai-typing-indicator"); var botMsg = document.createElement("div"); botMsg.className = "hungai-message hungai-msg-bot"; wrap.insertBefore(botMsg, typing); speakAndType(botMsg, introGreeting, function() { scheduleOneMinuteFollowup(); }); } // KỊCH BẢN: SAU 1 PHÚT KHÔNG PHẢN HỒI -> NÓI CÂU DẪN VÀ 4 KHUNG VÀNG LẦN LƯỢT XUẤT HIỆN function scheduleOneMinuteFollowup() { if (oneMinuteTimer) clearTimeout(oneMinuteTimer); oneMinuteTimer = setTimeout(function() { if (userHasInteracted || !isOpen) return; var wrap = document.getElementById("hungai-messages-wrap"); var typing = document.getElementById("hungai-typing-indicator"); var followupText = "Bên chúng em có thể giúp anh chị:"; var followMsg = document.createElement("div"); followMsg.className = "hungai-message hungai-msg-bot"; wrap.insertBefore(followMsg, typing); speakAndType(followMsg, followupText, function() { showAndReadChipsSequentially(); }); }, 15000); // 15 GIÂY } var zaloFollowupTimer = null; var zaloAutoHideTimer = null; var userReallyReplied = false; function cancelZaloTimers() { userReallyReplied = true; if (zaloFollowupTimer) { clearTimeout(zaloFollowupTimer); zaloFollowupTimer = null; } if (zaloAutoHideTimer) { clearTimeout(zaloAutoHideTimer); zaloAutoHideTimer = null; } } var resetZaloFollowupTimers = cancelZaloTimers; function startZaloFollowupCountdown() { if (zaloFollowupTimer) clearTimeout(zaloFollowupTimer); if (zaloAutoHideTimer) clearTimeout(zaloAutoHideTimer); userReallyReplied = false; // ĐẾM ĐÚNG 15 GIÂY SAU KHI KHUNG ZALO XUẤT HIỆN zaloFollowupTimer = setTimeout(function() { if (userReallyReplied || !isOpen) return; var wrap = document.getElementById("hungai-messages-wrap"); var typing = document.getElementById("hungai-typing-indicator"); var checkMsg = document.createElement("div"); checkMsg.className = "hungai-message hungai-msg-bot"; wrap.insertBefore(checkMsg, typing); wrap.scrollTop = wrap.scrollHeight; var checkText = isAI ? "Anh chị đã kết nối được với anh Hùng AI chưa ạ? Nếu đã kết nối được rồi em xin tắt hộp hội thoại và nếu anh chị cần trao đổi gì thêm xin hãy bấm vào micro hoặc gõ vào hội thoại." : "Anh chị đã kết nối được với " + bossName + " chưa ạ? Nếu đã kết nối được rồi em xin tắt hộp hội thoại và nếu anh chị cần trao đổi gì thêm xin hãy bấm vào micro hoặc gõ vào hội thoại."; speakAndType(checkMsg, checkText, function() { // SAU KHI ĐỌC XONG CÂU TRÊN: ĐẾM ĐÚNG 5 GIÂY TỰ ĐỘNG ẨN zaloAutoHideTimer = setTimeout(function() { if (!userReallyReplied && isOpen) { hungaiOpenChat(false); } }, 5000); // 5 GIÂY }); }, 15000); // 15 GIÂY } // 4 KHUNG VÀNG LẦN LƯỢT XUẤT HIỆN VÀ ĐỌC ĐÚNG NỘI DUNG TỪNG KHUNG function renderMiniZaloCard(parentEl) { if (!parentEl) parentEl = document.getElementById("hungai-messages-wrap"); var existingCard = document.getElementById("hungai-mini-zalo-card"); if (!existingCard) { var card = document.createElement("div"); card.id = "hungai-mini-zalo-card"; card.style.cssText = "margin-top:8px;padding:8px 10px;background:#0F172A;border:1px solid #0068FF;border-radius:12px;display:flex;align-items:center;gap:10px;box-shadow:0 4px 14px rgba(0,0,0,0.4);animation:hungaiSlideIn 0.3s ease;"; card.innerHTML = '<img src="/uploads/images/zalo_qr_hung_in.jpg" style="width:72px;height:72px;border-radius:6px;background:#ffffff;padding:2px;flex-shrink:0;box-shadow:0 1px 4px rgba(0,0,0,0.3);" alt="Zalo QR">' + '<div style="flex:1;min-width:0;">' + '<div style="color:#60A5FA;font-size:11px;font-weight:700;display:flex;align-items:center;gap:4px;margin-bottom:2px;">' + '<svg width="13" height="13" viewBox="0 0 24 24" fill="#0068FF"><path d="M12 2C6.48 2 2 6.48 2 12c0 1.82.49 3.53 1.35 5L2 22l5.22-1.31C8.61 21.43 10.26 22 12 22c5.52 0 10-4.48 10-10S17.52 2 12 2z"/></svg>' + 'Kết nối Zalo với anh Hùng' + '</div>' + '<div style="color:#94A3B8;font-size:10px;line-height:1.3;margin-bottom:5px;">Quét mã QR hoặc bấm nút:</div>' + '<a href="https://zalo.me/0983607875" target="_blank" onclick="cancelZaloTimers();" style="display:inline-flex;align-items:center;gap:6px;background:#0068FF;color:#FFFFFF;font-size:11.5px;font-weight:700;padding:5px 12px;border-radius:6px;text-decoration:none;box-shadow:0 2px 8px rgba(0,104,255,0.45);">' + '<svg width="13" height="13" viewBox="0 0 24 24" fill="#FFFFFF"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/></svg>' + 'Mở Zalo chat' + '</a>' + '</div>'; parentEl.appendChild(card); var wrap = document.getElementById("hungai-messages-wrap"); if (wrap) wrap.scrollTop = wrap.scrollHeight; } // Luôn kích hoạt bộ đếm giờ 45s + 10s tự ẩn bất cứ khi nào Card Zalo được hiển thị startZaloFollowupCountdown(); } function showAndReadChipsSequentially() { var wrap = document.getElementById("hungai-messages-wrap"); var typing = document.getElementById("hungai-typing-indicator"); var chipsContainer = document.createElement("div"); chipsContainer.className = "hungai-chips-list"; wrap.insertBefore(chipsContainer, typing); var idx = 0; function playNextChip() { if (userHasInteracted || !isOpen) return; if (idx >= chipOptions.length) { // SAU KHI XUẤT HIỆN XONG CẢ 4 KHUNG: BẮT ĐẦU ĐẾM 45 GIÂY ĐỂ HỎI LẠI VÀ 10 GIÂY TỰ ẨN startZaloFollowupCountdown(); return; } var optText = chipOptions[idx]; var spokenText = spokenTexts[idx]; var chipEl = document.createElement("div"); chipEl.className = "hungai-chip-item"; chipEl.style.display = "block"; chipEl.onclick = function() { userHasInteracted = true; if (autoCloseTimer) clearTimeout(autoCloseTimer); document.getElementById("hungai-input-field").value = optText; hungaiDoSend(); }; chipsContainer.appendChild(chipEl); wrap.scrollTop = wrap.scrollHeight; var currentIdx = idx; idx++; speakAndType(chipEl, spokenText, function() { if (currentIdx === 3) { renderMiniZaloCard(chipsContainer); } setTimeout(playNextChip, 350); }); } playNextChip(); } var hasWelcomeTriggered = false; function triggerWelcomeSequence() { if (hasWelcomeTriggered) return; hasWelcomeTriggered = true; // Đợi 600ms để khung chat mở hoàn toàn và video hình cô gái đã nổi rõ nét trên màn hình rồi mới cất tiếng setTimeout(function() { initWelcome(); }, 600); } function getTrafficSource() { var ref = (document.referrer || "").toLowerCase(); var params = new URLSearchParams(window.location.search); var utmSource = params.get('utm_source'); var utmMedium = params.get('utm_medium'); var utmCampaign = params.get('utm_campaign'); var fbclid = params.get('fbclid'); var gclid = params.get('gclid'); var zarsrc = params.get('zarsrc'); if (utmSource) { var s = utmSource.toUpperCase(); if (utmMedium) s += " (" + utmMedium + ")"; if (utmCampaign) s += " - CD: " + utmCampaign; return s; } if (fbclid || ref.indexOf("facebook.com") !== -1 || ref.indexOf("fb.me") !== -1 || ref.indexOf("l.facebook.com") !== -1 || ref.indexOf("m.facebook.com") !== -1) { if (ref.indexOf("hungin70") !== -1 || ref.indexOf("pages") !== -1) return "Facebook Fanpage Hùng In"; if (ref.indexOf("hungtritue") !== -1 || params.get('fb_source') === 'profile') return "Facebook Trang cá nhân"; return "Facebook (Bài viết / Bảng tin / Fanpage)"; } if (zarsrc || ref.indexOf("zalo.me") !== -1 || ref.indexOf("chat.zalo.me") !== -1) { return "Zalo (Tin nhắn / Nhật ký Zalo)"; } if (gclid || ref.indexOf("google.com") !== -1 || ref.indexOf("google.com.vn") !== -1 || ref.indexOf("bing.com") !== -1) { return "Google Search (Tìm kiếm)"; } if (ref.indexOf("tiktok.com") !== -1) return "TikTok"; if (ref.indexOf("youtube.com") !== -1 || ref.indexOf("youtu.be") !== -1) return "YouTube"; if (!ref || ref.indexOf(window.location.hostname) !== -1) return "Truy cập trực tiếp"; return "Website ngoài: " + document.referrer; } function getDeviceName() { var ua = navigator.userAgent; if (/iPad|iPhone|iPod/.test(ua) && !window.MSStream) return "iPhone / iPad (iOS)"; if (/Android/.test(ua)) return "Điện thoại Android"; if (/Macintosh|Mac OS X/.test(ua)) return "Máy tính Mac (macOS)"; if (/Windows/.test(ua)) return "Máy tính Windows"; return "Thiết bị khác"; } var hasSentFirstMsgAlert = false; function notifyLead(fullMsg, phone) { var isHotLead = !!phone; var now = new Date(); var timeStr = ("0" + now.getHours()).slice(-2) + ":" + ("0" + now.getMinutes()).slice(-2) + " - " + ("0" + now.getDate()).slice(-2) + "/" + ("0" + (now.getMonth() + 1)).slice(-2) + "/" + now.getFullYear(); var source = getTrafficSource(); var device = getDeviceName(); var pageUrl = window.location.href; var header = isHotLead ? "???? [HOT LEAD - CÓ SỐ ĐIỆN THOẠI KHÁCH HÀNG]" : "???? [KHÁCH ĐANG CHAT TRÊN WEB TRITUEMEDIA]"; var text = header + "\n" + "━━━━━━━━━━━━━━━━━━━━\n" + "???? Nguồn: " + source + "\n" + "???? Thiết bị: " + device + "\n" + "???? Trang xem: " + pageUrl + "\n" + "⏰ Lúc: " + timeStr + "\n" + "━━━━━━━━━━━━━━━━━━━━\n" + (isHotLead ? "???? SỐ ĐIỆN THOẠI: " + phone + "\n" : "") + "???? Nội dung: \"" + fullMsg + "\"\n" + "????️ Chuyên mục: " + (isAI ? "HÙNG AI" : "HÙNG IN"); var endpoint = "https://api.telegram.org/bot" + TELEGRAM_BOT + "/sendMessage"; try { fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ chat_id: TELEGRAM_CHAT, text: text }) }); } catch(e) {} } function getSmartQuickReply(text) { var raw = text.trim(); var norm = raw.toLowerCase().replace(/[!.,?~:;]/g, " ").replace(/\s+/g, " ").trim(); // 1. Ý ĐỊNH HỎI SỐ ĐIỆN THOẠI / ZALO / LIÊN HỆ ANH HÙNG / HOTLINE var phoneKeys = [ "số của anh hùng", "so cua anh hung", "số anh hùng", "so anh hung", "số điện thoại", "so dien thoai", "sđt", "sdt", "hotline", "hot line", "số zalo", "so zalo", "zalo anh hùng", "zalo anh hung", "cho anh số", "cho mình số", "cho em số", "liên hệ thế nào", "lien he the nao", "gọi cho ai", "goi cho ai", "số liên hệ", "so lien he", "kết nối anh hùng", "ket noi anh hung", "xin số", "xin so" ]; for (var i = 0; i < phoneKeys.length; i++) { if (norm.indexOf(phoneKeys[i]) !== -1) { return { reply: isAI ? "Dạ, số điện thoại và Zalo trực tiếp của chuyên gia Hùng AI là 098.360.7875 (hoặc 0889.699.855) anh chị nhé!" : "Dạ, số điện thoại và Zalo trực tiếp của " + bossName + " là 098.360.7875 (hoặc 0889.699.855) anh chị nhé!", showZaloCard: true }; } } // 2. Ý ĐỊNH HỎI ĐỊA CHỈ / XƯỞNG / VĂN PHÒNG var addressKeys = [ "địa chỉ", "dia chi", "ở đâu", "o dau", "xưởng ở đâu", "xuong o dau", "địa chỉ xưởng", "dia chi xuong", "công ty ở đâu", "cong ty o dau", "văn phòng ở đâu", "van phong o dau", "đến xem mẫu", "den xem mau", "xem mẫu ở đâu", "xem mau o dau", "hàng đào", "hang dao" ]; for (var i = 0; i < addressKeys.length; i++) { if (norm.indexOf(addressKeys[i]) !== -1) { return { reply: isAI ? "Dạ văn phòng của bên em tại số 20 Hàng Đào, quận Hoàn Kiếm, Hà Nội anh chị nhé. Anh chị có thể ghé qua trao đổi giải pháp trực tiếp ạ!" : "Dạ văn phòng Trí Tuệ Media - Hùng In tại số 20 Hàng Đào, quận Hoàn Kiếm, Hà Nội và hệ thống xưởng sản xuất tại Hà Nội. Anh chị có thể qua trực tiếp xem mẫu bao bì thực tế nhé ạ!", showZaloCard: false }; } } // 3. KHÁCH GÕ CỘC LỐC / GIỤC GIÃ ("nào", "sao", "alo", "ơi", "?") var shortPushes = ["nào", "nao", "sao", "sao rồi", "sao roi", "sao thế", "sao the", "đâu rồi", "dau roi", "ơi", "oi", "alo", "alô"]; if (shortPushes.indexOf(norm) !== -1 || norm === "?" || norm === "??") { return { reply: "Dạ em Mai Lan đây ạ! Anh chị cần em hỗ trợ giải đáp chi tiết điều gì, anh chị cứ nhắn em giải đáp ngay nhé ạ!", showZaloCard: false }; } // 4. LỜI CHÀO HỎI THÔNG THƯỜNG var greetingWords = ["hello", "hi", "chào", "chao", "chào em", "chao em", "chào bạn", "chao ban", "em ơi", "em oi", "có ai không", "co ai khong"]; for (var i = 0; i < greetingWords.length; i++) { if (norm === greetingWords[i] || norm.indexOf(greetingWords[i]) === 0) { return { reply: isAI ? "Dạ em chào anh chị! Em là Mai Lan trợ lý của Hùng AI. Anh chị đang quan tâm giải pháp AI Agent, Tự động hóa quy trình hay AI Video nào ạ?" : "Dạ em chào anh chị! Em là Mai Lan trợ lý của Hùng In. Anh chị đang quan tâm sản xuất bao bì, hộp giấy hay in lịch Tết, bao lì xì cho bên mình ạ?", showZaloCard: false }; } } // 5. CẢM ƠN var thanksWords = ["cảm ơn", "cam on", "thank", "thanks", "cảm ơn em", "cam on em", "cảm ơn bạn", "ok cảm ơn"]; for (var i = 0; i < thanksWords.length; i++) { if (norm === thanksWords[i] || norm.indexOf(thanksWords[i]) === 0) { return { reply: "Dạ không có chi ạ! Anh chị cần tìm hiểu thêm gì cứ nhắn em nhé, em luôn sẵn sàng hỗ trợ anh chị 24/7 ạ!", showZaloCard: false }; } } // 6. NHẬN DIỆN SỔ TAY / SỔ DA / SỔ QUÀ TẶNG if (norm.indexOf("sổ tay") !== -1 || norm.indexOf("so tay") !== -1 || norm.indexOf("sổ da") !== -1 || norm.indexOf("so da") !== -1 || norm.indexOf("sổ còng") !== -1) { return { reply: "Dạ xưởng Hùng In chuyên sản xuất sổ tay bìa da PU, bìa còng dập chìm ép kim logo cao cấp theo yêu cầu doanh nghiệp. Anh chị dự kiến in số lượng khoảng bao nhiêu cuốn và khổ A5 hay A6 ạ?", showZaloCard: false }; } // 7. NHẬN DIỆN SỐ LƯỢNG (VÍ DỤ: 2000, 1000 CUỐN, 500 CÁI...) if (/^\d+[\s\.\,]*((cuốn|cuon|cái|cai|chiếc|chiec|hộp|hop|bộ|bo|sp|chiếc))?$/.test(norm)) { return { reply: "Dạ em đã ghi nhận số lượng " + raw + " của anh chị rồi ạ! Xưởng em cam kết giá tận xưởng cực kỳ ưu đãi và hỗ trợ thiết kế phối cảnh logo miễn phí. Em gửi mã kết nối Zalo với " + bossName + " ngay bên dưới để anh chị gửi mẫu trao đổi chi tiết nhé ạ!", showZaloCard: true }; } // 8. LỊCH TẾT / BAO LÌ XÌ / HỘP GIẤY / TÚI GIẤY if (norm.indexOf("lịch tết") !== -1 || norm.indexOf("lich tet") !== -1 || norm.indexOf("lịch bàn") !== -1 || norm.indexOf("lich ban") !== -1) { return { reply: "Dạ xưởng em đã có sẵn đầy đủ catalogue các mẫu lịch để bàn, lịch treo tường và lịch bloc 2027 mới nhất. Anh chị đang quan tâm dòng lịch nào để em gửi mẫu xem thử ạ?", showZaloCard: false }; } if (norm.indexOf("bao lì xì") !== -1 || norm.indexOf("bao li xi") !== -1 || norm.indexOf("lì xì") !== -1) { return { reply: "Dạ xưởng Hùng In chuyên in bao lì xì Tết giấy Kraft, giấy Couche, ép kim nhũ vàng sắc nét. Anh chị dự kiến in số lượng khoảng bao nhiêu chiếc ạ?", showZaloCard: false }; } return null; } function hungaiDoSend() { userHasInteracted = true; resetZaloFollowupTimers(); if (oneMinuteTimer) clearTimeout(oneMinuteTimer); if (autoCloseTimer) clearTimeout(autoCloseTimer); var input = document.getElementById("hungai-input-field"); var userText = input.value.trim(); if (!userText) return; input.value = ""; var wrap = document.getElementById("hungai-messages-wrap"); var typing = document.getElementById("hungai-typing-indicator"); var userBox = document.createElement("div"); userBox.className = "hungai-message hungai-msg-user"; userBox.innerText = userText; wrap.insertBefore(userBox, typing); wrap.scrollTop = wrap.scrollHeight; var phoneDetect = userText.match(/(0[3|5|7|8|9][0-9]{8})/); if (phoneDetect) { notifyLead(userText, phoneDetect[1]); } else if (!hasSentFirstMsgAlert) { hasSentFirstMsgAlert = true; notifyLead(userText, null); } var fastReply = getSmartQuickReply(userText); if (fastReply) { var botBox = document.createElement("div"); botBox.className = "hungai-message hungai-msg-bot"; wrap.insertBefore(botBox, typing); speakAndType(botBox, fastReply.reply, function() { if (fastReply.showZaloCard) { renderMiniZaloCard(wrap); } }); return; } typing.style.display = "flex"; wrap.scrollTop = wrap.scrollHeight; chatHistory.push({ role: "user", parts: [{ text: userText }] }); var pageH1 = document.querySelector("h1"); var pageTitle = pageH1 && pageH1.innerText ? pageH1.innerText.trim() : (document.title || ""); var sysPrompt = isAI ? "Bạn là Mai Lan - Chuyên gia tư vấn giải pháp AI của chuyên gia Đỗ Huy Hùng (Hùng AI) trên website trituemedia.vn. Khách hàng đang xem trang: '" + pageTitle + "'. Hãy tập trung tư vấn đúng trọng tâm chủ đề trang này (AI Agent, Tự động hóa n8n, AI Video, Second Brain). TUYỆT ĐỐI KHÔNG lan man sang in ấn bao bì. Khi cần anh Hùng hỗ trợ, hãy nói dứt khoát: 'Dạ để em mở kết nối Zalo ngay bên dưới để anh Hùng hỗ trợ trực tiếp cho anh chị nhé ạ!', TUYỆT ĐỐI KHÔNG nói 'vui lòng chờ em'. Trả lời súc tích, sắc sảo từ 2 đến 4 câu. TUYỆT ĐỐI KHÔNG thêm hashtag (#)." : "Bạn là Mai Lan - Chuyên gia tư vấn cấp cao của thương hiệu Hùng In (Công ty Cổ phần Bao bì Đông Hà) trên website trituemedia.vn. Khách hàng hiện đang đọc bài viết: '" + pageTitle + "'.\n" + "QUY TẮC CỐT LÕI: Bạn PHẢI TẬP TRUNG 100% TƯ VẤN ĐÚNG CHỦ ĐỀ MÀ KHÁCH ĐANG XEM (Ví dụ nếu khách đang ở bài Bao Lì Xì thì CHỈ tư vấn kỹ thuật, chất liệu, kích thước, gia công cho Bao Lì Xì; TUYỆT ĐỐI KHÔNG tự ý lan man sang hộp cứng, catalogue hay sản phẩm khác trừ khi khách chủ động hỏi).\n" + "TƯ VẤN SÂU: giải đáp cụ thể câu hỏi kỹ thuật của khách (như thay thế ép kim bằng in nhũ metallic, phủ UV định vị, thúc nổi 3D, chọn giấy mỹ thuật vân nhám...).\n" + "KHI CẦN KẾT NỐI VỚI ANH HÙNG: Hãy nói dứt khoát: 'Dạ vấn đề này để em mở kết nối Zalo ngay bên dưới để anh Hùng tư vấn trực tiếp cho anh chị nhé ạ!', TUYỆT ĐỐI KHÔNG nói 'vui lòng chờ em một chút'. TUYỆT ĐỐI KHÔNG đòi hỏi số điện thoại của khách bừa bãi. TUYỆT ĐỐI KHÔNG thêm hashtag (#)."; var requestBody = { system_instruction: { parts: [{ text: sysPrompt }] }, contents: chatHistory.slice(-2) }; var modelName = "gemini-2.5-flash"; var apiUrl = "https://generativelanguage.googleapis.com/v1beta/models/" + modelName + ":generateContent?key=" + GEMINI_KEY; function handleFallback() { typing.style.display = "none"; var fallbackText = isAI ? "Dạ câu hỏi này chuyên sâu quá, để em bật kết nối Zalo với anh Hùng để anh ấy tư vấn chính xác và chi tiết nhất cho anh chị nhé ạ!" : "Dạ câu hỏi này chuyên sâu quá, để em bật kết nối Zalo với " + bossName + " để anh ấy tư vấn chính xác và chi tiết nhất cho anh chị nhé ạ!"; var botBox = document.createElement("div"); botBox.className = "hungai-message hungai-msg-bot"; wrap.insertBefore(botBox, typing); speakAndType(botBox, fallbackText, function() { renderMiniZaloCard(wrap); }); } fetch(apiUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(requestBody) }) .then(function(res) { if (!res.ok) throw new Error("API_ERROR_" + res.status); return res.json(); }) .then(function(data) { typing.style.display = "none"; if (!data || !data.candidates || !data.candidates[0] || !data.candidates[0].content || !data.candidates[0].content.parts[0]) { handleFallback(); return; } var botReply = data.candidates[0].content.parts[0].text; // Lọc sạch triệt để markdown sao (**), gạch chéo anh/chị và hashtag botReply = botReply.replace(/\*\*/g, "").replace(/\*/g, "").replace(/#[^\s]+/g, "").replace(/anh\/chị/gi, "anh chị").trim(); chatHistory.push({ role: "model", parts: [{ text: botReply }] }); var botBox = document.createElement("div"); botBox.className = "hungai-message hungai-msg-bot"; wrap.insertBefore(botBox, typing); // TỰ ĐỘNG BẬT THẺ ZALO MINI NGAY DƯỚI TIN NHẮN KHI NÓI ĐẾN KẾT NỐI ZALO / ANH HÙNG var shouldShowZalo = /kết nối|zalo|anh hùng|liên hệ/i.test(botReply); speakAndType(botBox, botReply, function() { if (shouldShowZalo) { renderMiniZaloCard(wrap); } }); }) .catch(function(err) { handleFallback(); }); } // Khai báo GLOBAL window.hungaiDoSend ngay lập tức để Enter và nút bấm Gửi hoạt động 100% window.hungaiDoSend = hungaiDoSend; // Gắn trực tiếp Event Listener vào ô input và nút Gửi var inputEl = document.getElementById("hungai-input-field"); if (inputEl) { inputEl.addEventListener("keydown", function(e) { if (e.key === "Enter") { e.preventDefault(); hungaiDoSend(); } }); inputEl.addEventListener("input", cancelZaloTimers); } var sendBtnEl = document.querySelector(".hungai-send-btn"); if (sendBtnEl) { sendBtnEl.addEventListener("click", function(e) { e.preventDefault(); hungaiDoSend(); }); } var micBtnEl = document.getElementById("hungai-mic-button"); if (micBtnEl) { micBtnEl.addEventListener("click", resetZaloFollowupTimers); } // Sau đúng 5 giây ở trang trong thì khung trợ lý mới tự động mở lên setTimeout(function() { if (!isOpen && !userHasInteracted) { hungaiOpenChat(true); } }, 5000); })(); </script> <style id="hungai-super-contrast-fix"> html, body, .wrapper-main-content, .content-list, #articlecontent, article { background-color: #FFFFFF !important; } #articlecontent, #articlecontent *, article, article * { color: #111827 !important; opacity: 1 !important; filter: none !important; visibility: visible !important; } #articlecontent article h1.title, #articlecontent h1 { color: #0A0A0C !important; font-weight: 800 !important; font-size: 26px !important; opacity: 1 !important; } #articlecontent h2, #articlecontent h2 span { color: #92400E !important; font-weight: 700 !important; } #articlecontent strong { color: #000000 !important; font-weight: 800 !important; } #articlecontent .meta { color: #6B7280 !important; } </style> <script id="hungai-antifade-enforcer"> (function() { function enforceDarkText() { var root = document.getElementById("articlecontent"); if (!root) return; root.style.setProperty("background-color", "#FFFFFF", "important"); var els = root.querySelectorAll("*"); for (var i = 0; i < els.length; i++) { var el = els[i]; var styleCol = el.style.color || ""; if (styleCol.indexOf("204") !== -1 || styleCol.indexOf("ccd3e4") !== -1 || styleCol.indexOf("rgb(204, 211, 228)") !== -1) { if (el.tagName === "H1") { el.style.setProperty("color", "#0A0A0C", "important"); } else if (el.tagName === "H2") { el.style.setProperty("color", "#92400E", "important"); } else { el.style.setProperty("color", "#1F2937", "important"); } } } } document.addEventListener("DOMContentLoaded", function() { enforceDarkText(); setTimeout(enforceDarkText, 50); setTimeout(enforceDarkText, 300); setTimeout(enforceDarkText, 1000); setTimeout(enforceDarkText, 2500); }); window.addEventListener("load", enforceDarkText); setInterval(enforceDarkText, 500); })(); </script> <style id="hungai-unified-header-footer"> @import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap'); /* 1. ĐỈNH TRANG CỐ ĐỊNH KHI CUỘN (STICKY HEADER) */ header.pr-header-exact, header.pr-header { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; width: 100% !important; height: 70px !important; background: #111317 !important; border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important; z-index: 999999 !important; box-sizing: border-box !important; } body { padding-top: 70px !important; } @media (max-width: 768px) { header.pr-header-exact, header.pr-header { height: 60px !important; padding: 0 16px !important; } body { padding-top: 60px !important; } } /* 2. ẨN HOÀN TOÀN CÁC PHẦN CHÂN TRANG CŨ TRẮNG */ .ai-foot, footer, .site-footer, .footer-wrap, section.special, .wrp-special, .items-address, .items-contact { display: none !important; } /* 3. CHÂN TRANG ĐỒNG BỘ 4 CỘT CHUẨN ĐẸP 100% */ #hungai-global-footer-root { background: #0B0E14 !important; color: #CBD5E1 !important; font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important; padding: 60px 0 35px !important; margin-top: 70px !important; border-top: 1px solid rgba(255, 255, 255, 0.08) !important; box-sizing: border-box !important; position: relative !important; width: 100% !important; clear: both !important; display: block !important; } .hungai-footer-container { max-width: 1200px !important; margin: 0 auto !important; padding: 0 24px !important; box-sizing: border-box !important; } .hungai-footer-grid { display: grid !important; grid-template-columns: 2fr 1fr 1fr 1.2fr !important; gap: 40px !important; padding-bottom: 40px !important; border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important; } .hungai-footer-col h4 { font-family: 'Oswald', sans-serif !important; font-size: 18px !important; font-weight: 700 !important; letter-spacing: 0.08em !important; color: #FFFFFF !important; text-transform: uppercase !important; margin: 0 0 18px 0 !important; } .hungai-footer-col p { font-size: 14px !important; line-height: 1.7 !important; color: #CBD5E1 !important; margin: 0 0 12px 0 !important; } .hungai-footer-col ul { list-style: none !important; padding: 0 !important; margin: 0 !important; display: flex !important; flex-direction: column !important; gap: 12px !important; } .hungai-footer-col ul li { margin: 0 !important; padding: 0 !important; } .hungai-footer-col ul a { color: #94A3B8 !important; text-decoration: none !important; font-size: 14px !important; transition: color 0.2s ease !important; display: inline-block !important; } .hungai-footer-col ul a:hover { color: #FFFFFF !important; } .hungai-footer-bottom { max-width: 1200px !important; margin: 25px auto 0 !important; display: flex !important; align-items: center !important; justify-content: space-between !important; font-size: 13px !important; color: #64748B !important; box-sizing: border-box !important; } .hungai-btn-top { background: rgba(255, 255, 255, 0.08) !important; color: #E2E8F0 !important; border: 1px solid rgba(255, 255, 255, 0.15) !important; padding: 8px 18px !important; border-radius: 6px !important; font-size: 13px !important; font-weight: 600 !important; cursor: pointer !important; text-decoration: none !important; display: inline-flex !important; align-items: center !important; gap: 6px !important; transition: all 0.2s ease !important; } .hungai-btn-top:hover { background: #FFFFFF !important; color: #0A0A0C !important; } @media (max-width: 900px) { .hungai-footer-grid { grid-template-columns: 1fr 1fr !important; gap: 30px !important; } } @media (max-width: 600px) { .hungai-footer-grid { grid-template-columns: 1fr !important; gap: 25px !important; } .hungai-footer-bottom { flex-direction: column !important; gap: 14px !important; text-align: center !important; } } </style> <template id="hungai-footer-template"> <div id="hungai-global-footer-root"> <div class="hungai-footer-container"> <div class="hungai-footer-grid"> <div class="hungai-footer-col"> <h4>HÙNG TRÍ TUỆ</h4> <p>Hệ sinh thái kết hợp hoàn hảo giữa năng lực In ấn Sản xuất thực tế (Hùng IN) và Công nghệ Tự động hóa AI tiên phong (Hùng AI).</p> <p style="margin-top: 14px; color: #FFFFFF; font-weight: 500;"> 📍 20 Hàng Đào – Phường Hoàn Kiếm – Hà Nội </p> </div> <div class="hungai-footer-col"> <h4>HÙNG IN</h4> <ul> <li><a href="https://trituemedia.vn/hung-in.html">Bao bì & Hộp quà</a></li> <li><a href="https://tritGiải pháp thiết kế sáng tạo và sản xuất in ấn công nghiệp: Hộp quà tặng, bao bì cao cấp, catalogue, tem nhãn decal chuẩn xác từng milimet.
DỊCH VỤ THIẾT KẾ & IN ẤN