Skip to content

Discord ​

autorag tui --discord lets you ask the librarian questions from a Discord channel while a TUI session is running on your machine. It loads pi-discord-remote (pinned 0.2.4, MIT).

On launch it creates one text channel for the session. A message you send there runs through the same Jev routing and two-phase search as the same text typed in the terminal. When the TUI exits, the channel is deleted.

Requirements ​

  • A running autorag tui --discord session. The bridge is an extension of that process: if the TUI exits, the bot stops answering. Discord cannot start a session.
  • A Discord bot token and a server where the bot may manage channels.
  • Outbound HTTPS and WebSocket only. No inbound port is opened.

Setup ​

  1. Create an application at the Discord developer portal, open Bot, and copy the token.

  2. Under Bot, enable Message Content Intent. Without it, login fails with disallowed intents.

  3. Invite the bot to your server (OAuth2 → URL Generator, scope bot) with these permissions: View Channels, Send Messages, Add Reactions, and Manage Channels.

  4. Turn on Developer Mode (Discord settings → Advanced), then copy your server ID and your user ID from the right-click menu.

  5. Write ~/.pi/agent/pi-discord-remote/config.json and restrict it:

    json
    {
      "token": "<bot token>",
      "guildId": "<server id>",
      "allowedUserIds": ["<your user id>"]
    }
    bash
    chmod 600 ~/.pi/agent/pi-discord-remote/config.json

    Or run /pi-discord-remote setup inside the TUI. DISCORD_TOKEN and DISCORD_GUILD_ID can stand in for the token and server ID; DISCORD_CATEGORY_ID optionally places the channel in a category.

  6. Start the TUI:

    bash
    autorag tui --discord

The channel appears in your server.

Set allowedUserIds. The session has shell access. An empty list lets every member

of the server drive it.

Using it ​

  • Send a question in the session channel. The bot reacts with ⏳ while it works.
  • If the search has two phases, the fast answer is posted as soon as verification starts. Each correction verification makes to it is posted as its own message (✎ Corrected c1 — reason, the original struck out, the replacement in bold). The closing reply follows with a mention of the asker; it is a short note on what changed, not a second answer. A one-phase search posts one reply.
  • Tool calls are posted as short labels while the search runs.
  • When the model needs to ask you something, it asks in the channel and reads your next message as the answer (via discord_ask_user_question).
  • A message sent while a search is running gets Still processing. Steering a running search from Discord is not supported yet.
  • /pi-discord-remote status | stop | start work in the TUI; open-config edits the config JSON.

The extension also registers discord_send_image, which uploads a local file, URL, or base64 image the model chooses.

Troubleshooting ​

SymptomCause
Discord remote: no configMissing config file, or invalid JSON
disallowed intentsMessage Content Intent is off
Could not create channelThe bot lacks Manage Channels
Channel appears but nothing answersThe bot cannot read the channel, or your user ID is not in allowedUserIds
Could not post the fast answerTUI warning only; the final answer still posts

Released under the Apache-2.0 license.