Tools: How to Set Up a Personal AI Agent with OpenClaw and Discor

Tools: How to Set Up a Personal AI Agent with OpenClaw and Discor

Source: Dev.to

Understanding OpenClaw ## What You Will Build ## Why Self-Hosting an AI Agent Feels Different ## Prerequisites ## Installing OpenClaw ## Building from Source (Optional) ## Running the Onboarding Wizard ## Creating a Discord Bot ## Configuring OpenClaw for Discord ## Starting the Gateway ## Testing the Discord Integration ## Troubleshooting Tips ## What You Can Do After Setup ## Conclusion ## Reference 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. 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. By following this guide, you will set up: The result is an AI assistant that can respond to you through Discord messages while running quietly in the background on your own hardware. 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. Before installing anything, make sure the basics are ready. You need Node.js version 22 or higher. Check your 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. The simplest way to install OpenClaw is globally using npm: If you prefer keeping it inside a project folder: For local installation: If the version number appears, the installation worked correctly. If you want to customize or explore development builds: This approach is helpful for contributors or those who want deeper control over the code. OpenClaw includes a guided setup that configures most things automatically. During onboarding, you will: The daemon option ensures the agent starts automatically when your system boots. To interact with OpenClaw through Discord, create a bot from the Discord Developer Portal. Enable these intents in bot settings: 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: These will be needed for configuration. OpenClaw stores its configuration in: You can also store sensitive values as environment variables: Example configuration: 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. Once the configuration is complete, start the gateway: Or with local install: Open your browser and go to: 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. Open Discord and go to the server where the bot was added. Mention the bot in a channel: If everything is configured correctly, the bot will reply through OpenClaw. For direct messages, a pairing code may appear. Approve it using: Once paired, you can chat freely through DMs or channels. If the bot connects but stays silent: These commands help identify configuration or permission issues. 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. 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. How to Self-Host OpenClaw for Clawdbot AI Agent Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse CODE_BLOCK: node --version Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: node --version CODE_BLOCK: node --version COMMAND_BLOCK: npm install -g openclaw@latest Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: npm install -g openclaw@latest COMMAND_BLOCK: npm install -g openclaw@latest CODE_BLOCK: mkdir openclaw cd openclaw npm init -y npm install openclaw@latest Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: mkdir openclaw cd openclaw npm init -y npm install openclaw@latest CODE_BLOCK: mkdir openclaw cd openclaw npm init -y npm install openclaw@latest CODE_BLOCK: openclaw --version Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: openclaw --version CODE_BLOCK: openclaw --version CODE_BLOCK: npx openclaw --version Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: npx openclaw --version CODE_BLOCK: npx openclaw --version COMMAND_BLOCK: git clone https://github.com/openclaw/openclaw.git cd openclaw pnpm install pnpm ui:build pnpm build Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: git clone https://github.com/openclaw/openclaw.git cd openclaw pnpm install pnpm ui:build pnpm build COMMAND_BLOCK: git clone https://github.com/openclaw/openclaw.git cd openclaw pnpm install pnpm ui:build pnpm build CODE_BLOCK: openclaw onboard --install-daemon Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: openclaw onboard --install-daemon CODE_BLOCK: openclaw onboard --install-daemon CODE_BLOCK: npx openclaw onboard --install-daemon Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: npx openclaw onboard --install-daemon CODE_BLOCK: npx openclaw onboard --install-daemon CODE_BLOCK: ~/.openclaw/openclaw.json Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: ~/.openclaw/openclaw.json CODE_BLOCK: ~/.openclaw/openclaw.json CODE_BLOCK: export DISCORD_BOT_TOKEN=your_token_here Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: export DISCORD_BOT_TOKEN=your_token_here CODE_BLOCK: export DISCORD_BOT_TOKEN=your_token_here CODE_BLOCK: { "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 } } } } } } } Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: { "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 } } } } } } } CODE_BLOCK: { "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 } } } } } } } CODE_BLOCK: openclaw gateway --port 18789 Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: openclaw gateway --port 18789 CODE_BLOCK: openclaw gateway --port 18789 CODE_BLOCK: npx openclaw gateway --port 18789 Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: npx openclaw gateway --port 18789 CODE_BLOCK: npx openclaw gateway --port 18789 CODE_BLOCK: http://localhost:18789 Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: http://localhost:18789 CODE_BLOCK: http://localhost:18789 CODE_BLOCK: @YourBotName hello Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: @YourBotName hello CODE_BLOCK: @YourBotName hello CODE_BLOCK: openclaw pairing approve discord <code> Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: openclaw pairing approve discord <code> CODE_BLOCK: openclaw pairing approve discord <code> CODE_BLOCK: openclaw doctor openclaw channels status --probe Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: openclaw doctor openclaw channels status --probe CODE_BLOCK: openclaw doctor openclaw channels status --probe - 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 - Add your LLM API key - Generate a secure gateway token - Install OpenClaw as a background service - Open the Discord Developer Portal - Create a new application - Add a bot to the application - Copy the bot token and store it securely - Message Content Intent - Server Members Intent - Confirm message content intent is enabled - Check channel permissions - Make sure you mention the bot if mention mode is enabled