Cortask

Discord Channel

The Discord adapter connects a Discord bot to a Cortask workspace using the discord.js library and the Discord Gateway WebSocket API.

Creating a Discord Bot

  1. Go to the Discord Developer Portal and click New Application.
  2. Under the Bot tab, click Reset Token to generate a bot token. Copy it.
  3. Enable these Privileged Gateway Intents on the Bot tab:
    • Message Content Intent
  4. Under OAuth2 > URL Generator, select the bot scope. For permissions, the bot needs at minimum: Send Messages, Read Message History, and View Channels.
  5. Use the generated URL to invite the bot to your server.

Configuring the Bot Token

In the Cortask UI, go to your workspace's channel settings and add a Discord channel. Paste the bot token.

Optional configuration:

  • Allowed guilds: Restrict the bot to specific Discord servers by guild ID. If empty, the bot responds in any server it has been invited to.
  • Allowed users: Restrict to specific Discord user IDs. If empty, any user can interact.
  • Respond to mentions: Whether the bot responds when @mentioned in a server channel (default: on).
  • Respond to DMs: Whether the bot responds to direct messages (default: on).

Starting and Stopping

  • Start: The adapter logs into the Discord Gateway and begins listening for messages. The bot appears as online.
  • Stop: The client is destroyed and the bot goes offline.

Server and DM Support

The bot supports two interaction modes:

  • Server messages: The bot only responds when directly @mentioned. The mention prefix is stripped before the message is sent to the agent.
  • Direct messages: Any DM to the bot is processed as a prompt (no mention needed).

Both modes can be independently enabled or disabled via configuration. A typing indicator is shown while the agent processes the request.

Mention Handling

When mentioned in a server channel, the bot strips its own <@botId> tag from the message text before forwarding it to the agent. If the resulting text is empty (a bare mention with no content), the message is ignored.

Limitations

  • Text only: The adapter processes text content from messages. Embeds, attachments, and other message types are ignored.
  • Message length: Discord enforces a 2,000-character limit per message. Long responses are automatically split.
  • No slash commands: The adapter uses message-based interaction, not Discord slash commands.
  • No thread support: The bot replies in the same channel or DM; it does not create or follow threads.