Discord Integration¶
Connect your Idun agent to Discord so users can interact with it via slash commands.
Prerequisites¶
- A running Idun agent (engine)
- A Discord account
- Your engine must be publicly reachable (use ngrok for local development)
1. Create a Discord Application¶
- Go to the Discord Developer Portal
- Click New Application and give it a name
- On the General Information page, copy:
- Application ID
- Public Key
2. Create a Bot¶
- Go to the Bot tab
- Click Reset Token to generate a Bot Token — copy it immediately (it's only shown once)
3. Invite the Bot to Your Server¶
- Go to OAuth2 → URL Generator
- Select scopes:
bot,applications.commands - Select bot permissions:
Send Messages - Copy the generated URL, open it in your browser, and select your server
- To get your Guild ID: enable Developer Mode in Discord settings (User Settings → Advanced → Developer Mode), then right-click your server name → Copy Server ID
4. Configure the Integration¶
Add the Discord integration to your engine config:
integrations:
- provider: "DISCORD"
enabled: true
config:
bot_token: "MTI..."
application_id: "123456789012345678"
public_key: "abcdef1234567890..."
guild_id: "987654321098765432" # optional, scopes commands to a single server
Or configure it through the Manager UI on the Integrations page.
| Field | Description |
|---|---|
bot_token |
Bot token from step 2 |
application_id |
Application ID from step 1 |
public_key |
Public key from step 1 (used for Ed25519 signature verification) |
guild_id |
(Optional) Your Discord server ID. If set, slash commands are scoped to this server and appear instantly |
5. Set the Interactions Endpoint URL¶
- Make sure your engine is running and publicly reachable
- In the Discord Developer Portal, go to General Information
- Set Interactions Endpoint URL to:
https://<your-domain>/integrations/discord/webhook
Discord will send a PING request to verify the endpoint. The engine handles this automatically.
6. Register a Slash Command¶
Discord doesn't create commands automatically — you need to register them via the Discord API.
Register a guild command (appears instantly in your server):
curl -X POST \
"https://discord.com/api/v10/applications/{APPLICATION_ID}/guilds/{GUILD_ID}/commands" \
-H "Authorization: Bot {BOT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "ask",
"description": "Ask the agent a question",
"options": [
{
"name": "query",
"description": "Your question",
"type": 3,
"required": true
}
]
}'
Replace {APPLICATION_ID}, {GUILD_ID}, and {BOT_TOKEN} with your values.
Note
"type": 3 means a STRING option. The engine extracts this as the query text sent to your agent.
Tip
To register a global command (available in all servers the bot is in), omit /guilds/{GUILD_ID} from the URL. Global commands can take up to 1 hour to appear.
7. Test It¶
- Go to your Discord server
- Type
/ask query: Hello - The bot shows a "thinking..." indicator (deferred response), then replies with your agent's answer
How It Works¶
- User sends
/ask query: ...in Discord - Discord POSTs the interaction to your engine's webhook
- Engine verifies the Ed25519 signature
- Engine immediately defers the response (Discord requires a reply within 3 seconds)
- Engine invokes the agent asynchronously with the query text
-
Engine edits the deferred message with the agent's reply
-
Session tracking: The Discord user ID is used as the session ID, so conversation context is maintained per user
- Message limit: Discord messages are capped at 2000 characters — longer replies are truncated