// [nexus] Phone access onboarding step — Telegram bridge with BotFather guided setup import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { cn } from "@/lib/utils"; interface TelegramStepProps { onNext: () => void; onBack: () => void; } export function TelegramStep({ onNext, onBack }: TelegramStepProps) { const [token, setToken] = useState(""); const [validating, setValidating] = useState(false); const [botUsername, setBotUsername] = useState(null); const [error, setError] = useState(null); async function handleValidate() { if (!token.trim()) return; setValidating(true); setError(null); setBotUsername(null); try { const res = await fetch("/api/telegram/token", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ token: token.trim() }), }); if (res.ok) { const data = await res.json(); setBotUsername(data.botUsername ?? data.bot_username ?? null); } else { let msg = "Invalid token"; try { const data = await res.json(); if (data?.error) msg = data.error; } catch { // ignore parse errors } setError(msg); } } catch { setError("Could not reach the server. Check your connection and try again."); } finally { setValidating(false); } } return (
{/* Telegram as current option */}

Telegram Bot

{/* BotFather instructions */}

Set up your bot in 4 steps:

    {[ <>Open Telegram and search for @BotFather, <>Send /newbot and follow the prompts to create a bot, <>Copy the bot token -- it looks like 123456:ABC-DEF..., "Paste the token below and click Validate", ].map((instruction, i) => (
  1. {i + 1} {instruction}
  2. ))}
{/* Token input */}
{ setToken(e.target.value); setBotUsername(null); setError(null); }} disabled={validating} autoComplete="off" className="font-mono text-sm" /> {/* Success state */} {botUsername && (

Connected to @{botUsername}

)} {/* Error state */} {error && (

{error}

)}
{/* Future bridges note */}

Discord and WhatsApp bridges coming in a future update.

{/* Actions */}
); }