บริบทผู้ใช้ช่วยให้คุณส่งข้อมูลเกี่ยวกับผู้ใช้ที่ล็อกอินไปยัง AI เมื่อคุณให้บริบทผู้ใช้ AI สามารถทักทายผู้ใช้ด้วยชื่อ อ้างอิงรายละเอียดบัญชี และให้การตอบกลับที่เป็นส่วนตัวโดยไม่ต้องถามข้อมูลที่คุณมีอยู่แล้ว
สิ่งนี้สร้างประสบการณ์ที่ราบรื่นซึ่ง AI "รู้" เกี่ยวกับผู้ใช้อยู่แล้ว - แผนสมาชิก สถานะคำสั่งซื้อ คะแนนสะสม หรือข้อมูลที่เกี่ยวข้องอื่นๆ ที่คุณเลือกแชร์
// After user logs in or data loadswindow.Asyntai = window.Asyntai || {};
window.Asyntai.userContext = {
"Customer name": currentUser.name,
"Email": currentUser.email,
"Subscription plan": currentUser.subscription.planName,
"Cart total": cart.total,
"Loyalty points": currentUser.loyaltyPoints
};
// You can update it anytime - changes apply to the next messagewindow.Asyntai.userContext["Cart total"] = newTotal;
// Define a function to fetch user contextwindow.Asyntai = window.Asyntai || {};
window.Asyntai.fetchUserContext = function() {
return fetch('/api/your-user-context-endpoint/')
.then(function(response) { return response.json(); })
.then(function(data) {
window.Asyntai.userContext = data;
});
};
// The widget automatically calls this when the chat opens