Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(platform): add Bots settings page with per-platform link management (#13222)

Bentlyaea4d5abd1eb
diff --git a/autogpt_platform/backend/backend/api/features/platform_linking/registry.py b/autogpt_platform/backend/backend/api/features/platform_linking/registry.py
new file mode 100644
index 0000000000..790383e022
--- /dev/null
+++ b/autogpt_platform/backend/backend/api/features/platform_linking/registry.py
@@ -0,0 +1,59 @@
+"""Per-platform metadata for the Bots settings page.
+
+API-facing source of truth for which chat-bot platforms exist, which are
+enabled on this deployment, and how to build their "Add bot to your server"
+invite URL. New platforms slot in by adding a row + their config check below.
+"""
+
+from urllib.parse import urlencode
+
+from pydantic import BaseModel, ConfigDict
+
+from backend.copilot.bot.adapters.discord import config as discord_config
+
+
+class PlatformMeta(BaseModel):
+ """Static + runtime metadata for one chat-bot platform."""
+
+ model_config = ConfigDict(frozen=True)
+
+ platform: str # canonical key, matches PlatformLinkInfo.platform (uppercase)
+ display_name: str
+ icon: str # filename under /public/integrations/<icon>
+ enabled: bool
+ add_bot_url: str | None # null when the platform has no invite URL we can build
+
+
+def enabled_platforms() -> list[PlatformMeta]:
+ """Return metadata for every platform currently enabled on this deployment.
+
+ Platforms whose adapter isn't configured (missing credentials) are
+ omitted entirely so the Bots page hides them.
+ """
+ all_platforms = [_discord_meta()]
+ return [platform for platform in all_platforms if platform.enabled]
+
+
+def _discord_meta() -> PlatformMeta:
+ enabled = bool(discord_config.get_bot_token())
+ return PlatformMeta(
+ platform="DISCORD",
+ display_name="Discord",
+ icon="discord.png",
+ enabled=enabled,
+ add_bot_url=_discord_invite_url() if enabled else None,
+ )
+
+
+def _discord_invite_url() -> str | None:
+ client_id = discord_config.get_client_id()
+ if not client_id:
+ return None
+ params = urlencode(
+ {
+ "client_id": client_id,
+ "scope": "bot applications.commands",
+ "permissions": discord_config.get_invite_permissions(),
+ }
+ )
+ return f"https://discord.com/oauth2/authorize?{params}"
diff --git a/autogpt_platform/backend/backend/api/features/platform_linking/registry_test.py b/autogpt_platform/backend/backend/api/features/platform_linking/registry_test.py
new file mode 100644
index 0000000000..8f34818084
--- /dev/null
+++ b/autogpt_platform/backend/backend/api/features/platform_linking/registry_test.py
@@ -0,0 +1,57 @@
+"""Tests for the bot-platforms registry."""
+
+from unittest.mock import patch
+
+from backend.api.features.platform_linking.registry import enabled_platforms
+
+
+def test_discord_excluded_when_bot_token_not_set():
+ with patch(
+ "backend.api.features.platform_linking.registry.discord_config.get_bot_token",
+ return_value="",
+ ):
+ assert enabled_platforms() == []
+
+
+def test_discord_appears_with_invite_url_when_client_id_set():
+ with (
+ patch(
+ "backend.api.features.platform_linking.registry.discord_config.get_bot_token",
+ return_value="token",
+ ),
+ patch(
+ "backend.api.features.platform_linking.registry.discord_config.get_client_id",
+ return_value="my-client-id",
+ ),
+ patch(
+ "backend.api.features.platform_linking.registry.discord_config.get_invite_permissions",
+ return_value="123",
+ ),
+ ):
+ platforms = enabled_platforms()
+
+ assert len(platforms) == 1
+ discord = platforms[0]
+ assert discord.platform == "DISCORD"
+ assert discord.enabled is True
+ assert discord.add_bot_url is not None
+ assert "client_id=my-client-id" in discord.add_bot_url
+ assert "permissions=123" in discord.add_bot_url
+
+
+def test_discord_appears_without_invite_url_when_client_id_missing():
+ with (
+ patch(
+ "backend.api.features.platform_linking.registry.discord_config.get_bot_token",
+ return_value="token",
+ ),
+ patch(
+ "backend.api.features.platform_linking.registry.discord_config.get_client_id",
+ return_value="",
+ ),
+ ):
+ platforms = enabled_platforms()
+
+ assert len(platforms) == 1
+ assert platforms[0].enabled is True
+ assert platforms[0].add_bot_url is None
diff --git a/autogpt_platform/backend/backend/api/features/platform_linking/routes.py b/autogpt_platform/backend/backend/api/features/platform_linking/routes.py
index 7b0f845c01..a65e70dbf8 100644
--- a/autogpt_platform/backend/backend/api/features/platform_linking/routes.py
+++ b/autogpt_platform/backend/backend/api/features/platform_linking/routes.py
@@ -8,6 +8,7 @@ from fastapi import APIRouter, HTTPException, Path, Security
from backend.data.db_accessors import platform_linking_db
from backend.platform_linking.models import (
+ BotPlatformInfo,
ConfirmLinkResponse,
ConfirmUserLinkResponse,
DeleteLinkResponse,
@@ -23,6 +24,8 @@ from backend.util.exceptions import (
NotFoundError,
)
+from . import registry
+
logger = logging.getLogger(__name__)
router = APIRouter()
@@ -126,6 +129,38 @@ async def list_my_user_links(
return await platform_linking_db().list_user_links(user_id)
+ "/platforms",
+ response_model=list[BotPlatformInfo],
+ dependencies=[Security(auth.requires_user)],
+ summary="List bot platforms enabled on this deployment plus the caller's links",
+ operation_id="list_bot_platforms",
+)
+async def list_bot_platforms(
+ user_id: Annotated[str, Security(auth.get_user_id)],
+) -> list[BotPlatformInfo]:
+ db = platform_linking_db()
+ user_links = await db.list_user_links(user_id)
+ server_links = await db.list_server_links(user_id)
+ dm_by_platform: dict[str, PlatformUserLinkInfo] = {}
+ for link in user_links:
+ dm_by_platform.setdefault(link.platform, link)
+ servers_by_platform: dict[str, list[PlatformLinkInfo]] = {}
+ for link in server_links:
+ servers_by_platform.setdefault(link.platform, []).append(link)
+ return [
+ BotPlatformInfo(
+ platform=meta.platform,
+ display_name=meta.display_name,
+ icon=meta.icon,
+ add_bot_url=meta.add_bot_url,
+ dm_link=dm_by_platform.get(meta.platform),
+ server_links=servers_by_platform.get(meta.platform, []),
+ )
+ for meta in registry.enabled_platforms()
+ ]
+
+
@router.delete(
"/links/{link_id}",
response_model=DeleteLinkResponse,
diff --git a/autogpt_platform/backend/backend/api/features/platform_linking/routes_test.py b/autogpt_platform/backend/backend/api/features/platform_linking/routes_test.py
index 944ef8eb6a..34aef91af8 100644
--- a/autogpt_platform/backend/backend/api/features/platform_linking/routes_test.py
+++ b/autogpt_platform/backend/backend/api/features/platform_linking/routes_test.py
@@ -1,10 +1,13 @@
"""Route tests: domain exceptions → HTTPException status codes."""
+from datetime import datetime, timezone
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from fastapi import HTTPException
+from backend.api.features.platform_linking.registry import PlatformMeta
+from backend.platform_linking.models import PlatformLinkInfo, PlatformUserLinkInfo
from backend.util.exceptions import (
LinkAlreadyExistsError,
LinkFlowMismatchError,
@@ -22,6 +25,18 @@ def _db_mock(**method_configs):
return db
+def _discord_meta(
+ *, enabled: bool = True, add_bot_url: str | None = "https://invite"
+) -> PlatformMeta:
+ return PlatformMeta(
+ platform="DISCORD",
+ display_name="Discord",
+ icon="discord.png",
+ enabled=enabled,
+ add_bot_url=add_bot_url,
+ )
+
+
class TestTokenInfoRouteTranslation:
@pytest.mark.asyncio
async def test_not_found_maps_to_404(self):
@@ -262,3 +277,137 @@ class TestAdversarialDeleteLinkId:
for link_id in ("'; DROP TABLE links;--", "../../etc/passwd", ""):
response = client.delete(f"/api/platform-linking/links/{link_id}")
assert response.status_code in (404, 405)
+
+
+class TestListBotPlatforms:
+ @pytest.mark.asyncio
+ async def test_returns_enabled_platforms_with_no_links(self):
+ from backend.api.features.platform_linking.routes import list_bot_platforms
+
+ db = _db_mock(
+ list_user_links=AsyncMock(return_value=[]),
+ list_server_links=AsyncMock(return_value=[]),
+ )
+ with (
+ patch(
+ "backend.api.features.platform_linking.routes.platform_linking_db",
+ return_value=db,
+ ),
+ patch(
+ "backend.api.features.platform_linking.routes.registry.enabled_platforms",
+ return_value=[_discord_meta()],
+ ),
+ ):
+ result = await list_bot_platforms(user_id="u1")
+
+ assert len(result) == 1
+ assert result[0].platform == "DISCORD"
+ assert result[0].add_bot_url == "https://invite"
+ assert result[0].dm_link is None
+ assert result[0].server_links == []
+
+ @pytest.mark.asyncio
+ async def test_attaches_callers_dm_and_server_links(self):
+ from backend.api.features.platform_linking.routes import list_bot_platforms
+
+ dm_link = PlatformUserLinkInfo(
+ id="dm-1",
+ platform="DISCORD",
+ platform_user_id="discord-user-1",
+ platform_username="bently",
+ linked_at=datetime(2026, 5, 1, tzinfo=timezone.utc),
+ )
+ server_a = PlatformLinkInfo(
+ id="srv-a",
+ platform="DISCORD",
+ platform_server_id="111",
+ owner_platform_user_id="discord-user-1",
+ server_name="Server A",
+ linked_at=datetime(2026, 5, 1, tzinfo=timezone.utc),
+ )
+ server_b = PlatformLinkInfo(
+ id="srv-b",
+ platform="DISCORD",
+ platform_server_id="222",
+ owner_platform_user_id="discord-user-1",
+ server_name="Server B",
+ linked_at=datetime(2026, 5, 2, tzinfo=timezone.utc),
+ )
+ db = _db_mock(
+ list_user_links=AsyncMock(return_value=[dm_link]),
+ list_server_links=AsyncMock(return_value=[server_a, server_b]),
+ )
+ with (
+ patch(
+ "backend.api.features.platform_linking.routes.platform_linking_db",
+ return_value=db,
+ ),
+ patch(
+ "backend.api.features.platform_linking.routes.registry.enabled_platforms",
+ return_value=[_discord_meta()],
+ ),
+ ):
+ result = await list_bot_platforms(user_id="discord-user-1")
+
+ assert result[0].dm_link is not None
+ assert result[0].dm_link.id == "dm-1"
+ assert [s.id for s in result[0].server_links] == ["srv-a", "srv-b"]
+
+ @pytest.mark.asyncio
+ async def test_picks_newest_dm_link_when_multiple_for_same_platform(self):
+ from backend.api.features.platform_linking.routes import list_bot_platforms
+
+ newer = PlatformUserLinkInfo(
+ id="dm-new",
+ platform="DISCORD",
+ platform_user_id="discord-user-2",
+ platform_username="newer-handle",
+ linked_at=datetime(2026, 5, 10, tzinfo=timezone.utc),
+ )
+ older = PlatformUserLinkInfo(
+ id="dm-old",
+ platform="DISCORD",
+ platform_user_id="discord-user-1",
+ platform_username="older-handle",
+ linked_at=datetime(2026, 5, 1, tzinfo=timezone.utc),
+ )
+ db = _db_mock(
+ list_user_links=AsyncMock(return_value=[newer, older]),
+ list_server_links=AsyncMock(return_value=[]),
+ )
+ with (
+ patch(
+ "backend.api.features.platform_linking.routes.platform_linking_db",
+ return_value=db,
+ ),
+ patch(
+ "backend.api.features.platform_linking.routes.registry.enabled_platforms",
+ return_value=[_discord_meta()],
+ ),
+ ):
+ result = await list_bot_platforms(user_id="u1")
+
+ assert result[0].dm_link is not None
+ assert result[0].dm_link.id == "dm-new"
+
+ @pytest.mark.asyncio
+ async def test_omits_platforms_whose_adapter_isnt_configured(self):
+ from backend.api.features.platform_linking.routes import list_bot_platforms
+
+ db = _db_mock(
+ list_user_links=AsyncMock(return_value=[]),
+ list_server_links=AsyncMock(return_value=[]),
+ )
+ with (
+ patch(
+ "backend.api.features.platform_linking.routes.platform_linking_db",
+ return_value=db,
+ ),
+ patch(
+ "backend.api.features.platform_linking.routes.registry.enabled_platforms",
+ return_value=[],
+ ),
+ ):
+ result = await list_bot_platforms(user_id="u1")
+
+ assert result == []
diff --git a/autogpt_platform/backend/backend/copilot/bot/adapters/discord/config.py b/autogpt_platform/backend/backend/copilot/bot/adapters/discord/config.py
index d2b3518eed..ea704cbe0e 100644
--- a/autogpt_platform/backend/backend/copilot/bot/adapters/discord/config.py
+++ b/autogpt_platform/backend/backend/copilot/bot/adapters/discord/config.py
@@ -7,9 +7,26 @@ def get_bot_token() -> str:
return Settings().secrets.autopilot_bot_discord_token
+def get_client_id() -> str:
+ return Settings().secrets.autopilot_bot_discord_client_id
+
+
+def get_invite_permissions() -> str:
+ return (
+ Settings().secrets.autopilot_bot_discord_permissions
+ or DEFAULT_INVITE_PERMISSIONS
+ )
+
+
# Discord message content limit (hard platform cap)
MAX_MESSAGE_LENGTH = 2000
# Flush the streaming buffer at 1900 — leaves 100-char headroom under the
# 2000 cap so the boundary-splitter has room to reach a natural break point.
CHUNK_FLUSH_AT = 1900
+
+# Sensible default Discord permissions for the "Add to server" invite URL —
+# covers send messages, embed links, attach files, read history, add
+# reactions, use external emoji, slash commands, public threads, and sending
+# in threads. Override per-deployment via AUTOPILOT_BOT_DISCORD_PERMISSIONS.
+DEFAULT_INVITE_PERMISSIONS = "377957124928"
diff --git a/autogpt_platform/backend/backend/platform_linking/models.py b/autogpt_platform/backend/backend/platform_linking/models.py
index 4f7f947506..c0562de22b 100644
--- a/autogpt_platform/backend/backend/platform_linking/models.py
+++ b/autogpt_platform/backend/backend/platform_linking/models.py
@@ -154,6 +154,21 @@ class PlatformUserLinkInfo(BaseModel):
linked_at: datetime
+class BotPlatformInfo(BaseModel):
+ """A bot platform enabled on this deployment plus the caller's links to it.
+
+ Platforms whose adapter isn't configured (missing token/credentials) are
+ omitted from the response entirely — the Bots settings page hides them.
+ """
+
+ platform: str
+ display_name: str
+ icon: str
+ add_bot_url: str | None = None
+ dm_link: PlatformUserLinkInfo | None = None
+ server_links: list[PlatformLinkInfo] = Field(default_factory=list)
+
+
class ConfirmLinkResponse(BaseModel):
success: bool
link_type: LinkType = LinkType.SERVER
diff --git a/autogpt_platform/backend/backend/util/settings.py b/autogpt_platform/backend/backend/util/settings.py
index 1431842154..e27cbeb0c3 100644
--- a/autogpt_platform/backend/backend/util/settings.py
+++ b/autogpt_platform/backend/backend/util/settings.py
@@ -726,6 +726,17 @@ class Secrets(UpdateTrackingModel["Secrets"], BaseSettings):
description="Discord bot token for the CoPilot chat bridge. When set, "
"the bridge enables its Discord adapter.",
)
+ autopilot_bot_discord_client_id: str = Field(
+ default="",
+ description="Discord application client ID for the CoPilot bot. Used "
+ "to build the 'Add to server' invite URL on the Bots settings page; "
+ "the bot itself doesn't need it.",
+ )
+ autopilot_bot_discord_permissions: str = Field(
+ default="",
+ description="Discord permissions bitfield for the 'Add to server' "
+ "invite URL. Overrides the built-in default when non-empty.",
+ )
smtp_server: str = Field(default="", description="SMTP server IP")
smtp_port: str = Field(default="", description="SMTP server port")
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/bots/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/bots/__tests__/main.test.tsx
new file mode 100644
index 0000000000..d51d3f99b7
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/bots/__tests__/main.test.tsx
@@ -0,0 +1,190 @@
+import { describe, expect, test } from "vitest";
+
+import {
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from "@/tests/integrations/test-utils";
+import { server } from "@/mocks/mock-server";
+import {
+ getDeletePlatformLinkingUnlinkADmUserLinkMockHandler401,
+ getDeletePlatformLinkingUnlinkAPlatformServerMockHandler,
+ getListBotPlatformsMockHandler,
+ getListBotPlatformsMockHandler401,
+} from "@/app/api/__generated__/endpoints/platform-linking/platform-linking.msw";
+import type { BotPlatformInfo } from "@/app/api/__generated__/models/botPlatformInfo";
+
+import SettingsBotsPage from "../page";
+
+function discordPlatform(
+ overrides: Partial<BotPlatformInfo> = {},
+): BotPlatformInfo {
+ return {
+ platform: "DISCORD",
+ display_name: "Discord",
+ icon: "discord.png",
+ add_bot_url: "https://discord.com/oauth2/authorize?client_id=123",
+ dm_link: undefined,
+ server_links: [],
+ ...overrides,
+ };
+}
+
+describe("SettingsBotsPage", () => {
+ test("renders the header and the Discord card with an Add bot button", async () => {
+ server.use(getListBotPlatformsMockHandler([discordPlatform()]));
+
+ render(<SettingsBotsPage />);
+
+ expect(
+ await screen.findByRole("heading", { name: /^bots$/i }),
+ ).toBeDefined();
+ expect(
+ await screen.findByRole("heading", { name: /discord/i }),
+ ).toBeDefined();
+ expect(
+ screen.getByRole("link", { name: /add bot to discord/i }),
+ ).toBeDefined();
+ });
+
+ test("shows the 'no bots enabled' empty state when no platforms are configured", async () => {
+ server.use(getListBotPlatformsMockHandler([]));
+
+ render(<SettingsBotsPage />);
+
+ expect(await screen.findByText(/no bots enabled/i)).toBeDefined();
+ });
+
+ test("renders an error card on 401 instead of the platform list", async () => {
+ server.use(getListBotPlatformsMockHandler401());
+
+ render(<SettingsBotsPage />);
+
+ expect(await screen.findByText(/something went wrong/i)).toBeDefined();
+ });
+
+ test("shows the DM-not-linked tile and an unlinked indicator when no DM link", async () => {
+ server.use(getListBotPlatformsMockHandler([discordPlatform()]));
+
+ render(<SettingsBotsPage />);
+
+ expect(
+ await screen.findByText(/dm the bot on discord to link/i),
+ ).toBeDefined();
+ expect(screen.getByText(/not linked/i)).toBeDefined();
+ });
+
+ test("shows the DM username and an Unlink button when DM link exists", async () => {
+ server.use(
+ getListBotPlatformsMockHandler([
+ discordPlatform({
+ dm_link: {
+ id: "dm-1",
+ platform: "DISCORD",
+ platform_user_id: "u-1",
+ platform_username: "bently",
+ linked_at: new Date("2024-01-01T00:00:00Z"),
+ },
+ }),
+ ]),
+ );
+
+ render(<SettingsBotsPage />);
+
+ expect(await screen.findByText("bently")).toBeDefined();
+ expect(
+ screen.getByRole("button", { name: /unlink dm on discord/i }),
+ ).toBeDefined();
+ });
+
+ test("shows a 'Bot not in server' indicator when the server name is missing", async () => {
+ server.use(
+ getListBotPlatformsMockHandler([
+ discordPlatform({
+ server_links: [
+ {
+ id: "srv-orphan",
+ platform: "DISCORD",
+ platform_server_id: "1126875755960336515",
+ owner_platform_user_id: "u-1",
+ server_name: null,
+ linked_at: new Date("2024-01-01T00:00:00Z"),
+ },
+ ],
+ }),
+ ]),
+ );
+
+ render(<SettingsBotsPage />);
+
+ expect(await screen.findByText("1126875755960336515")).toBeDefined();
+ expect(screen.getByText(/bot not in server/i)).toBeDefined();
+ });
+
+ test("clicking unlink on a linked server fires the API and the row is gone after refetch", async () => {
+ server.use(
+ getListBotPlatformsMockHandler([
+ discordPlatform({
+ server_links: [
+ {
+ id: "srv-1",
+ platform: "DISCORD",
+ platform_server_id: "111",
+ owner_platform_user_id: "u-1",
+ server_name: "AutoGPT HQ",
+ linked_at: new Date("2024-01-01T00:00:00Z"),
+ },
+ ],
+ }),
+ ]),
+ getDeletePlatformLinkingUnlinkAPlatformServerMockHandler({
+ success: true,
+ }),
+ );
+
+ render(<SettingsBotsPage />);
+
+ const unlinkBtn = await screen.findByRole("button", {
+ name: /unlink autogpt hq/i,
+ });
+
+ server.use(getListBotPlatformsMockHandler([discordPlatform()]));
+ fireEvent.click(unlinkBtn);
+
+ await waitFor(() => {
+ expect(screen.queryByText("AutoGPT HQ")).toBeNull();
+ });
+ });
+
+ test("a 401 on DM unlink keeps the row in place", async () => {
+ server.use(
+ getListBotPlatformsMockHandler([
+ discordPlatform({
+ dm_link: {
+ id: "dm-1",
+ platform: "DISCORD",
+ platform_user_id: "u-1",
+ platform_username: "bently",
+ linked_at: new Date("2024-01-01T00:00:00Z"),
+ },
+ }),
+ ]),
+ getDeletePlatformLinkingUnlinkADmUserLinkMockHandler401(),
+ );
+
+ render(<SettingsBotsPage />);
+
+ fireEvent.click(
+ await screen.findByRole("button", { name: /unlink dm on discord/i }),
+ );
+
+ // Swap the GET handler so a refetch would drop the DM row. If the failed
+ // mutation wrongly invalidated platforms, "bently" would vanish. Asserting
+ // it stays proves no refetch fired.
+ server.use(getListBotPlatformsMockHandler([discordPlatform()]));
+ await waitFor(() => {
+ expect(screen.getByText("bently")).toBeDefined();
+ });
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/BotCard.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/BotCard.tsx
new file mode 100644
index 0000000000..7cc204cd53
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/BotCard.tsx
@@ -0,0 +1,86 @@
+"use client";
+
+import Image from "next/image";
+import { PlusIcon } from "@phosphor-icons/react";
+
+import { Button } from "@/components/atoms/Button/Button";
+import { Card } from "@/components/atoms/Card/Card";
+import { Text } from "@/components/atoms/Text/Text";
+import type { BotPlatformInfo } from "@/app/api/__generated__/models/botPlatformInfo";
+
+import { BotCardDmTile } from "./BotCardDmTile";
+import { BotCardServerList } from "./BotCardServerList";
+import { useBotCard } from "./useBotCard";
+
+type Props = {
+ platform: BotPlatformInfo;
+};
+
+export function BotCard({ platform }: Props) {
+ const { isPending, unlinkServerLink, unlinkDmLink } = useBotCard();
+ const serverLinks = platform.server_links ?? [];
+
+ return (
+ <Card className="flex flex-col gap-5 p-5">
+ <header className="flex flex-wrap items-center justify-between gap-3">
+ <div className="flex items-center gap-3">
+ <Image
+ src={`/integrations/${platform.icon}`}
+ alt={`${platform.display_name} icon`}
+ width={32}
+ height={32}
+ className="rounded-md"
+ />
+ <Text variant="large-medium" as="h2" className="text-textBlack">
+ {platform.display_name}
+ </Text>
+ </div>
+ {platform.add_bot_url ? (
+ <Button
+ as="NextLink"
+ href={platform.add_bot_url}
+ target="_blank"
+ rel="noopener noreferrer"
+ variant="primary"
+ size="small"
+ leftIcon={<PlusIcon size={16} />}
+ >
+ Add bot to {platform.display_name}
+ </Button>
+ ) : null}
+ </header>
+
+ <section className="flex flex-col gap-2">
+ <Text
+ variant="small-medium"
+ as="span"
+ className="uppercase tracking-wide text-zinc-500"
+ >
+ Direct messages
+ </Text>
+ <BotCardDmTile
+ platformName={platform.display_name}
+ dmLink={platform.dm_link ?? null}
+ isPending={isPending}
+ onUnlink={unlinkDmLink}
+ />
+ </section>
+
+ <section className="flex flex-col gap-2">
+ <Text
+ variant="small-medium"
+ as="span"
+ className="uppercase tracking-wide text-zinc-500"
+ >
+ Linked servers
+ </Text>
+ <BotCardServerList
+ platformName={platform.display_name}
+ serverLinks={serverLinks}
+ isPending={isPending}
+ onUnlink={unlinkServerLink}
+ />
+ </section>
+ </Card>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/BotCardDmTile.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/BotCardDmTile.tsx
new file mode 100644
index 0000000000..f5568f1ecd
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/BotCardDmTile.tsx
@@ -0,0 +1,58 @@
+import { ChatCircleDotsIcon, LinkIcon, TrashIcon } from "@phosphor-icons/react";
+
+import { Button } from "@/components/atoms/Button/Button";
+import { Text } from "@/components/atoms/Text/Text";
+import type { PlatformUserLinkInfo } from "@/app/api/__generated__/models/platformUserLinkInfo";
+
+type Props = {
+ platformName: string;
+ dmLink: PlatformUserLinkInfo | null;
+ isPending: (linkId: string) => boolean;
+ onUnlink: (linkId: string) => void;
+};
+
+export function BotCardDmTile({
+ platformName,
+ dmLink,
+ isPending,
+ onUnlink,
+}: Props) {
+ const title = dmLink
+ ? (dmLink.platform_username ?? `User ${dmLink.platform_user_id}`)
+ : `DM the bot on ${platformName} to link`;
+ const subtitle = dmLink
+ ? "Your DM channel is linked to this account."
+ : "Send the bot a direct message to start the link flow.";
+
+ return (
+ <div className="flex items-center justify-between gap-3 rounded-large border border-zinc-200 px-4 py-3">
+ <div className="flex min-w-0 items-center gap-3">
+ <ChatCircleDotsIcon size={20} className="shrink-0 text-zinc-500" />
+ <div className="flex min-w-0 flex-col">
+ <Text variant="body-medium" as="span" className="text-textBlack">
+ {title}
+ </Text>
+ <Text variant="small" as="span" className="text-zinc-500">
+ {subtitle}
+ </Text>
+ </div>
+ </div>
+ {dmLink ? (
+ <Button
+ variant="outline"
+ size="small"
+ leftIcon={<TrashIcon size={16} />}
+ loading={isPending(dmLink.id)}
+ onClick={() => onUnlink(dmLink.id)}
+ aria-label={`Unlink DM on ${platformName}`}
+ >
+ Unlink
+ </Button>
+ ) : (
+ <span className="inline-flex items-center gap-1 text-xs text-zinc-500">
+ <LinkIcon size={14} /> Not linked
+ </span>
+ )}
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/BotCardServerList.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/BotCardServerList.tsx
new file mode 100644
index 0000000000..3ccfa9e702
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/BotCardServerList.tsx
@@ -0,0 +1,112 @@
+import { TrashIcon, UsersIcon, WarningCircleIcon } from "@phosphor-icons/react";
+
+import { Button } from "@/components/atoms/Button/Button";
+import { Text } from "@/components/atoms/Text/Text";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/components/atoms/Tooltip/BaseTooltip";
+import type { PlatformLinkInfo } from "@/app/api/__generated__/models/platformLinkInfo";
+
+type Props = {
+ platformName: string;
+ serverLinks: PlatformLinkInfo[];
+ isPending: (linkId: string) => boolean;
+ onUnlink: (linkId: string) => void;
+};
+
+export function BotCardServerList({
+ platformName,
+ serverLinks,
+ isPending,
+ onUnlink,
+}: Props) {
+ if (serverLinks.length === 0) {
+ return (
+ <div className="rounded-large border border-dashed border-zinc-200 px-4 py-3">
+ <Text variant="small" as="span" className="text-zinc-500">
+ No servers linked yet. Use &quot;Add bot to {platformName}&quot; to
+ invite the bot.
+ </Text>
+ </div>
+ );
+ }
+
+ return (
+ <ul className="flex flex-col gap-2">
+ {serverLinks.map((link) => (
+ <BotCardServerRow
+ key={link.id}
+ link={link}
+ platformName={platformName}
+ isPending={isPending(link.id)}
+ onUnlink={() => onUnlink(link.id)}
+ />
+ ))}
+ </ul>
+ );
+}
+
+type RowProps = {
+ link: PlatformLinkInfo;
+ platformName: string;
+ isPending: boolean;
+ onUnlink: () => void;
+};
+
+function BotCardServerRow({
+ link,
+ platformName,
+ isPending,
+ onUnlink,
+}: RowProps) {
+ const botMissing = !link.server_name;
+ const displayLabel = link.server_name ?? link.platform_server_id;
+
+ return (
+ <li className="flex items-center justify-between gap-3 rounded-large border border-zinc-200 px-4 py-3">
+ <div className="flex min-w-0 items-center gap-3">
+ <UsersIcon size={20} className="shrink-0 text-zinc-500" />
+ <div className="flex min-w-0 flex-col">
+ <Text
+ variant="body-medium"
+ as="span"
+ className="truncate text-textBlack"
+ >
+ {displayLabel}
+ </Text>
+ {botMissing ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex items-center gap-1 text-xs text-amber-600">
+ <WarningCircleIcon size={14} weight="fill" /> Bot not in
+ server
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>
+ {platformName} can&apos;t see this server, so we can&apos;t
+ resolve its name. Re-invite the bot, or unlink to remove this
+ row.
+ </TooltipContent>
+ </Tooltip>
+ ) : (
+ <Text variant="small" as="span" className="text-zinc-500">
+ Linked by you
+ </Text>
+ )}
+ </div>
+ </div>
+ <Button
+ variant="outline"
+ size="small"
+ leftIcon={<TrashIcon size={16} />}
+ loading={isPending}
+ onClick={onUnlink}
+ aria-label={`Unlink ${displayLabel}`}
+ >
+ Unlink
+ </Button>
+ </li>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/useBotCard.ts b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/useBotCard.ts
new file mode 100644
index 0000000000..f41edd6fb9
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotCard/useBotCard.ts
@@ -0,0 +1,85 @@
+import { useState } from "react";
+import { useQueryClient } from "@tanstack/react-query";
+
+import {
+ getListBotPlatformsQueryKey,
+ useDeletePlatformLinkingUnlinkADmUserLink,
+ useDeletePlatformLinkingUnlinkAPlatformServer,
+} from "@/app/api/__generated__/endpoints/platform-linking/platform-linking";
+import { useToast } from "@/components/molecules/Toast/use-toast";
+
+export function useBotCard() {
+ const queryClient = useQueryClient();
+ const { toast } = useToast();
+ // Track every in-flight link ID independently. A single string would
+ // get clobbered when the first of two concurrent unlinks settles,
+ // re-enabling the still-pending button and allowing a duplicate DELETE.
+ const [pendingIds, setPendingIds] = useState<ReadonlySet<string>>(
+ () => new Set(),
+ );
+
+ function markPending(linkId: string) {
+ setPendingIds((prev) => {
+ const next = new Set(prev);
+ next.add(linkId);
+ return next;
+ });
+ }
+
+ function clearPending(linkId: string) {
+ setPendingIds((prev) => {
+ if (!prev.has(linkId)) return prev;
+ const next = new Set(prev);
+ next.delete(linkId);
+ return next;
+ });
+ }
+
+ const invalidatePlatforms = () =>
+ queryClient.invalidateQueries({ queryKey: getListBotPlatformsQueryKey() });
+
+ function showError(action: string) {
+ toast({
+ title: `Couldn't ${action}`,
+ description: "Please try again in a moment.",
+ variant: "destructive",
+ });
+ }
+
+ const unlinkServer = useDeletePlatformLinkingUnlinkAPlatformServer({
+ mutation: {
+ onSuccess: () => invalidatePlatforms(),
+ onError: () => showError("unlink the server"),
+ },
+ });
+
+ const unlinkDm = useDeletePlatformLinkingUnlinkADmUserLink({
+ mutation: {
+ onSuccess: () => invalidatePlatforms(),
+ onError: () => showError("unlink the DM"),
+ },
+ });
+
+ function unlinkServerLink(linkId: string) {
+ if (pendingIds.has(linkId)) return;
+ markPending(linkId);
+ unlinkServer.mutate({ linkId }, { onSettled: () => clearPending(linkId) });
+ }
+
+ function unlinkDmLink(linkId: string) {
+ if (pendingIds.has(linkId)) return;
+ markPending(linkId);
+ unlinkDm.mutate({ linkId }, { onSettled: () => clearPending(linkId) });
+ }
+
+ function isPending(linkId: string) {
+ return pendingIds.has(linkId);
+ }
+
+ return {
+ isPending,
+ isUnlinking: unlinkServer.isPending || unlinkDm.isPending,
+ unlinkServerLink,
+ unlinkDmLink,
+ };
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotsHeader/BotsHeader.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotsHeader/BotsHeader.tsx
new file mode 100644
index 0000000000..cf5eab769e
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotsHeader/BotsHeader.tsx
@@ -0,0 +1,20 @@
+"use client";
+
+import { Text } from "@/components/atoms/Text/Text";
+
+export function BotsHeader() {
+ return (
+ <div className="flex flex-col items-start gap-4 pb-6 pl-4 sm:flex-row sm:items-start sm:justify-between">
+ <div className="flex min-w-0 flex-col">
+ <Text variant="h4" as="h1" className="leading-[28px] text-zinc-900">
+ Bots
+ </Text>
+ <Text variant="body" className="mt-4 max-w-[600px] text-zinc-600">
+ Connect AutoGPT bots to your chat platforms. Add a bot to one of your
+ servers, link a DM channel so the bot can talk to you directly, or
+ unlink an existing connection.
+ </Text>
+ </div>
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotsList/BotsList.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotsList/BotsList.tsx
new file mode 100644
index 0000000000..8250acb4b3
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotsList/BotsList.tsx
@@ -0,0 +1,56 @@
+"use client";
+
+import { ErrorCard } from "@/components/molecules/ErrorCard/ErrorCard";
+import { Text } from "@/components/atoms/Text/Text";
+
+import { BotCard } from "../BotCard/BotCard";
+import { useBotsList } from "./useBotsList";
+
+export function BotsList() {
+ const { platforms, isLoading, isError, error, refetch, isEmpty } =
+ useBotsList();
+
+ if (isLoading) {
+ return (
+ <div className="flex w-full flex-col gap-3 px-4">
+ <div className="h-40 animate-pulse rounded-large bg-zinc-100" />
+ </div>
+ );
+ }
+
+ if (isError) {
+ return (
+ <div className="flex w-full flex-col gap-3 px-4">
+ <ErrorCard
+ context="bots"
+ responseError={
+ error instanceof Error ? { message: error.message } : undefined
+ }
+ onRetry={() => refetch()}
+ />
+ </div>
+ );
+ }
+
+ if (isEmpty) {
+ return (
+ <div className="flex flex-col items-center justify-center gap-2 px-6 py-10 text-center">
+ <Text variant="large-medium" as="span" className="text-textBlack">
+ No bots enabled
+ </Text>
+ <Text variant="body" className="max-w-[360px] text-zinc-500">
+ No chat-bot platforms are configured on this deployment. Ask an
+ administrator to enable Discord, Slack, or another adapter.
+ </Text>
+ </div>
+ );
+ }
+
+ return (
+ <div className="flex w-full flex-col gap-4 px-4 pb-4">
+ {platforms.map((platform) => (
+ <BotCard key={platform.platform} platform={platform} />
+ ))}
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotsList/useBotsList.ts b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotsList/useBotsList.ts
new file mode 100644
index 0000000000..07251f7b02
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/bots/components/BotsList/useBotsList.ts
@@ -0,0 +1,19 @@
+import { useListBotPlatforms } from "@/app/api/__generated__/endpoints/platform-linking/platform-linking";
+
+export function useBotsList() {
+ const { data, isLoading, isSuccess, isError, error, refetch } =
+ useListBotPlatforms({
+ query: { retry: false },
+ });
+
+ const platforms = data?.status === 200 ? data.data : [];
+
+ return {
+ platforms,
+ isLoading,
+ isError,
+ error,
+ refetch,
+ isEmpty: isSuccess && platforms.length === 0,
+ };
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/bots/page.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/bots/page.tsx
new file mode 100644
index 0000000000..6dcbd0db52
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/bots/page.tsx
@@ -0,0 +1,13 @@
+"use client";
+
+import { BotsHeader } from "./components/BotsHeader/BotsHeader";
+import { BotsList } from "./components/BotsList/BotsList";
+
+export default function SettingsBotsPage() {
+ return (
+ <>
+ <BotsHeader />
+ <BotsList />
+ </>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/components/SettingsSidebar/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/settings/components/SettingsSidebar/helpers.ts
index 36193568fe..4d48e4e032 100644
--- a/autogpt_platform/frontend/src/app/(platform)/settings/components/SettingsSidebar/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/components/SettingsSidebar/helpers.ts
@@ -1,5 +1,6 @@
import {
ChartLineUpIcon,
+ ChatsCircleIcon,
CreditCardIcon,
KeyIcon,
PlugsConnectedIcon,
@@ -27,6 +28,7 @@ export const settingsNavItems: SettingsNavItem[] = [
href: "/settings/integrations",
Icon: PlugsConnectedIcon,
},
+ { label: "Bots", href: "/settings/bots", Icon: ChatsCircleIcon },
{ label: "AutoGPT API Keys", href: "/settings/api-keys", Icon: KeyIcon },
{
label: "Creator Dashboard",
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index bba37fb9cd..cab6b87df7 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -7657,6 +7657,31 @@
}
}
},
+ "/api/platform-linking/platforms": {
+ "get": {
+ "tags": ["platform-linking"],
+ "summary": "List bot platforms enabled on this deployment plus the caller's links",
+ "operationId": "list_bot_platforms",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "items": { "$ref": "#/components/schemas/BotPlatformInfo" },
+ "type": "array",
+ "title": "Response List Bot Platforms"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"
+ }
+ },
+ "security": [{ "HTTPBearerJWT": [] }]
+ }
+ },
"/api/platform-linking/tokens/{token}/confirm": {
"post": {
"tags": ["platform-linking"],
@@ -11291,6 +11316,32 @@
"required": ["file"],
"title": "Body_uploadWorkspaceFile"
},
+ "BotPlatformInfo": {
+ "properties": {
+ "platform": { "type": "string", "title": "Platform" },
+ "display_name": { "type": "string", "title": "Display Name" },
+ "icon": { "type": "string", "title": "Icon" },
+ "add_bot_url": {
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
+ "title": "Add Bot Url"
+ },
+ "dm_link": {
+ "anyOf": [
+ { "$ref": "#/components/schemas/PlatformUserLinkInfo" },
+ { "type": "null" }
+ ]
+ },
+ "server_links": {
+ "items": { "$ref": "#/components/schemas/PlatformLinkInfo" },
+ "type": "array",
+ "title": "Server Links"
+ }
+ },
+ "type": "object",
+ "required": ["platform", "display_name", "icon"],
+ "title": "BotPlatformInfo",
+ "description": "A bot platform enabled on this deployment plus the caller's links to it.\n\nPlatforms whose adapter isn't configured (missing token/credentials) are\nomitted from the response entirely — the Bots settings page hides them."
+ },
"BulkMoveAgentsRequest": {
"properties": {
"agent_ids": {