<div class="chat-messages" id="chatMessages">
<div class="message received">
Welcome to SpaChat! 🌸<br>
How can I help you today?<br>
<span class="timestamp">Just now</span>
</div>
</div>
<div class="typing-indicator" id="typingIndicator">💬 Assistant is typing...</div>
<div class="chat-input">
<input type="text" id="messageInput" placeholder="Type your wellness message..." maxlength="200">
<button onclick="sendMessage()">Send</button>
</div>
</div>
<script>
const chatMessages = document.getElementById('chatMessages');
const messageInput = document.getElementById('messageInput');
const typingIndicator = document.getElementById('typingIndicator');
// Wellness responses database
const wellnessResponses = [
"That sounds wonderful! 🌟 Take a deep breath and relax.",
"Your wellness journey is important! 💚",
"I'm here to support your self-care routine. 🌸",
"Remember to hydrate and take breaks! 💧",
"You deserve all the peace and tranquility. 🕊️",
"Mindfulness is a beautiful practice. ✨",
"Your mental health matters deeply. 💙",
"Let's create a calm space together. 🌿",
"Every small step toward wellness counts! 🌱",
"You're doing great on your journey! 🎯"
];
const spaServices = [
"💆♀️ Massage Therapy",
"🌸 Aromatherapy",
"🕯️ Candlelight Meditation",
"🧘♀️ Yoga Sessions",
"🍵 Herbal Tea Consultation",
"🌙 Sleep Wellness Program"
];
function getCurrentTime() {
return new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
}
function addMessage(text, isSent = false) {
const messageDiv = document.createElement('div');
messageDiv.className = `message ${isSent ? 'sent' : 'received'}`;
messageDiv.innerHTML = `${text}<br><span class="timestamp">${getCurrentTime()}</span>`;
chatMessages.appendChild(messageDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
function showTyping() {
typingIndicator.style.display = 'block';
chatMessages.scrollTop = chatMessages.scrollHeight;
}
function hideTyping() {
typingIndicator.style.display = 'none';
}
function getWellnessResponse(userMessage) {
const lowerMessage = userMessage.toLowerCase();
if (lowerMessage.includes('hello') || lowerMessage.includes('hi') || lowerMessage.includes('hey')) {
return "Hello there! 🌺 Welcome to our wellness space. How are you feeling today?";
}
if (lowerMessage.includes('stress') || lowerMessage.includes('tired') || lowerMessage.includes('exhausted')) {
return "I understand. Let's take a moment for yourself. 🌼 Would you like to hear about our relaxation services?";
}
if (lowerMessage.includes('massage') || lowerMessage.includes('spa') || lowerMessage.includes('relax')) {
const service = spaServices[Math.floor(Math.random() * spaServices.length)];
return `We offer ${service}! Our therapists are here to help you unwind. 🧘♀️`;
}
if (lowerMessage.includes('thank')) {
return "You're very welcome! 🙏 Remember, taking care of yourself is not selfish—it's essential. 💚";
}
if (lowerMessage.includes('bye') || lowerMessage.includes('goodbye')) {
return "Sending you peaceful vibes! 🌙 Take care and come back whenever you need wellness support. 🌸";
}
// Random wellness response
return wellnessResponses[Math.floor(Math.random() * wellnessResponses.length)];
}
async function sendMessage() {
const message = messageInput.value.trim();
if (!message) return;
// Add user message
addMessage(message, true);
messageInput.value = '';
// Show typing indicator
showTyping();
// Simulate thinking time
await new Promise(resolve => setTimeout(resolve, 1000 + Math.random() * 2000));
// Get and add response
hideTyping();
const response = getWellnessResponse(message);
addMessage(response);
}
// Allow Enter key to send
messageInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
sendMessage();
}
});
// Add some ambient messages to make it feel alive
setTimeout(() => {
addMessage("🌱 Just a gentle reminder: Your wellness journey is unique and beautiful. Take it one breath at a time.");
}, 3000);
setTimeout(() => {
addMessage("🕯️ Creating calm spaces for your mind and soul. How can we support your peace today?");
}, 8000);
</script>
Description
<title>SpaChat - Wellness Messaging</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; }[Enter feedback here]
Page URL
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/websockets?view=aspnetcore-9.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/websockets.md
Document ID
762efeed-010e-f422-03d0-22d6681b2851
Platform Id
3e06aef0-84df-6106-fb9c-2d43e7e95d19
Article author
@wadepickett
Metadata
Related Issues