Skip to content

Self-improving AI Employees for everyone

fix(credentials/telegram): green status indicator reflects bot-token storage

trohitgc5718a155d53
diff --git a/server/config/credential_providers.json b/server/config/credential_providers.json
index a28fe86e..c017cb99 100644
--- a/server/config/credential_providers.json
+++ b/server/config/credential_providers.json
@@ -265,6 +265,11 @@
"kind": "oauth",
"icon_ref": "asset:telegram",
"status_hook": "telegram",
+ "_stored_check_note": "Telegram uses status_hook for runtime connection state but stores the bot token via api_key (telegram_bot_token), not OAuth. Override the catalogue handler's default get_oauth_tokens(status_hook) lookup so the connected/stored badge reflects bot-token presence.",
+ "stored_check": {
+ "type": "api_key",
+ "key": "telegram_bot_token"
+ },
"ws": {
"login": "telegram_connect",
"logout": "telegram_disconnect",
diff --git a/server/routers/websocket.py b/server/routers/websocket.py
index 4f4ba45f..7e0d1b5b 100644
--- a/server/routers/websocket.py
+++ b/server/routers/websocket.py
@@ -362,9 +362,23 @@ async def handle_get_credential_catalogue(data: Dict[str, Any], websocket: WebSo
status_hook = provider.get("status_hook")
tokens = None
- if status_hook:
- # Status-hook providers (whatsapp, android, twitter, google, telegram)
- # use OAuth tokens or special connection state.
+ # Declarative per-provider override for the "stored" check.
+ # Lets Telegram (kind=oauth + status_hook but actual storage
+ # is api_key for the bot token) signal that "stored" should
+ # be ``has_valid_key("telegram_bot_token")`` rather than the
+ # default ``get_oauth_tokens(status_hook)`` lookup. Other
+ # providers don't declare ``stored_check`` and keep the
+ # original kind/status_hook-based logic untouched -- so
+ # Google's saved client_secret (password field) does NOT
+ # flip the connected dot before the user actually completes
+ # the OAuth flow.
+ stored_check = provider.get("stored_check")
+ if stored_check and stored_check.get("type") == "api_key":
+ provider["stored"] = await auth_service.has_valid_key(stored_check.get("key", pid))
+ elif status_hook:
+ # Status-hook providers (whatsapp, android, twitter, google,
+ # claude_code, codex_cli) use OAuth tokens for the runtime
+ # connection state.
tokens = await auth_service.get_oauth_tokens(status_hook)
provider["stored"] = tokens is not None
elif kind == "apiKey":