Discord guide

Discord inbound needs a long-lived gateway WebSocket — the capability serverless deployments can't self-host. Register your bot and our worker fleet holds the socket for you.

Prerequisites

  • A Discord application with a bot token (Developer Portal → Bot).
  • A server you can add the bot to.
  • An AgentSky API token with write scope.

Create the bot

In the Discord Developer Portal:

The Developer Portal's Applications page with the New Application button highlighted

New Application → add a Bot → enable the Message Content intent → copy the bot token.

Register the channel app

The developer console runs the same checklist and shows the invite link after create:

The developer console's new-app checklist for Discord

Or over the API:

bash
curl -s -X POST https://api.agentsky.dev/v1/channels/apps \
  -H "Authorization: Bearer $AST_TOKEN" -H 'content-type: application/json' \
  -d '{"platform": "discord", "label": "My bot", "credentials": {"bot_token": "..."}}'
# -> setup: { "invite_url": "https://discord.com/oauth2/authorize?..." }

Registration proves the token and returns setup.invite_url — open it to add your bot to a server. Within about a minute the worker fleet opens your bot's gateway connection and starts mirroring events.

Connect

bash
curl -s -X POST https://api.agentsky.dev/v1/channels/connections \
  -H "Authorization: Bearer $AST_TOKEN" -H 'content-type: application/json' \
  -d '{"platform": "discord", "app": "app_...", "destination": {"session": "sess-..."}}'

Discord connects synchronously: the call creates a per-agent text channel in your server over REST, greets, binds, and returns CONNECTED.

Capabilities

threadsreactionsmarkersproactivemarkdownmodalsephemeralstreaming

Troubleshooting

  • Guild messages don't reach the agent — mention the bot (or DM it). The gateway runs without the privileged MessageContent intent, so untagged guild messages carry no text.
  • Connect fails after registration — make sure the bot was actually added via setup.invite_url and has permission to create channels in the server.
  • Events lag right after registration — the worker fleet reconciles registered bots periodically; the first connection can take up to about a minute.