Discord Integration Setup for Hermes Agent

Summary

The process for integrating the Hermes Agent with Discord involves configuring a bot application through the Discord Developer Portal, setting specific gateway intents, and provisioning environment variables on the Sokrates appliance. This integration is preferred over WhatsApp for development environments due to its lack of requirement for a dedicated phone number or QR code pairing.

Details

The setup of the Hermes Agent on Discord is a multi-step process involving external platform configuration and internal system environment management.

Discord Developer Portal Configuration

To enable the Hermes Agent to communicate via Discord, a new application must be created in the Discord Developer Portal. The following settings are required:

  1. Bot Identity: Create a bot user within the application. The “Public Bot” setting should be toggled OFF to prevent unauthorized servers from adding the agent.
  2. Privileged Gateway Intents: The agent requires specific data access to function. In the Bot tab, the following must be enabled:
    • Server Members Intent: Allows the agent to recognize users in the server.
    • Message Content Intent: Essential for the agent to read and respond to user prompts.
  3. Authentication: A Bot Token must be generated (via “Reset Token”) and securely stored for use in the environment configuration.
  4. Authorization URL: A manual invite URL is generated using the Application ID (found in the General Information tab). The required scope is bot + applications.commands with a permission integer of 274878286912. The resulting URL follows this format: https://discord.com/oauth2/authorize?client_id=YOUR_APP_ID&scope=bot+applications.commands&permissions=274878286912

Appliance Configuration

The Hermes Agent runs as a systemd service on the NixOS appliance (typically sokrates-dev or sokrates-box). It looks for credentials in a specific secrets directory that is isolated from the main application logic.

The environment file is located at: /var/lib/sokrates/secrets/hermes/hermes.env

The file must contain the following variables:

  • ANTHROPIC_API_KEY: The API key for the underlying LLM.
  • DISCORD_BOT_TOKEN: The token obtained from the Developer Portal.
  • DISCORD_ALLOWED_USERS: A comma-separated list of Discord User IDs authorized to interact with the bot. This acts as a primary security filter. User IDs are obtained by enabling “Developer Mode” in the Discord client and right-clicking a user profile.

Deployment and Validation

Once the environment file is populated, the agent must be restarted to pick up the changes:

sudo systemctl restart hermes-agent

The agent is considered “live” once it appears online in the Discord server and responds to messages from users listed in the DISCORD_ALLOWED_USERS variable.