This guide describes how to set up and configure the Discord adapter for Clawmini.
- A Discord account.
- A Clawmini daemon running locally (the adapter communicates with it via TRPC over Unix sockets).
- Go to the Discord Developer Portal.
- Click New Application.
- Give your application a name (e.g., "Clawmini-Bot") and click Create. (Optional: Set the App Icon using this default avatar image).
- In the left sidebar, click Bot.
- Under Bot Token, click Reset Token (or Copy Token) to retrieve your bot's token. Save this token securely; you will need it later.
- Scroll down to the Privileged Gateway Intents section.
- Enable Message Content Intent. This is required for the bot to read DM messages.
- Click Save Changes.
The adapter only responds to messages from a single authorized user. To find your Discord User ID:
- Open Discord and go to User Settings (the gear icon at the bottom left).
- Go to Advanced.
- Enable Developer Mode.
- Right-click on your profile picture or username in a server or DM and select Copy User ID.
Discord bots cannot initiate a DM conversation with a user unless the user has first interacted with the bot.
- In the Discord Developer Portal, go to OAuth2 -> URL Generator.
- Select the
botscope. - If prompted for an Installation Method, ensure you select Guild Install. The
botscope is not valid for "User Install" and will cause an error. - Select the
Send MessagesandRead Message Historypermissions under Bot Permissions. - Copy the generated URL and paste it into your browser.
- Select your personal server (or any server you share with the bot) to invite the bot.
- Once the bot is in a shared server, you can right-click the bot and select Message to start a DM conversation.
The adapter requires a configuration file with your bot token and user ID. You can generate a template configuration file by running the init command:
npx clawmini-adapter-discord initThis will create a config.json file at .clawmini/adapters/discord/config.json. Open this file and replace the placeholders with your actual bot token and user ID:
{
"botToken": "YOUR_DISCORD_BOT_TOKEN",
"authorizedUserId": "YOUR_DISCORD_USER_ID",
"chatId": "default",
"requireMention": false
}(Note: chatId defaults to "default". You can change this if you want the bot to associate with a different chat. requireMention defaults to false and can be set to true if you only want the bot to respond when explicitly mentioned).
Ensure the Clawmini daemon is running, then start the Discord adapter:
npx clawmini-adapter-discordThe adapter will now forward authorized Discord DM messages to your Clawmini daemon and vice versa.
By default, the adapter connects to a single chat (the one specified as chatId in your config.json). However, you can create new Discord channels (or use different DMs) to map to separate Clawmini chats.
- Create a new Text Channel in your Discord server (or open a new DM group).
- Invite the bot to the channel if necessary.
- Send the command
/agent [agent-id]to automatically create a new Clawmini chat with that agent and map it to the current Discord channel. - Alternatively, use
/chat [chat-id]to map that specific Discord channel to an existing Clawmini chat.
Note: Each Discord channel can only be mapped to one Clawmini chat, and each Clawmini chat can only be mapped to one channel/space across all adapters.