-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Closed
Labels
β Not TriagedSource - Docs.msDocs Customer feedback via GitHub IssueDocs Customer feedback via GitHub Issueaspnet-core/svcfundamentals/subsvc
Description
Description
<title>SpaChat - Wellness Messaging</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body {
font-family: 'Arial', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.chat-container {
width: 400px;
height: 600px;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
overflow: hidden;
}
.chat-header {
background: linear-gradient(45deg, #ff6b6b, #ffa502);
color: white;
padding: 20px;
text-align: center;
font-size: 1.5em;
font-weight: bold;
}
.chat-messages {
flex: 1;
padding: 20px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 15px;
}
.message {
max-width: 70%;
padding: 12px 16px;
border-radius: 20px;
animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.received {
background: #e3f2fd;
align-self: flex-start;
border-bottom-left-radius: 5px;
}
.sent {
background: #4caf50;
color: white;
align-self: flex-end;
border-bottom-right-radius: 5px;
}
.chat-input {
display: flex;
padding: 20px;
background: white;
border-top: 1px solid #eee;
}
.chat-input input {
flex: 1;
padding: 12px 16px;
border: 2px solid #e0e0e0;
border-radius: 25px;
outline: none;
font-size: 16px;
}
.chat-input input:focus {
border-color: #4caf50;
}
.chat-input button {
margin-left: 10px;
padding: 12px 20px;
background: #4caf50;
color: white;
border: none;
border-radius: 25px;
cursor: pointer;
font-weight: bold;
transition: background 0.3s;
}
.chat-input button:hover {
background: #45a049;
}
.timestamp {
font-size: 0.7em;
opacity: 0.7;
margin-top: 5px;
text-align: right;
}
.typing-indicator {
display: none;
padding: 10px;
color: #666;
font-style: italic;
}
</style>
πΏ SpaChat Wellness
<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>
[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
Metadata
- ID: a3b0cac1-adc7-434c-d867-6e28e39bdae7
- PlatformId: 3e06aef0-84df-6106-fb9c-2d43e7e95d19
- Service: aspnet-core
- Sub-service: fundamentals
Metadata
Metadata
Assignees
Labels
β Not TriagedSource - Docs.msDocs Customer feedback via GitHub IssueDocs Customer feedback via GitHub Issueaspnet-core/svcfundamentals/subsvc