diegosouzapw/OmniRoute · error

Telegram API ${method} failed: ${json?.description || res.st

Error message

Telegram API ${method} failed: ${json?.description || res.status}

What it means

Error "Telegram API ${method} failed: ${json?.description || res.status}" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/lib/telegram/botApi.ts:68

}

async function botFetch<T>(method: string, body: unknown): Promise<T> {
  const token = getTelegramBotToken();
  if (!token) throw new Error("TELEGRAM_BOT_TOKEN is not set");
  const url = `${getTelegramBotApiBase()}/bot${token}/${method}`;
  const res = await fetch(url, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(body),
    signal: AbortSignal.timeout(getTelegramWebhookTimeoutMs()),
  });
  const json = (await res.json().catch(() => null)) as {
    ok?: boolean;
    description?: string;
    result?: T;
  } | null;
  if (!res.ok || !json?.ok) {
    throw new Error(`Telegram API ${method} failed: ${json?.description || res.status}`);
  }
  return json.result as T;
}

export async function sendTelegramMessage(
  params: TelegramSendMessageParams
): Promise<TelegramMessage> {
  return botFetch<TelegramMessage>("sendMessage", params);
}

export async function editTelegramMessage(
  params: TelegramEditMessageParams
): Promise<TelegramMessage> {
  return botFetch<TelegramMessage>("editMessageText", params);
}

/**
 * Register (or unregister) the bot webhook. Returns the Bot API result.

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/lib/telegram/botApi.ts:68 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/a4d6723e49de7f00. Report an issue: GitHub.