The idea of running your own AI assistant used to sound like something reserved for research labs or large companies. Recently, that barrier has dropped. Tools like OpenClaw have made it possible for anyone with a laptop and some curiosity to run a personal AI agent locally.
This guide walks through the process of setting up OpenClaw on your own machine and connecting it to Discord. By the end, you will have an AI agent that lives on your system, remembers conversations, and can interact with you through Discord like a personal assistant that never logs out.
Understanding OpenClaw
OpenClaw began as a small experimental project and quickly grew into one of the fastest rising repositories in the open source space. It has gone through a few name changes, but the core idea has stayed the same. Instead of being just another chatbot that replies to prompts, it behaves like an agent that can take actions.
Once running, OpenClaw can browse the web, manage files, run terminal commands, and communicate through messaging platforms. It also keeps long term memory of conversations and preferences. Everything stays on your own machine, which means you decide what data exists and where it goes.
This local-first approach is what attracts many developers. Cloud assistants are convenient, but they also come with limitations such as usage caps, subscription costs, and questions about data storage. Running an AI agent locally removes most of those concerns.
What You Will Build
By following this guide, you will set up:
- A self-hosted OpenClaw AI agent running locally
- Discord integration for chatting with the agent
- Persistent memory stored on your system
- A dashboard to monitor and control the agent
The result is an AI assistant that can respond to you through Discord messages while running quietly in the background on your own hardware.
Why Self-Hosting an AI Agent Feels Different
Using a cloud chatbot feels temporary. Conversations disappear into servers you cannot see. Self-hosting changes that experience. When OpenClaw runs locally, it becomes part of your environment. It can access local files, remember projects, and respond with context from previous interactions.
The more you use it, the more it behaves like a long-term collaborator rather than a simple chatbot. With Discord integration, it also becomes accessible from anywhere without exposing your data to external storage.
Prerequisites
Before installing anything, make sure the basics are ready.
You need Node.js version 22 or higher. Check your version:
node --version
If Node.js is not installed or outdated, download the current version from nodejs.org or install through your package manager.
You also need an API key for a language model provider. OpenClaw works well with Claude, but other providers or local models can be used.
Finally, keep a Discord account ready since the agent will communicate through a Discord bot.
Installing OpenClaw
The simplest way to install OpenClaw is globally using npm:
npm install -g openclaw@latest
If you prefer keeping it inside a project folder:
mkdir openclaw
cd openclaw
npm init -y
npm install openclaw@latest
Verify installation:
openclaw --version
For local installation:
npx openclaw --version
If the version number appears, the installation worked correctly.
Building from Source (Optional)
If you want to customize or explore development builds:
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
pnpm ui:build
pnpm build
This approach is helpful for contributors or those who want deeper control over the code.
Running the Onboarding Wizard
OpenClaw includes a guided setup that configures most things automatically.
Global install:
openclaw onboard --install-daemon
Local install:
npx openclaw onboard --install-daemon
During onboarding, you will:
- Add your LLM API key
- Generate a secure gateway token
- Install OpenClaw as a background service
The daemon option ensures the agent starts automatically when your system boots.
Creating a Discord Bot
To interact with OpenClaw through Discord, create a bot from the Discord Developer Portal.
Steps:
- Open the Discord Developer Portal
- Create a new application
- Add a bot to the application
- Copy the bot token and store it securely
Enable these intents in bot settings:
- Message Content Intent
- Server Members Intent
Then generate an invite URL with permissions like reading messages and sending replies. Use the generated link to add the bot to your server.
Enable developer mode in Discord settings so you can copy:
- Server ID
- Channel ID
- User ID
These will be needed for configuration.
Configuring OpenClaw for Discord
OpenClaw stores its configuration in:
~/.openclaw/openclaw.json
You can also store sensitive values as environment variables:
export DISCORD_BOT_TOKEN=your_token_here
Example configuration:
{
"llm": {
"provider": "anthropic",
"apiKey": "YOUR_ANTHROPIC_API_KEY"
},
"channels": {
"discord": {
"enabled": true,
"token": "YOUR_DISCORD_BOT_TOKEN",
"dm": {
"enabled": true,
"policy": "pairing"
},
"guilds": {
"YOUR_GUILD_ID": {
"users": ["YOUR_USER_ID"],
"requireMention": true,
"channels": {
"general": {
"allow": true,
"requireMention": true
}
}
}
}
}
}
}
Replace placeholders with real values such as your API key, bot token, server ID, and user ID.
The pairing policy for DMs adds an approval step for security. You can also switch to open or allowlist modes depending on how private you want the bot to be.
Starting the Gateway
Once the configuration is complete, start the gateway:
openclaw gateway --port 18789
Or with local install:
npx openclaw gateway --port 18789
Open your browser and go to:
http://localhost:18789
This dashboard lets you monitor activity and manage the agent.
If you installed the daemon earlier, the gateway should start automatically at boot. You can check its status with system commands depending on your OS.
Testing the Discord Integration
Open Discord and go to the server where the bot was added. Mention the bot in a channel:
@YourBotName hello
If everything is configured correctly, the bot will reply through OpenClaw.
For direct messages, a pairing code may appear. Approve it using:
openclaw pairing approve discord <code>
Once paired, you can chat freely through DMs or channels.
Troubleshooting Tips
If the bot connects but stays silent:
- Confirm message content intent is enabled
- Check channel permissions
- Make sure you mention the bot if mention mode is enabled
Run diagnostics:
openclaw doctor
openclaw channels status --probe
These commands help identify configuration or permission issues.
What You Can Do After Setup
Once running, the agent can become part of your daily workflow.
You can ask for summaries of news or tasks, organize files, or perform quick research. It can monitor things and send alerts through Discord. Over time, its memory builds context around your habits and projects.
The experience feels less like using a tool and more like maintaining a persistent digital assistant that understands your environment.
Conclusion
Self-hosting an AI agent shifts control back to the user. Instead of relying entirely on cloud services, you get an assistant that lives within your own system and evolves with your usage. The setup requires some technical patience, but the result is a flexible and private AI companion that can be accessed from anywhere through Discord while remaining fully under your control.
Top comments (0)