Spaces:
Sleeping

axeronis commited on
Commit
db0923c
Β·
1 Parent(s): 7efb057

chore(debug): add verbose logging for Telegram media processing

Browse files
backend/app/api/telegram_webhook.py CHANGED
@@ -112,6 +112,8 @@ async def process_telegram_message(
112
  import time
113
  import re
114
 
 
 
115
  async with async_session_maker() as session:
116
  try:
117
  # 1. Get Tenant & Bot Token
@@ -125,6 +127,8 @@ async def process_telegram_message(
125
  logger.error(f"No Telegram token for tenant {tenant_id}")
126
  return
127
 
 
 
128
  # 2. Process Media (Voice, Photo, Doc)
129
  is_voice = False
130
  media_url = None
@@ -159,16 +163,18 @@ async def process_telegram_message(
159
 
160
  # Handle Voice
161
  if voice_file_id:
 
162
  try:
163
  text = await transcribe_telegram_voice(bot_token, voice_file_id)
164
  is_voice = True
165
- # Optional: We could also upload the voice file if needed
166
  except Exception as e:
167
- logger.error(f"Voice processing failed: {e}")
168
 
169
  # Handle Photo / Document
170
  target_file_id = photo_file_id or doc_file_id
171
  if target_file_id:
 
172
  try:
173
  content, name, mime = await download_file(target_file_id)
174
  if content and supabase_client:
 
112
  import time
113
  import re
114
 
115
+ logger.info(f"πŸ”§ Processing TG message: text={text[:30] if text else 'N/A'}..., voice={voice_file_id}, photo={photo_file_id}, doc={doc_file_id}")
116
+
117
  async with async_session_maker() as session:
118
  try:
119
  # 1. Get Tenant & Bot Token
 
127
  logger.error(f"No Telegram token for tenant {tenant_id}")
128
  return
129
 
130
+ logger.info(f"βœ… Tenant found, bot_token={'present' if bot_token else 'MISSING'}")
131
+
132
  # 2. Process Media (Voice, Photo, Doc)
133
  is_voice = False
134
  media_url = None
 
163
 
164
  # Handle Voice
165
  if voice_file_id:
166
+ logger.info(f"🎀 Voice file detected: {voice_file_id}")
167
  try:
168
  text = await transcribe_telegram_voice(bot_token, voice_file_id)
169
  is_voice = True
170
+ logger.info(f"βœ… Voice transcribed: {text[:50]}...")
171
  except Exception as e:
172
+ logger.error(f"❌ Voice processing failed: {e}", exc_info=True)
173
 
174
  # Handle Photo / Document
175
  target_file_id = photo_file_id or doc_file_id
176
  if target_file_id:
177
+ logger.info(f"πŸ“Ž Media file detected: {target_file_id}")
178
  try:
179
  content, name, mime = await download_file(target_file_id)
180
  if content and supabase_client: