> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getnao.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Discord Bot

> Enable your team or community to ask questions directly in Discord

The nao Discord bot brings your analytics agent directly into Discord, allowing your team to ask questions and get insights without leaving their server.

When configured, the nao Discord bot:

* Connects to Discord over the gateway with your own Discord application and bot
* Answers mentions in channels, every message in direct messages, and follow-ups in threads it already answers in
* Returns answers with SQL queries, data tables, and visualizations
* Posts a "✨ nao is answering..." message and streams the answer into it as it grows

> [!NOTE]
>
> The Discord bot uses the same agent context, rules, models, and capabilities
> as your web chat interface. Any improvements to your agent automatically
> benefit Discord users.

Each nao project connects its own Discord application.

## Setup

### Step 1: Create a Discord application and bot

1. Go to the [Discord Developer Portal](https://discord.com/developers/applications) and create a new application.
2. From **General Information**, copy the **Application ID** and the **Public Key**.
3. Open the **Bot** page, create the bot, and copy its **token**.

### Step 2: Connect your Discord bot to nao

1. In nao, open **Settings** -> **Integrations & MCP** -> **Discord**
2. Fill in the required fields:
   * **Bot token**
   * **Application ID**
   * **Public key**
3. Optionally fill in:
   * **Trigger role IDs (comma separated)**: mentioning one of these roles also triggers the bot, not only mentioning the bot itself.
   * **Respond to channel IDs (comma separated)**: limit the bot to these channels. Leave it empty to answer in all channels.
   * **Fallback user email (community servers)**: messages from members who have not linked a nao account are answered as this user.
   * **Do not add the "Open in nao" link to answers**: useful on community servers where members do not have access to nao.
4. Click **"Save"**

> [!WARNING]
>
> Anyone who can mention the bot can reach whatever the fallback user can see.
> Use a dedicated nao account with access limited to what you want to expose.

### Step 3: Add the bot to your server

Once saved, the **Add to your server** card shows an **Add to Discord** button and the invite link. Open it to invite the bot to a Discord server you manage, then mention it or send it a direct message.

### Step 4: Turn on the Stop button

Copy the URL from the **Interactions Endpoint URL** card and paste it into the **Interactions Endpoint URL** field of your Discord application's **General Information** page. This adds a **Stop** button to the answer while nao is generating, so people can cut a long answer short.

This step is optional. Everything except the Stop button works without it.

### Step 5: Choose the model

In the **Settings** card, pick the **Model** used to answer questions asked in Discord.

### Step 6: Account linking

Discord does not expose member emails, so accounts cannot be linked automatically by email.

* When an unlinked member mentions the bot, it sends them a direct message with a link to connect their Discord account to nao. They open it, sign in, then ask their question again.
* If their direct messages are closed, they send `login <code>` to the bot instead. Each user finds their code on the Discord settings page.

If a **Fallback user email** is set, unlinked members are answered as that user instead of being asked to link.

> [!NOTE]
>
> Admins configure the integration. Members with the Admin, Context admin, or
> User role can use the bot. Members with the Viewer role cannot.

## Usage

**Ask Questions**

In a channel, mention the bot:

```
@nao What were our top 5 products by revenue last month?
```

The bot will:

1. Process your question using the same agent as the web interface
2. Generate SQL queries based on your context
3. Execute queries against your connected databases
4. Stream the answer into a single Discord message, editing it as the answer grows
5. End the answer with an **Open in nao** link to the full conversation, unless the link is turned off

**Thread Conversations**

Once the bot answers in a thread, follow-ups inside it need no mention.

**Direct Messages**

In a direct message the bot answers every message. No mention needed.

**Long answers**

Discord posts are limited to 2,000 characters. When an answer is longer, the post is truncated and the full answer is attached as an `answer.md` file.

**Feedback**

React to an answer with 👍 or 👎 and the vote is recorded in nao, the same as the thumbs in the web UI. Remove the reaction to remove the vote.

**What's Next?**

> **[Admin Setup](https://docs.getnao.io/nao-agent/chat/admin/setup.md)**
>
> Configure authentication, models, and messaging integrations

> **[Chat Overview](https://docs.getnao.io/nao-agent/chat/overview.md)**
>
> Learn how the main chat interface works


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.