Product & User Context
Send relevant product and user data so the assistant can answer with better context.
Context lets the assistant understand who the user is and what they are viewing.
Send context during init
window.LoopSmartAI.q.push([
"init",
{
agentId: "YOUR_AGENT_ID",
productContext: {
productCode: "SKU-123",
productName: "Premium Headphones",
category: "audio",
},
userContext: {
id: "user-456",
email: "user@example.com",
name: "Jane Doe",
},
},
]);Update context dynamically
Use these methods when page state changes in a SPA, after login, or after product navigation.
window.LoopSmartAI.setProductContext({
productCode: "SKU-999",
productName: "Travel Backpack",
});
window.LoopSmartAI.setUserContext({
id: "user-789",
membership: "premium",
});You can also update both in one call:
window.LoopSmartAI.updateContext(
{
productCode: "SKU-777",
},
{
id: "user-789",
},
);Recommended fields
Product context
| Field | Type | Notes |
|---|---|---|
productCode | string | Most useful identifier |
productName | string | User-friendly display name |
category | string | Optional but useful for hints |
price | number | Optional |
currency | string | Optional |
User context
| Field | Type | Notes |
|---|---|---|
id | string | Stable internal user ID |
customerId | string | Legacy alias used in older setups |
email | string | Optional if available |
name | string | Optional |
membership | string | Optional segment or plan value |
Data minimization
Only send the fields required for conversation quality. Avoid sensitive personal data.
Continue to JavaScript API.