{"record":{"id":"a59b6580680a4976","repo":"babalae/better-genshin-impact","slug":"please-send-a-message-to-the-bot-first-and-check-t","errorCode":null,"errorMessage":"Please send a message to the bot first and check that the chat ID is correct.","messagePattern":"Please send a message to the bot first and check that the chat ID is correct\\.","errorType":"exception","errorClass":"NotifierException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Service/Notifier/TelegramNotifier.cs","lineNumber":190,"sourceCode":"\n    private async Task SendRequestAsync(string endpoint, HttpContent content, string type)\n    {\n        var request = new HttpRequestMessage(HttpMethod.Post, endpoint) { Content = content };\n        request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(\"application/json\"));\n        request.Headers.UserAgent.Add(new ProductInfoHeaderValue(\"BetterGenshinImpact\", \"1.0\"));\n\n        var response = await _httpClient.SendAsync(request);\n        var responseContent = await response.Content.ReadAsStringAsync();\n\n        if (!response.IsSuccessStatusCode)\n            throw new NotifierException($\"Telegram {type} message failed: {response.StatusCode}, {responseContent}\");\n\n        var (isSuccess, errorCode, errorDescription) = ValidateApiResponse(responseContent);\n        if (!isSuccess)\n        {\n            var msg = errorCode switch\n            {\n                400 => \"Please send a message to the bot first and check that the chat ID is correct.\",\n                401 => \"Telegram bot token is incorrect.\",\n                404 => $\"Telegram API not found (404). Please verify your bot token is correct. URL: {endpoint}\",\n                _ => $\"Telegram API error: {errorDescription} (Code: {errorCode})\"\n            };\n            throw new NotifierException(msg);\n        }\n    }\n\n    private static string FormatApiBaseUrl(string apiBaseUrl)\n    {\n        if (string.IsNullOrEmpty(apiBaseUrl)) return DefaultApiUrl;\n        var url = apiBaseUrl.Trim();\n        if (!url.StartsWith(\"http://\") && !url.StartsWith(\"https://\")) url = \"https://\" + url;\n        if (!url.EndsWith(\"/\")) url += \"/\";\n        if (!url.EndsWith(\"/bot\")) url += \"bot\";\n        return url;\n    }\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Service/Notifier/TelegramNotifier.cs#L172-L208","documentation":"User-facing hint thrown when ValidateApiResponse reports the Telegram Bot API returned ok:false with error_code 400. Telegram returns 400 'Bad Request: chat not found' when the chat_id does not exist for the bot — most commonly because the user has never initiated a conversation with the bot (bots cannot message users first under privacy rules) or the chat_id is wrong.","triggerScenarios":"SendRequestAsync gets a 200 OK body {\"ok\":false,\"error_code\":400,\"description\":\"Bad Request: chat not found\"}; ValidateApiResponse returns (false,400,...); the switch maps 400 to this hint.","commonSituations":"New bot, user never pressed Start / sent any message to it; chat_id typo; messaging a user who blocked the bot; group chat_id used without the bot being a member; chat_id from a different bot.","solutions":["Open the bot in Telegram and send /start (or any message) so it can reply — required for private chats.","Double-check the chat_id (use getUpdates to read the exact id the bot sees).","For groups, ensure the bot was added as a member and (for privacy-mode groups) that it received a recent message.","If blocked, the user must unblock the bot."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Cannot validate server-side chat existence locally, but can sanity-check the id shape.\nif (!long.TryParse(chatId, out _))\n    throw new InvalidOperationException(\"Telegram chat id must be numeric.\");","typeGuard":null,"tryCatchPattern":"try { await telegramNotifier.SendAsync(data); }\ncatch (NotifierException ex) when (ex.Message.Contains(\"send a message to the bot first\"))\n{ /* instruct user to /start the bot and verify chat_id; no automated retry */ }","preventionTips":["Send /start to the bot before configuring its chat_id.","Read the exact chat_id from getUpdates rather than guessing.","For groups, add the bot as a member first."],"tags":["telegram","config","api-failure","notifier","bot"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}