> For the complete documentation index, see [llms.txt](https://aibotkit.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aibotkit.gitbook.io/documentation/channels-and-integrations/discord.md).

# Discord

Add your AI Bot Kit chatbot to a Discord server. Members can use the `/ask` slash command in any channel the bot has access to and get the same trained responses as your website widget.

## What you need

* A Discord server where you have **Manage Server** permission
* A paid plan (Basic, Essential, or Business)

## Create a Discord application

1. Go to [discord.com/developers/applications](https://discord.com/developers/applications) → **New Application**.
2. Give it a name and click **Create**.
3. Under **Bot** → **Token**, click **Reset Token** and copy the bot token.
4. Under **General Information**, copy the **Application ID** and **Public Key**.
5. Under **Bot** → **Privileged Gateway Intents**, enable **Message Content Intent**.

## Connect to AI Bot Kit

1. Open your chatbot → **INTEGRATIONS** → **Discord**.
2. Paste the **Bot Token**, **Application ID**, and **Public Key**.
3. Click **Connect Discord**.
4. After connecting, you'll see steps to set the Interactions Endpoint URL and invite the bot to your server.
5. In the developer portal, generate an **OAuth2 invite link** with `bot` and `applications.commands` scopes (and the `Send Messages` + `Read Message History` permissions). Use it to add the bot to your server.

When connected, you'll see:

* **Feature bullets:**
  * **Ed25519 verified** -- Cryptographically secure interaction verification
  * **Instant replies** -- Your bot responds in real time
  * **Any Discord server** -- Works in any server you have access to

## How members use it

In any channel where the bot has access:

```
/ask How do I reset my password?
```

The bot replies in the same channel with the AI-generated answer. The interaction is initially deferred (Discord's "thinking…" state), then edited with the final response — typically under 5 seconds.

## What happens behind the scenes

* Discord POSTs interaction events to `/api/discord/callback`. The handler verifies the **Ed25519** signature using your Public Key.
* The session ID is `discord_<user-id>` — per-user threads, not per-channel.
* Replies are sent via Discord's REST API as **interaction follow-ups**.

## Tips

* **Slash commands take time to propagate.** After saving credentials, give Discord up to an hour to make `/ask` available globally.
* **Per-server toggling:** the bot is on for every server it's added to. To exclude a server, kick the bot from it.
* **One application per chatbot.** AI Bot Kit detects token reuse and asks you to confirm a transfer.

## Limits

* Counts toward your **Monthly AI Messages** quota.
* Discord enforces its own per-channel rate limits; AI Bot Kit defers replies to stay within them.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://aibotkit.gitbook.io/documentation/channels-and-integrations/discord.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
