Deploying Your AI Agent › Making Your Agent Accessible
AI Agent HandbookAll chapters Deploying Your AI Agent › Making Your Agent AccessibleOne section · Sections in this chapter7 / 10 ↓
Now that your agent is running somewhere, how do users interact with it? You have several options, depending on your needs.
Web Interface
The most straightforward approach is to build a simple web page that lets users type messages and see responses. You can use HTML, CSS, and JavaScript to create a chat interface that calls your agent's API.
Here's a minimal example:
<!DOCTYPE html>
<html>
<head>
<title>My AI Assistant</title>
</head>
<body>
<div id="chat"></div>
<input id="message" type="text" placeholder="Type a message...">
<button onclick="sendMessage()">Send</button>
<script>
async function sendMessage() {
const message = document.getElementById('message').value;
const response = await fetch('/chat', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({message: message})
});
const data = await response.json();
document.getElementById('chat').innerHTML +=
`<p><strong>You:</strong> ${message}</p>
<p><strong>Assistant:</strong> ${data.response}</p>`;
}
</script>
</body>
</html>This gives you a basic chat interface. You can enhance it with better styling, conversation history, typing indicators, and other features as needed.
Messaging Platform Integration
Another option is to integrate your agent with an existing messaging platform like Slack, Discord, or Telegram. Users interact with your agent through a familiar interface, and you don't need to build your own UI.
Most platforms provide APIs and webhooks for this. For example, with Slack, you'd create a bot application, configure it to receive messages, and have your agent respond to those messages through the Slack API.
API-Only Access
For some use cases, you might not need a user interface at all. If your agent is meant to be used by other programs or services, exposing it as an API is sufficient. Other developers can integrate your agent into their applications by making HTTP requests.