Integrations

Discord

Connect a chatbot to Discord so people can ask it questions with an /ask slash command, in a server channel or a direct message. Pro plan only.

Discord is currently marked Coming soon. Unlock it first — see Testing the new integrations.

What this does and does not do

It answers /ask. It does not read ordinary messages.

Discord only delivers plain chat messages over a Gateway WebSocket — a connection a bot must hold open permanently. Aimy runs on request-and-response web hosting, which cannot hold one. Slash commands arrive over a normal webhook, which is why that is what this supports.

This is a real capability, not a placeholder, and it has one advantage over listening to everything: the bot only ever answers when someone deliberately asks, so it cannot be pulled into a conversation and billed for it.

Before You Start

  • A Discord account and a server where you can add a bot (you need Manage Server).
  • A chatbot in Aimy with at least one document uploaded.

Step 1 — Create the Discord application

1. Create it. Go to the Discord Developer PortalNew Application. Name it and accept the terms.

2. Copy two values from General Information:

  • Application ID — a long number.
  • Public Key — 64 hexadecimal characters. Aimy checks the length and refuses anything else, because a wrong key means every request fails signature verification and Discord silently refuses to register your endpoint.

3. Add a bot and copy its token. Open the Bot tab → Add BotReset Token → copy. Discord shows a bot token exactly once; if you lose it, reset again.

Step 2 — Connect in Aimy

4. Open the integration. Integrations → the Discord card → pick your chatbot from the tabs.

5. Paste all three values — Application ID, Public key, Bot token — and click Connect.

Verify: connecting also registers the /ask command against your application, which is what proves the Application ID and bot token are a valid pair. If you see "Discord rejected that bot token", one of the two is wrong.

Step 3 — Give Discord the endpoint URL

6. Copy the Interactions endpoint URL from the box that appears.

7. Paste it into Discord. Back on General Information, paste it into Interactions Endpoint URL and click Save Changes.

Verify — and this one is a genuine test. Discord immediately sends several requests, some with deliberately invalid signatures, and refuses to save the URL unless the bad ones are rejected with a 401. If it saves, your signature verification is provably correct. If it says the endpoint could not be validated, the public key is wrong.

Step 4 — Add the bot to a server

8. Build an invite link. Open OAuth2URL Generator, tick applications.commands under Scopes (and bot if you want it visible in the member list).

9. Open the generated URL, pick your server, and authorise.

Step 5 — Test it

10. Wait, if you have to. Global slash commands can take up to an hour to appear in every server. If /ask does not autocomplete yet, this is why — it is not a failure.

11. Run it. In any channel the bot can see, type /ask, pick the command, and enter a real question your documents can answer.

Verify: you should see "thinking…" appear almost instantly, then be replaced by the answer a few seconds later. That two-stage behaviour is correct and expected — see below.

How it works — the "thinking…" step

Discord discards an interaction that is not acknowledged within three seconds, showing "The application did not respond". Our answers take longer, so Aimy replies immediately with a deferred response — the "thinking…" state — which buys fifteen minutes to fill in the real answer.

A background worker then edits that placeholder with the answer. If a reply is longer than Discord's 2,000-character limit, the first part replaces the placeholder and the rest arrive as follow-up messages.

A limitation worth knowing

Live agent handoff on Discord expires after 15 minutes. The interaction token is the only way Discord gives us to reach the person who ran the command, and it dies after fifteen minutes — often less than a human takes to pick up a conversation. Handoff works for a fast takeover and fails honestly for a slow one, and the agent is told their reply did not land.

Fixing that properly needs the same always-on Gateway connection that plain message support would require.

Troubleshooting

  • "Interactions Endpoint URL could not be validated." The public key is wrong, or was copied with whitespace. It must be exactly 64 hex characters.
  • /ask does not appear. Wait up to an hour, confirm the invite included applications.commands, or click Test & re-register /ask in Aimy.
  • "The application did not respond." The endpoint URL is not saved, or the server is unreachable.
  • Stuck on "thinking…" forever. The webhook acknowledged but the worker failed. Check the log for channel_reply_worker.
Disconnecting in Aimy leaves the /ask command registered on Discord's side — we cannot know the application is not shared with something else. Remove the endpoint URL in the Developer Portal to stop it appearing.