Skip to main content

Prerequisites

Node.js

Version 14.0.0 or higher

BoostGPT Account

Sign up at app.boostgpt.co

Step 1: Create a Project

1

Sign up

Go to app.boostgpt.co and create an account.
2

Create a project

Create your first project and copy the Project ID from settings.
3

Generate API key

Go to API Keys and generate a new key.
Keep your API key secure! Never commit it to version control.

Step 2: Install the SDK

npm install boostgpt @boostgpt/router

Step 3: Create Your First Bot

Create a .env file:
.env
BOOSTGPT_API_KEY=your_api_key_here
BOOSTGPT_PROJECT_ID=your_project_id_here
Create create-bot.js:
create-bot.js
import 'dotenv/config';
import { BoostGPT } from 'boostgpt';

const client = new BoostGPT({
  key: process.env.BOOSTGPT_API_KEY,
  project_id: process.env.BOOSTGPT_PROJECT_ID
});

// Create a bot
const result = await client.createBot({
  name: 'My First Bot',
  model: 'gpt-4o-mini',
  instruction: 'You are a helpful assistant. Be friendly and concise.',
  max_reply_tokens: 1000,
  status: 'active'
});

if (result.err) {
  console.error('Error:', result.err);
} else {
  console.log('Bot created!');
  console.log('Bot ID:', result.response.bot._id);
}
Run it:
node create-bot.js
Save the Bot ID from the output - you’ll need it for the next step.

Step 4: Deploy to Discord (Optional)

If you want to deploy your bot to Discord:
1

Create Discord application

Go to Discord Developer Portal and create a new application.
2

Create bot user

Go to the Bot section and create a bot user. Copy the bot token.
3

Enable intents

Enable MESSAGE CONTENT INTENT in the Bot settings.
4

Invite bot to server

Go to OAuth2 → URL Generator, select bot scope and Send Messages, Read Message History permissions. Use the generated URL to invite the bot.
Update your .env:
.env
BOOSTGPT_API_KEY=your_api_key_here
BOOSTGPT_PROJECT_ID=your_project_id_here
BOOSTGPT_BOT_ID=your_bot_id_here
DISCORD_TOKEN=your_discord_bot_token_here

Step 5: Run Your Multi-Channel Bot

Create bot.js:
bot.js
import 'dotenv/config';
import { Router, DiscordAdapter } from '@boostgpt/router';

const router = new Router({
  apiKey: process.env.BOOSTGPT_API_KEY,
  projectId: process.env.BOOSTGPT_PROJECT_ID,
  defaultBotId: process.env.BOOSTGPT_BOT_ID,
  adapters: [
    new DiscordAdapter({
      discordToken: process.env.DISCORD_TOKEN,
      replyInDMs: true,
      replyOnMention: true
    })
  ]
});

// Custom message handler (optional)
router.onMessage(async (message, context) => {
  console.log(`[${context.channel}] ${message.userName}: ${message.content}`);
  
  // Handle custom commands
  if (message.content === '/ping') {
    return 'Pong! 🏓';
  }
  
  // Let BoostGPT handle everything else
  return null;
});

// Start the router
await router.start();
console.log('✅ Bot is running!');

// Graceful shutdown
process.on('SIGINT', async () => {
  console.log('\n🛑 Shutting down...');
  await router.stop();
  process.exit(0);
});
Run your bot:
node bot.js
Your bot is now live on Discord! Message it or mention it in a channel.

What’s Next?

Common Issues

Make sure you’ve enabled MESSAGE CONTENT INTENT in the Discord Developer Portal under Bot settings.
Verify your API key and Project ID are correct. You can find them at app.boostgpt.co/settings.
Make sure you’ve installed all dependencies:
npm install boostgpt @boostgpt/router dotenv
Need help? Join our Discord community for support.