What the backend needs
The Discord adapter inintegrations/discord_adapter.py uses discord.py and supports both slash commands and message-based queries.
Required values:
DISCORD_BOT_TOKENortoken- Optional
DISCORD_GUILD_IDfor faster slash command sync - Optional
admin_user_idsfor approval gating - Enable the Message Content Intent in the Discord developer portal
What Discord users can do
Slash Commands
Use
/query to ask a question and /refresh to refresh schema.DM Queries
Send a direct message to the bot and get a response back in DM.
Prefix Queries
In a server, use the
!dh prefix for text queries when you do not want slash commands.Approvals and RLHF
Approve / Reject destructive SQL and capture 👍 / 👎 feedback with buttons.
Setup steps
1
Create a Discord application
Create a bot in the Discord Developer Portal.
2
Enable intents and permissions
Turn on Message Content Intent and grant bot permissions to send messages, read messages, use slash commands, add reactions, and read message history.
3
Invite the bot
Add the bot to your server using the OAuth2 invite URL.
4
Set environment variables
Set
DISCORD_BOT_TOKEN and optionally DISCORD_GUILD_ID for quicker slash command syncing.5
Add admins
Pass Discord user IDs in
admin_user_ids so approval prompts only go to trusted users.Example
Backend behavior
- Session IDs are mapped as
discord:{user_id}. - Slash command
/queryruns a natural language query. - Slash command
/refreshrefreshes the schema cache. - DM messages and
!dhprefix messages route through the same pipeline. - Approval messages are delivered as Discord UI buttons.
- RLHF is stored via the 👍 / 👎 buttons on response messages.
Discord is a good fit when you want both server chat and DM support with a richer button-based experience.

