User Context

Pass user information to personalize AI conversations

Configure User Context
Standard & Pro Plans

Overview

User Context allows you to pass information about logged-in users to the AI. When you provide user context, the AI can greet users by name, reference their account details, and provide personalized responses without asking for information you already have.

This creates a seamless experience where the AI already "knows" about the user - their subscription plan, order status, loyalty points, or any other relevant data you choose to share.

How It Works

  1. Enable User Context in your dashboard settings
  2. Add JavaScript to your website that sets user data
  3. AI receives the context with each message the user sends
  4. AI personalizes responses using the provided information
AI Assistant
Where is my order?
Hi Sarah! I can see your order #4521 is currently in transit. It left our Frankfurt warehouse yesterday and should arrive by Friday.
Can I upgrade my plan?
Of course! You're currently on the Basic plan with 847 API calls remaining. I can help you upgrade to Pro for additional features and higher limits.

Implementation

Choose the approach that fits your setup:

Output user data directly from your server-side template:

<!-- After your Asyntai widget script -->
<script>
window.Asyntai = window.Asyntai || {};
window.Asyntai.userContext = {
    "Customer name": "<?php echo $user->name; ?>",
    "Email": "<?php echo $user->email; ?>",
    "Subscription plan": "<?php echo $user->plan; ?>",
    "Order status": "<?php echo $user->latest_order_status; ?>"
};
</script>

Set the context after your app loads user data:

// After user logs in or data loads
window.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 message
window.Asyntai.userContext["Cart total"] = newTotal;

Fetch user data only when the chat opens (best for performance):

// Define a function to fetch user context
window.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

Best for performance: The widget detects fetchUserContext and calls it automatically when the chat opens, so data is loaded only when needed.

You decide what to share. Pass only the data relevant to your use case - customer name, order status, subscription tier, cart contents, or any other info that helps the AI assist your users better. Use descriptive labels so the AI understands the context.

Example Use Cases

E-commerce

"I can see your order #4521 is currently in transit and should arrive by Friday."

SaaS

"You have 847 API calls remaining this month on your Pro plan."

Support

"I see you're a Gold member with 3 open tickets. How can I help?"

Education

"You're 78% through the JavaScript course. Ready to start Module 8?"

Hospitality

"Your booking for September 17th is confirmed. Check-in starts at 3 PM."

Healthcare

"Your next appointment with Dr. Smith is scheduled for Tuesday at 10 AM."

Important Notes

Optional - The chat works perfectly without user context. It's an enhancement for logged-in users.
Real-time - Context is sent with each message, so you can update it dynamically as user data changes.
Security - Never include passwords, credit card numbers, or other sensitive data. Only pass non-sensitive information.
5KB Limit - Keep your context concise. Include only what's needed for personalization.

Integration Status

After implementing, visit the User Context settings page to verify your integration is working. The status card will show:

  • Whether context is being received
  • Latest message with context
  • Preview of the context data being sent