Run multiple AI-powered Discord bots simultaneously, each with their own persona and system prompt. Supports Ollama (local), OpenAI, and Grok as AI providers.
- Node.js v18+ or Bun
- A Discord application/bot token for each bot
- An API key for your chosen AI provider (or a running Ollama instance)
npm install
# or
bun installCopy the example keys file:
cp keys_ex.json keys.jsonThen fill in keys.json with your real tokens:
{
"discord": {
"mybotname": "YOUR_DISCORD_BOT_TOKEN"
},
"openai": "YOUR_OPENAI_API_KEY",
"grok": "YOUR_GROK_API_KEY"
}
keys.jsonis gitignored — never commit it.
Add a JSON file to the personas/ folder named after your bot (e.g. personas/mybot.json):
{
"name": "MyBot",
"discord_name": "mybotname",
"system_prompt": "You are MyBot, a helpful assistant.",
"provider_override": null,
"model_override": null
}| Field | Description |
|---|---|
name |
Display name used in conversation history |
discord_name |
Must match the key used in keys.json under discord |
system_prompt |
The AI system prompt defining the bot's personality |
provider_override |
Override the global provider ("ollama", "openai", "grok", or null) |
model_override |
Override the global model (e.g. "gpt-4o", or null) |
Add your bot's name to the bots array in config.json:
{
"bots": ["mybotname"]
}The name must match both the persona filename (personas/mybotname.json) and the discord key (keys.json → discord.mybotname).
- Sign up or log in at platform.openai.com
- Go to API keys → Create new secret key
- Copy the key into
keys.jsonunder"openai"
Note: OpenAI requires a paid balance to use the API. Add credits at platform.openai.com/settings/billing.
- Sign up or log in at console.x.ai
- Go to API Keys → Create API Key
- Copy the key into
keys.jsonunder"grok"
-
Download and install Ollama from ollama.com/download
-
Pull a model, e.g.:
ollama pull llama3.2
-
Ollama runs at
http://localhost:11434by default — no API key needed -
Browse available models at ollama.com/library
Set provider in config.json to ollama, openai, or grok, and fill in the relevant section:
{
"provider": "grok",
"ollama": {
"base_url": "http://localhost:11434",
"model": "llama3.2"
},
"openai": {
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini"
},
"grok": {
"base_url": "https://api.x.ai/v1",
"model": "grok-4-0709"
}
}For each bot:
- Go to discord.com/developers/applications
- Click New Application, give it a name
- Go to Bot → copy the token into
keys.json - Under Bot, enable Message Content Intent
- Go to OAuth2 → URL Generator, select
bot, then theSend MessagesandRead Message Historypermissions - Use the generated URL to invite the bot to your server
npm start
# or for auto-reload on file changes:
npm run devAll options live in config.json:
| Option | Values | Description |
|---|---|---|
provider |
ollama, openai, grok |
Default AI provider for all bots |
bots |
array of names | Which bots to start |
conversation.mode |
mention_only, all_messages |
When to respond — only when @mentioned, or to every message |
conversation.allowed_channels |
array of channel IDs | Restrict bots to specific channels (empty = all channels) |
conversation.respond_to_bots |
true / false |
Whether bots respond to other bots |
conversation.max_bot_chain |
number | Max consecutive bot messages before going silent (prevents infinite loops) |
conversation.max_history |
number | How many messages to keep in context per channel |
conversation.typing_indicator |
true / false |
Show "Bot is typing…" while generating a response |
- Create another Discord application and copy its token
- Add the token to
keys.jsonunder a new key:"discord": { "alice": "...", "bob": "..." } - Create
personas/bob.jsonwith its system prompt - Add
"bob"to thebotsarray inconfig.json - Restart the process — both bots will run in the same process