Skip to Content
Blocks

Discord

Make the bot

Follow Discord setup to create a bot. Enable Message Content Intent for text and follow-up messages.

Ask an agent to connect Discord. The agent calls discord_provision and gives you a claim link. Open the link and paste the bot token.

Add the bot to a server

Call discord_status after the bot connects. Open the link in setup.invite_url. Add the bot to your server. The link requests the permissions for your enabled features.

Find the server ID in discovered.guilds in discord_status. Add the server ID to a space in your config. A space holds the settings for one Discord server.

blocks:
  discord:
    use: discord
    spaces:
      home:
        guild_id: "100000000000000001"
        owner_ids: ["100000000000000002"]
        default_target: claude
    agents: {claude: [home]}

To set the owner, send the bot a direct message. Find your user ID in discovered.dm_users in discord_status. Put that ID in owner_ids.

Send from Discord

Mention the bot and give the target's short name, as in @swb claude check the build. With threads enabled, SwB can start a thread from your message and add you to it. SwB posts the answer there. Follow-up messages can reuse the thread's target. With personas enabled, eligible replies use the agent's name and picture.

Share with other people

Channels and targets are private by default. To give others access, share both the channel and the target. Use channel:<space>/<channel id> and target:<slug>. To give access to a specific user, add discord:<user id> to the access list.

Block settings

KeyUse
blocks.discordSettings for the Discord bot and its spaces
blocks.discord.useLoads the discord block
blocks.discord.enabledSet true to load the block or false to turn it off
blocks.discord.token_envName of the environment variable for the bot token
blocks.discord.application_idDiscord application ID for the invite link. SwB can also read the ID from Discord
blocks.discord.connectSet true to receive live events from Discord. Set false to test API calls on their own
blocks.discord.message_contentSet true to read message content, including follow-ups in threads. Turn on Message Content Intent in the Developer Portal
blocks.discord.threadsSet true to start a public thread for a reply in a server text channel
blocks.discord.personasSet true to use agent names and pictures on server posts sent through webhooks. Grant the bot Manage Webhooks
blocks.discord.avatarPicture file name for the bot profile
blocks.discord.ack_reactionEmoji to mark receipt of a message addressed to the bot. Set null to turn off this reaction
blocks.discord.dm_spaceSpace whose routing and owner settings apply to direct messages. The default is the first configured space
blocks.discord.dm_modeMode for direct messages from other people. Use watch to collect a digest or off to skip them
blocks.discord.daily_capDaily limit for each action that posts or replies through a tool. Set null to remove the limit
blocks.discord.refresh_minutesMinutes between updates to the target list. The default is 30
blocks.discord.target_aliasesMaps extra target names to existing targets
blocks.discord.agentsSpaces where each agent can post and receive events. Use * for all spaces

Use channel modes to wake an agent through a project route.

Spaces and channels

KeyUse
blocks.discord.spacesMaps names used in SwB to settings for Discord servers
blocks.discord.spaces.*.guild_idDiscord server ID. Omit it in one space for automatic matching. SwB needs exactly one available server owned by a space owner
blocks.discord.spaces.*.owner_idsDiscord user IDs treated as owners. The Discord app owner is the default
blocks.discord.spaces.*.knownMaps known Discord user IDs to display names
blocks.discord.spaces.*.default_targetTarget for a new message addressed to SwB with the target name omitted
blocks.discord.spaces.*.projectDefault SwB project for this space
blocks.discord.spaces.*.channel_projectsSets the SwB project by channel ID or by a name that starts with #
blocks.discord.spaces.*.modeMode for the space. A channel or thread mode can override it
blocks.discord.spaces.*.channelsSets a mode or more detailed settings by channel or thread ID
blocks.discord.spaces.*.channels.*.modeMode for one channel or thread
blocks.discord.spaces.*.channels.*.actionsActions allowed in triage mode, such as reply and notify_owner
blocks.discord.spaces.*.listenOlder setting for channel or thread IDs that use assist mode
blocks.discord.spaces.*.bot_posts_per_hourMaximum bot posts per thread in one hour. The default is 20

On this page