Introduction
In this tutorial, you'll learn how to create and customize a simple AI chatbot character similar to Microsoft's Mico using Python and basic web technologies. While Microsoft has moved Mico to their Learn Live platform, we'll build a foundational understanding of how chatbot avatars work and how to implement them in your own projects.
This tutorial will teach you:
- How to create a basic chatbot interface
- How to integrate character animations or visual elements
- How to simulate voice interaction with text-to-speech
Prerequisites
To follow this tutorial, you'll need:
- A computer with internet access
- Python 3.6 or higher installed
- Basic understanding of HTML and CSS
- Text editor (like VS Code or Sublime Text)
Step-by-Step Instructions
Step 1: Set up your development environment
First, we need to create a project folder and set up the basic files we'll need. Open your terminal or command prompt and run these commands:
mkdir chatbot_project
cd chatbot_project
This creates a new folder called 'chatbot_project' where we'll build our chatbot interface.
Step 2: Create the main HTML file
Create a file called index.html in your project folder:
<!DOCTYPE html>
<html>
<head>
<title>My AI Chatbot</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="chat-container">
<div class="chat-header">
<h2>My AI Assistant</h2>
</div>
<div class="chat-messages" id="chatMessages">
<div class="message bot-message">
Hello! I'm your AI assistant. How can I help you today?
</div>
</div>
<div class="chat-input">
<input type="text" id="userInput" placeholder="Type your message here...">
<button onclick="sendMessage()">Send</button>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
This creates the basic structure of our chatbot interface with a header, message area, and input field.
Step 3: Add basic styling
Create a file called style.css in your project folder:
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f0f0f0;
}
.chat-container {
width: 400px;
height: 500px;
border: 1px solid #ccc;
border-radius: 10px;
background-color: white;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
}
.chat-header {
background-color: #4CAF50;
color: white;
padding: 15px;
border-radius: 10px 10px 0 0;
}
.chat-messages {
flex: 1;
padding: 15px;
overflow-y: auto;
display: flex;
flex-direction: column;
}
.message {
margin: 10px 0;
padding: 10px;
border-radius: 10px;
max-width: 80%;
}
.user-message {
background-color: #e3f2fd;
align-self: flex-end;
}
.bot-message {
background-color: #f5f5f5;
align-self: flex-start;
}
.chat-input {
display: flex;
padding: 15px;
border-top: 1px solid #eee;
}
#userInput {
flex: 1;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
margin-left: 10px;
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
This CSS file styles our chatbot interface to look clean and professional.
Step 4: Create the JavaScript functionality
Create a file called script.js in your project folder:
function sendMessage() {
const userInput = document.getElementById('userInput');
const message = userInput.value;
if (message.trim() === '') return;
// Add user message to chat
addMessage(message, 'user');
// Clear input
userInput.value = '';
// Simulate bot response after a short delay
setTimeout(() => {
const responses = [
"I understand. Can you tell me more about that?",
"That's interesting! How can I help with that?",
"Thanks for sharing. What else would you like to know?",
"I'm here to help. What specifically do you need?"
];
const randomResponse = responses[Math.floor(Math.random() * responses.length)];
addMessage(randomResponse, 'bot');
}, 1000);
}
function addMessage(message, sender) {
const chatMessages = document.getElementById('chatMessages');
const messageDiv = document.createElement('div');
messageDiv.className = `message ${sender}-message`;
messageDiv.textContent = message;
chatMessages.appendChild(messageDiv);
// Scroll to bottom
chatMessages.scrollTop = chatMessages.scrollHeight;
}
// Allow sending messages with Enter key
const userInput = document.getElementById('userInput');
userInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
sendMessage();
}
});
This JavaScript handles sending messages, displaying them in the chat, and simulating responses from the AI.
Step 5: Add character animation (simulating Mico)
Let's add a simple animated character to our chatbot. Add this to your style.css file:
.character-container {
display: flex;
justify-content: center;
margin: 10px 0;
height: 100px;
}
.character {
width: 80px;
height: 80px;
background-color: #FFD700;
border-radius: 50%;
position: relative;
animation: bounce 2s infinite;
}
.character::before {
content: '';
position: absolute;
width: 20px;
height: 20px;
background-color: #000;
border-radius: 50%;
top: 25px;
left: 15px;
}
.character::after {
content: '';
position: absolute;
width: 20px;
height: 20px;
background-color: #000;
border-radius: 50%;
top: 25px;
right: 15px;
}
@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
Then update your index.html to include the character:
<div class="chat-container">
<div class="chat-header">
<h2>My AI Assistant</h2>
<div class="character-container">
<div class="character"></div>
</div>
</div>
<div class="chat-messages" id="chatMessages">
<div class="message bot-message">
Hello! I'm your AI assistant. How can I help you today?
</div>
</div>
<div class="chat-input">
<input type="text" id="userInput" placeholder="Type your message here...">
<button onclick="sendMessage()">Send</button>
</div>
</div>
This creates a yellow circular character with eyes that bounces, similar to Mico's style.
Step 6: Test your chatbot
Open your index.html file in a web browser to test your chatbot. Type messages and see how it responds. The character should bounce as you chat.
Summary
In this tutorial, you've learned how to create a basic chatbot interface with a visual character element similar to Microsoft's Mico. You've built:
- A responsive chat interface with HTML and CSS
- Interactive message handling with JavaScript
- A simple animated character that responds to user interaction
This foundation demonstrates how chatbot avatars work and how you can customize them for your own applications. While this is a simplified version, it shows the core concepts behind creating interactive AI interfaces like the ones you see in Microsoft Copilot.



