Platform Hopper: Guide (Discord AI Chatbot)
◀ Back to Buddy List
How to Deploy an AI Character Chatbot to Discord
By loamy ยท June 2026 ยท Estimated time: ~1.5 hours
Why a Discord Bot?
Discord is where a huge chunk of the AI character chat community already hangs out. Running your own AI character as a Discord bot means your friends can interact with it in real time, in channels, in threads, in DMs. It's a shared experience in a way that solo web chatbots aren't.

The setup is different from a web app. Instead of deploying to Vercel, you're running a bot process that connects to Discord's gateway and listens for messages. Claude.ai handles building the whole thing for you: you just describe the character and the behavior you want in plain English.

This guide uses all free tools. The only potential cost is if you choose a paid AI model through OpenRouter, but there are free model options too.
๐Ÿ“น Video Tutorial
๐ŸŽฌ Video tutorial coming soon
Prefer video? This walkthrough covers every step below. Subscribe to Platform Hopper on YouTube for more guides.
What You'll Need
Discord A Discord account and a server where you have admin/manage permissions. discord.com
Discord Developer Portal discord.com/developers/applications. This is where you create your bot application. Free.
Claude.ai Free account at claude.ai. This writes the bot code for you. No coding knowledge needed.
OpenRouter Free account at openrouter.ai. API access to AI models.
GitHub Free account at github.com/signup. Optional but recommended for version control.
Node.js Download from nodejs.org (LTS version). Required to run the bot on your computer.
Step 1: Create a Discord Application
Go to the Discord Developer Portal and click New Application. Give it your character's name.

Once created:
Go to the Bot tab on the left sidebar
Click Add Bot (if it's not already created)
Under the bot's username, click Reset Token and copy the token. Save this somewhere safe, you'll need it soon.
Scroll down to Privileged Gateway Intents and enable Message Content Intent (this lets your bot read messages in channels)

Important: Never share your bot token publicly. Anyone with it can control your bot. If you accidentally leak it, reset it immediately in the Developer Portal.
Step 2: Get Your OpenRouter API Key
If you don't already have an OpenRouter account, sign up at openrouter.ai.

Go to Keys in your dashboard and create a new API key. Copy it.

You now have two secrets:
Discord Bot Token (from Step 1)
OpenRouter API Key (from this step)
Step 3: Write Your Character Definition
Before building the bot, define your character. If you've used Character AI, Janitor AI, or any of the platforms on this site, you know the drill. The difference here is that instead of filling in separate boxes, you'll write everything into one block of text.

You can write one from scratch, or copy a character definition you already have from another platform and adapt it. See the web chatbot guide for a full character definition template with tips.

The short version: include a name, personality traits, backstory, speaking style, 2-3 example messages showing how the character actually talks, and a list of things the character would never do.

Discord-specific tip: Discord messages tend to be shorter and more casual than web chat. Mention in your character definition that responses should be kept to 1-3 paragraphs max, and that the character should match Discord's conversational energy.
Step 4: Ask Claude to Build the Bot
Go to claude.ai and start a new conversation. Paste in a prompt like this, with your character definition included:

Build me a Discord bot using discord.js that acts as an AI character. Here's what I need: - Bot responds when mentioned (@botname) or when someone sends a DM - Use OpenRouter API for AI responses (environment variable: OPENROUTER_API_KEY) - Use a free model from OpenRouter - The system prompt should keep the character in-character at all times - Maintain conversation context per-channel (last 20 messages) - Discord bot token comes from environment variable: DISCORD_TOKEN - Include a .env.example file showing what variables are needed - Add a simple status message like "Roleplaying as [character name]" - Keep responses under 2000 characters (Discord's message limit) Here is my character definition: [PASTE YOUR CHARACTER DEFINITION HERE]

Claude will generate everything: the bot script, package.json, environment config, and a README. Save each file to a folder on your computer (or ask Claude to help you with that step).
Step 5: Invite the Bot to Your Server
Back in the Discord Developer Portal, go to your application and click OAuth2 in the left sidebar.

Under OAuth2 URL Generator:
In Scopes, check bot
In Bot Permissions, check: Send Messages, Read Message History, View Channels
Copy the generated URL at the bottom

Paste that URL into your browser. Discord will ask which server to add the bot to. Pick your server and authorize it.

The bot will appear in your server's member list as offline. That's normal, because it's not running yet.
Step 6: Run the Bot
Open your terminal, navigate to the folder where you saved the bot files, and set up your environment variables:

cp .env.example .env

Open the .env file in any text editor and paste in your Discord bot token and OpenRouter API key.

Then install and run:

npm install node index.js

You should see a message like Logged in as YourCharacterName#1234. The bot is now online in your Discord server. Go to a channel and mention it: it should respond in character.

To stop the bot: press Ctrl+C in your terminal.
Step 7: Keep It Running 24/7 (Optional)
Right now the bot only runs when your terminal is open. If you want it online all the time, you have a few options:

Cheap options:
Run on a spare computer: an old laptop or a Raspberry Pi works great. Just run node index.js and leave it on. This is the only truly free option for 24/7 hosting.
A small VPS: services like DigitalOcean, Hetzner, or Vultr offer servers starting at $4-5/month. This is the most reliable option for keeping a bot online.
Railway or Render: railway.app and render.com make deployment easy (connect your GitHub repo and it runs automatically) but both require a paid plan. Still affordable for a small bot.

Pro tip: Use a process manager like pm2 to keep the bot alive and auto-restart on crashes:

npm install -g pm2 pm2 start index.js --name "my-character-bot" pm2 save
Making It Your Own
Once the basic bot is running, go back to Claude.ai and ask for upgrades:

"Add a /character command" so users can switch between multiple characters
"Add per-user conversation memory" so the bot remembers past conversations with each person
"Add a /reset command" to clear the conversation context
"Make it respond to all messages in a specific channel" instead of only when mentioned
"Add typing indicator" so the bot shows as "typing..." while generating a response
"Add a cooldown" to prevent spam by rate-limiting responses
"Switch to a better model" by browsing OpenRouter's model list for paid options with better roleplay quality
FAQ
Is this free?
The bot itself is free to build and run locally. OpenRouter has free models. Discord doesn't charge for bots. The only cost is if you use paid AI models or paid hosting.

Can the bot talk in multiple channels?
Yes. By default it responds when mentioned in any channel it can see. You can configure it to be active in specific channels only, or to respond to all messages in designated roleplay channels.

Can multiple people talk to it at once?
Yes. The bot handles messages independently. With per-channel context, it tracks the conversation flow in each channel separately.

What if I want multiple characters?
Ask Claude to add a character selection system. You can have different characters in different channels, or let users switch with a slash command.

How do I update the character's personality?
Edit the system prompt in your code (Claude can help with this), then restart the bot. Changes take effect immediately.

Can I add content filters?
Yes. Ask Claude to add input/output filtering. You can block specific words, topics, or patterns. You control the moderation since it's your bot.

Can I use a character I already made on another platform?
Yes. Copy your character's description, personality, and any example dialogues from the other platform and paste them into your character definition. The format is slightly different but the content transfers directly.

Can I do this on mobile?
You can do most of it on mobile. Claude.ai, the Discord Developer Portal, GitHub, and OpenRouter all work in a mobile browser, so you can generate the code, create your bot application, and set up your repo from your phone. The part that requires a computer is actually running the bot (Steps 6 and 7), since you need Node.js and a terminal. One workaround: do all the setup and code generation on mobile, push to GitHub, then use a cloud hosting service like Railway or Render to deploy it without ever touching a terminal (both require a paid plan, but are affordable).
Guide: Discord AI Chatbot | Platform Hopper