agent-zero/plugins/_telegram_integration/api/test_connection.py
Alessandro 2000ba74a3 ui: redesign email, Telegram, and WhatsApp settings
Redesign the three messaging integration panels with a clearer, more guided
setup flow and polished user experience.

- simplify the email panel by surfacing the essentials first, moving
  advanced scheduling behind Advanced, and making connection checks more
  visible
- redesign Telegram and WhatsApp as step-based setup flows with clearer
  status states, safer access warnings, richer test feedback, and more
  responsive layouts
- add shared plugin-settings wizard footer support, extract WhatsApp state
  into its own store, and align test-connection messages with the new UX

ux: ease Email connector setup and refresh copy

- Redesign the Email connector settings around a guided first-run flow with a clearer empty state, provider presets, and much friendlier copy
- Move server, routing, and scheduling power-user controls into an `Advanced` section while keeping the existing config model compatible
- Improve connection-test messaging, add Exchange inbound validation, and refresh the dashboard Email card copy while keeping the card visible
- Verify the updated setup flow in the browser on desktop and mobile

update and simplify x-data based on established frontend patterns

Update 10_discovery_cards.py

further polishing and first-draft no-click model for email and telegram

update whatsapp

Update telegram-config-store.js
2026-04-11 01:40:24 +02:00

37 lines
1.3 KiB
Python

from helpers.api import ApiHandler, Request
from helpers.errors import format_error
from plugins._telegram_integration.helpers.dependencies import ensure_dependencies
class TestConnection(ApiHandler):
async def process(self, input: dict, request: Request) -> dict:
bot_cfg = input.get("bot", {})
token = bot_cfg.get("token", "")
results: list[dict] = []
if not token:
results.append({
"test": "Bot token",
"ok": False,
"message": "Add your bot token first.",
})
return {"success": False, "results": results}
try:
ensure_dependencies()
from plugins._telegram_integration.helpers.bot_manager import test_token
ok, message = await test_token(token)
results.append({
"test": "Telegram bot",
"ok": ok,
"message": "Telegram accepted the bot token." if ok else message,
})
except Exception as e:
results.append({
"test": "Telegram bot",
"ok": False,
"message": f"Could not validate the bot token: {format_error(e)}",
})
return {"success": all(r["ok"] for r in results), "results": results}