Telegram Node seperating text and photos in different workflows

HI guys,

I am creating a social media workflow with Telegram as my input. I wanted to be able to process text message sent from telegram in one workflow and photos uploaded into telegram in another flow. I tried doing an if node where I set {{$input.data.message.text}} not equal to undefined or/and {{$input.data.message.text}} not eqjal to undefined. Hoewever when I run the workflow and upload a picture it always goes to the text flow. I tried two ifs same thing even tried using file_id is not undefined and it still goes to the text flow. How do I set it up? My ultimate goal here is to use the text as context to create social media post and at the end join it with the picture that was uploaded in telegram. So when I post in facebook the post will have text and picture together and uploaded in one facebook post.

  • n8n version: - version 1.73.0 Community Edition
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): self hosted on Render
  • Operating system: Mac OS 15.2

Cheers,
SherwinI

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I was able to solve my dilemma i hacked a javascript code then connected it to a switch here the javascript post just in case you need it.

// Extract the message from the incoming payload
const message = $json.message;

// Regular expression to detect URLs
const urlRegex = /(https?://[^\s]+)/;

// Determine the type of message
if (message.text) {
// Check if the text contains a URL
if (urlRegex.test(message.text)) {
return [{ json: { type: ‘url’, content: message.text } }];
} else {
return [{ json: { type: ‘text’, content: message.text } }];
}
} else if (message.photo) {
// Select the largest photo (last element in the array)
const largestPhoto = message.photo[message.photo.length - 1];
return [{ json: { type: ‘photo’, content: largestPhoto } }];
} else if (message.video) {
// Extract video details
return [{
json: {
type: ‘video’,
content: {
file_id: message.video.file_id,
file_name: message.video.file_name || null,
mime_type: message.video.mime_type || null,
file_size: message.video.file_size,
duration: message.video.duration,
width: message.video.width,
height: message.video.height,
thumbnail: message.video.thumb || null
}
}
}];
} else {
return [{ json: { type: ‘unknown’, content: null } }];
}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.