Build An Express API Server 
Build An Express API Server Transform your Skillful AI agent into a powerful API server in minutes. This template provides everything you need to expose your agent's capabilities through a robust, production-ready Express server.
Why Use This Template?
Why Use This Template?Running AI agents through an API opens up countless possibilities. You can:
- Build web applications that communicate with your agent 
- Create mobile apps with AI capabilities 
- Integrate your agent with other services 
- Build custom chatbots for various platforms 
Our Express template handles all the complexities of running an API server, including rate limiting, error handling, and request logging, letting you focus on building your application.
Getting Started
Getting StartedLet's turn your Skillful AI agent into an API server in four simple steps.
1. Create Your Project
1. Create Your ProjectUsing a code editor like Visual Studio Code, we can create a new project with:
# Create a project directory
mkdir my-agent-server
cd my-agent-server
# Create a new project
npm init -y2. Install the Template
2. Install the TemplateOur template includes everything you need for a production-ready server:
npm install @skillfulai/express-template3. Configure Your Server
3. Configure Your ServerCreate an index.js file:
const SkillfulServer = require('@skillfulai/express-template');
// Initialize with defaults - includes rate limiting and logging
const server = new SkillfulServer();
server.initialize();Create a .env file to store your credentials:
# Your Skillful AI API key from the dashboard
SKILLFUL_API_KEY=your_api_key
# The name of the agent you want to use
AGENT_NAME=Wojak
# The port your server will run on (optional, defaults to 3000)
PORT=30004. Launch Your Server
4. Launch Your ServerStart your server with:
node index.jsYou'll see a confirmation message that your server is running and your agent is ready to accept requests.
Using Your API
Using Your APIHere's how to interact with your agent using JavaScript:
Send a Message
// Using axios
const response = await axios.post('http://localhost:3000/chat', {
    message: 'Hello! Who are you?'
});
console.log(response.data.text);Get Agent Information
// Using axios
const agentInfo = await axios.get('http://localhost:3000/agent/info');What's Included Out of the Box
Your server comes with several built-in features:
Security
Security- Rate limiting to protect your server from overuse 
- Error handling to prevent server crashes 
- Request validation to ensure proper data 
Monitoring
Monitoring- Request logging to track usage 
- Health endpoints to monitor server status 
- Error tracking for debugging 
Agent Management
Agent Management- Easy agent switching 
- Conversation history tracking 
- Skill discovery endpoints 
Next Steps
Next StepsYour server is now running with the default configuration, which is perfect for most use cases. However, if you need to customize your server:
- Check our API Reference for detailed endpoint documentation 
- Join our Discord community for support 
Remember, this is just the beginning. The Express template provides a foundation that you can build upon to create powerful AI-enabled applications.
Last updated
