SkillfulAI
  • Skillful AI
    • Welcome
    • About us
    • Ecosystem
  • Web SDK
    • Overview
    • Getting Started
      • Installation
      • Quick Start
      • Authentication
    • SDK Reference
    • Templates
      • Telegram Bot Template
      • Express Server Template
        • API Reference
      • Discord Bot Template
        • ProActive Mode
      • Kick Stream Bot
        • Getting Started
          • Installation
          • Quick Start
        • Create Commands
        • Advanced Configurations
  • Unity Gaming SDK
    • Overview
    • Getting Started
      • Installation
      • Authentication
    • Services
      • Skillful Agents
        • Overview
        • Quick Start
        • Service Reference
      • Smart NPCs
        • Overview
        • Quick Start
        • Service Reference
      • Skillful Inference
        • Overview
        • Quick Start
        • Service Reference
          • Question Answering
          • Sentence Similarity
          • Speech Recognition
          • Text Classification
          • Text Generation
          • Text Summary
          • Text-To-Image
          • Zero Shot Classification
          • Translation (Localization)
    • Audio Recorder
    • Additional Utilities
Powered by GitBook
On this page
  • Build An Express API Server
  • Why Use This Template?
  • Getting Started
  • Using Your API
  • What's Included Out of the Box
  • Next Steps

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?

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

Let's turn your Skillful AI agent into an API server in four simple steps.

1. Create Your Project

Using 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 -y

2. Install the Template

Our template includes everything you need for a production-ready server:

npm install @skillfulai/express-template

3. Configure Your Server

Create 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=3000

4. Launch Your Server

Start your server with:

node index.js

You'll see a confirmation message that your server is running and your agent is ready to accept requests.

Using Your API

Here'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

  • Rate limiting to protect your server from overuse

  • Error handling to prevent server crashes

  • Request validation to ensure proper data

Monitoring

  • Request logging to track usage

  • Health endpoints to monitor server status

  • Error tracking for debugging

Agent Management

  • Easy agent switching

  • Conversation history tracking

  • Skill discovery endpoints

Next Steps

Your 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

Remember, this is just the beginning. The Express template provides a foundation that you can build upon to create powerful AI-enabled applications.

PreviousTelegram Bot TemplateNextAPI Reference

Last updated 3 months ago

Join our for support

Discord community