From 2e235213d965880653f90003e425a9f8a5890b78 Mon Sep 17 00:00:00 2001 From: William Valentin Date: Wed, 11 Feb 2026 19:44:42 -0800 Subject: [PATCH] fix(audio): handle voice message failures gracefully - Send user feedback when voice/audio download fails instead of silent failure - Send graceful message when audio transcription is not configured instead of empty text which crashes API --- src/channels/telegram/adapter.ts | 2 ++ src/daemon/routing.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/channels/telegram/adapter.ts b/src/channels/telegram/adapter.ts index 340fd2a..b00f825 100644 --- a/src/channels/telegram/adapter.ts +++ b/src/channels/telegram/adapter.ts @@ -300,6 +300,7 @@ export class TelegramAdapter implements ChannelAdapter { const fileData = await this.downloadFileToBase64(voice.file_id); if (!fileData) { console.error(`Failed to download voice message ${voice.file_id}`); + await ctx.reply('Sorry, I couldn\'t download your voice message. Please try again.', { reply_parameters: { message_id: ctx.message.message_id } }); return; } @@ -337,6 +338,7 @@ export class TelegramAdapter implements ChannelAdapter { const fileData = await this.downloadFileToBase64(audio.file_id); if (!fileData) { console.error(`Failed to download audio message ${audio.file_id}`); + await ctx.reply('Sorry, I couldn\'t download your audio file. Please try again.', { reply_parameters: { message_id: ctx.message.message_id } }); return; } diff --git a/src/daemon/routing.ts b/src/daemon/routing.ts index fafa98e..39cd3ea 100644 --- a/src/daemon/routing.ts +++ b/src/daemon/routing.ts @@ -254,6 +254,9 @@ export function createMessageRouter(deps: { const transcript = await transcribeAudio(att, audioConfig); messageText = `[Voice message]: ${transcript}\n\n${messageText}`; } + } else { + // No transcription endpoint configured — inform the user gracefully + messageText = `[Voice message received but audio transcription is not configured. Please configure the audio section in config.yaml to enable voice message support.]`; } // Remove audio attachments so buildUserMessage doesn't create audio content parts attachments = (msg.attachments ?? []).filter((a: Attachment) => !isSupportedAudio(a));