Troubleshooting
Common issues and solutions for inHotel Focus Chat integration.
Installation Issues
Chat Widget Doesn't Appear
Symptoms:
- No chat widget visible on page
- Console shows no errors
Solutions:
-
Check Script Loading
<!-- Ensure script is loaded before using the element -->
<script src="https://embed.agents.inhotel.io/focus-chat/latest/focus-chat.min.js"></script>
<focus-chat agent_card_url="..."></focus-chat> -
Verify Agent Card URL
- Open the agent card URL directly in browser
- Ensure it returns valid JSON
- Check for 404 or 500 errors
-
Check Browser Console
- Look for JavaScript errors
- Check for failed network requests
Script Loading Errors
Symptoms:
focus-chatelement not recognized- "Uncaught ReferenceError" errors
Solutions:
-
Verify CDN URL
<!-- Correct CDN URL -->
<script src="https://embed.agents.inhotel.io/focus-chat/latest/focus-chat.min.js"></script>
<!-- NOT this -->
<script src="https://embed.agents.inhotel.io/focus-chat/focus-chat.min.js"></script> -
Check Network Connectivity
- Verify CDN is accessible
- Check for corporate firewall blocking
-
Use Local Copy
<!-- Fallback to local file -->
<script src="path/to/focus-chat.min.js"></script>
CORS and Network Issues
CORS Errors
Symptoms:
Access to fetch at 'https://agent.example.com/card.json'
has been blocked by CORS policy
Solutions:
-
Server-Side CORS Headers
// Express.js example
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
}); -
Nginx Configuration
location /agent-card.json {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST';
} -
Apache Configuration
<Files "agent-card.json">
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST"
</Files>
Agent Card Loading Failed
Symptoms:
- Chat widget appears but shows loading indefinitely
- Network tab shows 404 or 500 errors for agent card
Solutions:
-
Verify URL
<!-- Check the URL is correct and accessible -->
<focus-chat agent_card_url="https://a44b44de-d6cb-409e-a1ff-3bc28aa95b4e.agents.inhotel.io/.well-known/agent-card.json"> -
Test Direct Access
# Test with curl
curl -v https://a44b44de-d6cb-409e-a1ff-3bc28aa95b4e.agents.inhotel.io/.well-known/agent-card.json -
Validate JSON
# Validate JSON syntax
cat agent-card.json | jq .
Chat Functionality Issues
Messages Not Sending
Symptoms:
- User can type but messages don't send
- Send button doesn't respond
Solutions:
-
Check Chat Endpoint
{
"url": "https://api.example.com/chat"
}Verify this endpoint accepts POST requests.
-
Test Endpoint Manually
curl -X POST https://api.example.com/chat \
-H "Content-Type: application/json" \
-d '{"message": "test"}' -
Check Network Tab
- Look for failed requests
- Check response status codes
No Response from Agent
Symptoms:
- Messages send successfully
- No response appears
Solutions:
-
Check Endpoint Response
// Endpoint should return JSON
{
"content": "Response message"
} -
Verify Response Format
// Correct format
app.post('/chat', (req, res) => {
res.json({
content: "Hello! How can I help you?"
});
}); -
Check Console for Errors
- Look for parsing errors
- Check for network timeouts
Streaming Not Working
Symptoms:
- Responses appear all at once instead of streaming
- Console shows streaming errors
Solutions:
-
Verify Server-Sent Events Support
// Server must support SSE
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive'
}); -
Check Content-Type
// Must use text/event-stream
res.setHeader('Content-Type', 'text/event-stream'); -
Disable Streaming Temporarily
{
"stream": false
}
Configuration Issues
Styling Not Applied
Symptoms:
- Chat widget appears with default styling
- Custom colors/fonts not showing
Solutions:
-
Check JSON Syntax
<!-- Ensure valid JSON -->
<focus-chat config='{"header_background_color": "#ff0000"}'> -
Verify Parameter Names
{
"header_background_color": "#3b82f6",
"user_message_background_color": "#3b82f6"
} -
Check CSS Specificity
- Shadow DOM isolates styles
- Use configuration parameters instead of external CSS
Context Not Working
Symptoms:
- Agent doesn't seem aware of page content
- Responses are generic
Solutions:
-
Check CSS Selector
{
"source_context": ".main-content"
}Ensure elements exist with this selector.
-
Verify Content Extraction
// Check if elements exist
console.log(document.querySelector('.main-content')); -
Test with Simple Selector
{
"source_context": "body"
}
Browser Compatibility Issues
Widget Not Working in Older Browsers
Symptoms:
- Widget doesn't appear in IE/older browsers
- Console shows "Custom elements not supported"
Solutions:
-
Check Browser Support
- Chrome 54+
- Firefox 63+
- Safari 10.1+
- Edge 79+
-
Add Polyfills (if needed)
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@2/webcomponents-loader.js"></script> -
Provide Fallback
<focus-chat agent_card_url="...">
<div>
<p>Chat requires a modern browser. Please update your browser or <a href="/contact">contact us</a>.</p>
</div>
</focus-chat>
Performance Issues
Memory Leaks
Symptoms:
- Browser memory usage increases over time
- Page becomes unresponsive
Solutions:
-
Check for Multiple Instances
<!-- Avoid multiple widgets with same config -->
<focus-chat agent_card_url="..."></focus-chat>
<!-- Don't duplicate --> -
Clear History Periodically
// Clear stored history if needed
sessionStorage.removeItem('inhotel_history_agentId_sectionKey');
Debug Mode
Enable detailed logging by checking browser console:
// Focus Chat logs with [InHotel] prefix
console.log('[InHotel] Widget initialized');
console.log('[InHotel] Context extracted: 150 characters');
console.log('[InHotel Streaming] Event received');
Common Log Messages
| Message | Meaning |
|---|---|
Widget initialized | Chat widget loaded successfully |
Agent card loaded | Agent configuration loaded |
Context extracted: X characters | Page context extracted |
Streaming connection established | Real-time streaming active |
History loaded: X messages | Previous conversation restored |
Getting Help
If you're still experiencing issues:
-
Check Browser Console
- Look for error messages
- Note any failed network requests
-
Verify Configuration
- Use a JSON validator for config
- Test agent card URL directly
-
Test with Minimal Example
<!DOCTYPE html>
<html>
<head>
<script src="https://embed.agents.inhotel.io/focus-chat/latest/focus-chat.min.js"></script>
</head>
<body>
<focus-chat agent_card_url="https://a44b44de-d6cb-409e-a1ff-3bc28aa95b4e.agents.inhotel.io/.well-known/agent-card.json"></focus-chat>
</body>
</html> -
Contact Support
- Provide browser version and OS
- Include console error messages
- Share minimal reproduction case
Frequently Asked Questions
Q: Can I use multiple chat widgets on one page?
A: Yes, but each should have a different agent_card_url or config to avoid conflicts.
Q: Does Focus Chat work with single-page applications?
A: Yes, the widget works with SPAs. You may need to reinitialize after route changes.
Q: Can I customize the widget beyond the provided parameters?
A: The widget uses Shadow DOM for isolation. Use the configuration parameters rather than external CSS.
Q: How do I clear conversation history?
A: Conversation history is automatically saved in your browser and clears when the session ends. You can also manually clear the conversation at any time using the Clear history button located at the top of the chat interface.