Skip to content

Commit affeebf

Browse files
committed
fix(telegram): allow URL strings in advanced mode media inputs
normalizeFileInput only handles file objects, not plain URL strings. Check for string input first before file normalization. Fixes #3220
1 parent 4c12914 commit affeebf

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

apps/sim/blocks/blocks/telegram.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,14 @@ export const TelegramBlock: BlockConfig<TelegramResponse> = {
270270
}
271271
case 'telegram_send_photo': {
272272
// photo is the canonical param for both basic (photoFile) and advanced modes
273+
// In advanced mode, photo can be a plain URL string or file_id
274+
if (typeof params.photo === 'string' && params.photo.trim()) {
275+
return {
276+
...commonParams,
277+
photo: params.photo.trim(),
278+
caption: params.caption,
279+
}
280+
}
273281
const photoSource = normalizeFileInput(params.photo, {
274282
single: true,
275283
})
@@ -284,6 +292,14 @@ export const TelegramBlock: BlockConfig<TelegramResponse> = {
284292
}
285293
case 'telegram_send_video': {
286294
// video is the canonical param for both basic (videoFile) and advanced modes
295+
// In advanced mode, video can be a plain URL string or file_id
296+
if (typeof params.video === 'string' && params.video.trim()) {
297+
return {
298+
...commonParams,
299+
video: params.video.trim(),
300+
caption: params.caption,
301+
}
302+
}
287303
const videoSource = normalizeFileInput(params.video, {
288304
single: true,
289305
})
@@ -298,6 +314,14 @@ export const TelegramBlock: BlockConfig<TelegramResponse> = {
298314
}
299315
case 'telegram_send_audio': {
300316
// audio is the canonical param for both basic (audioFile) and advanced modes
317+
// In advanced mode, audio can be a plain URL string or file_id
318+
if (typeof params.audio === 'string' && params.audio.trim()) {
319+
return {
320+
...commonParams,
321+
audio: params.audio.trim(),
322+
caption: params.caption,
323+
}
324+
}
301325
const audioSource = normalizeFileInput(params.audio, {
302326
single: true,
303327
})
@@ -312,6 +336,14 @@ export const TelegramBlock: BlockConfig<TelegramResponse> = {
312336
}
313337
case 'telegram_send_animation': {
314338
// animation is the canonical param for both basic (animationFile) and advanced modes
339+
// In advanced mode, animation can be a plain URL string or file_id
340+
if (typeof params.animation === 'string' && params.animation.trim()) {
341+
return {
342+
...commonParams,
343+
animation: params.animation.trim(),
344+
caption: params.caption,
345+
}
346+
}
315347
const animationSource = normalizeFileInput(params.animation, {
316348
single: true,
317349
})

0 commit comments

Comments
 (0)