[Telegram node] Get highest number photo

Hello, fantastic n8n team.

I posted a question a couple of days ago about the Telegram node ignoring videos and not being able to download them.

I was playing around with it till the new fix released this week, and I found that Telegram node totally ignores messages from other bots, it turned out it was intended by Telegram API itself

Bots talking to each other could potentially get stuck in unwelcome loops. To avoid this, we decided that bots will not be able to see messages from other bots regardless of mode.

But, I also caught that it picks it up ONCE you REPLY to this message in Telegram, That’s why I started a new thread, but sadly we returned to the previous bug. It Ignores the media and doesn’t place them in a Binary object to download. Instead, it returns:

JSON output

[
  {
    "update_id": xxxxxx,
    "message": {
      "message_id": 8,
      "from": {
        "id": xxxxxxxxxxxxx,
        "is_bot": false,
        "first_name": "xxxxxx",
        "username": "xxxxxxxxx",
        "language_code": "en"
      },
      "chat": {
        "id": -xxxxxxxxxxx,
        "title": "xxxxxxxxxxxxx",
        "type": "supergroup"
      },
      "date": 1721005646,
      "message_thread_id": 7,
      "reply_to_message": {
        "message_id": 7,
        "from": {
          "id": xxxxxxxx,
          "is_bot": true,
          "first_name": "BOT_NAME",
          "username": "BOT_USERNAME"
        },
        "chat": {
          "id": -xxxxxxxxx,
          "title": "Media work",
          "type": "supergroup"
        },
        "date": 1721005633,
        "photo": [
          {
            "file_id": "AgACAgQAAyEFAASAP6hDAAMHZpR2TlU-0O1PBFujWST_Q4ah3IsAAv20MRvEVp1Q1Jc2lM1ZnJ8BAAMCAANzAAM1BA",
            "file_unique_id": "AQAD_bQxG8RWnVB4",
            "file_size": 1781,
            "width": 90,
            "height": 77
          },
          {
            "file_id": "AgACAgQAAyEFAASAP6hDAAMHZpR2TlU-0O1PBFujWST_Q4ah3IsAAv20MRvEVp1Q1Jc2lM1ZnJ8BAAMCAANtAAM1BA",
            "file_unique_id": "AQAD_bQxG8RWnVBy",
            "file_size": 23247,
            "width": 320,
            "height": 274
          },
          {
            "file_id": "AgACAgQAAyEFAASAP6hDAAMHZpR2TlU-0O1PBFujWST_Q4ah3IsAAv20MRvEVp1Q1Jc2lM1ZnJ8BAAMCAAN4AAM1BA",
            "file_unique_id": "AQAD_bQxG8RWnVB9",
            "file_size": 97337,
            "width": 800,
            "height": 684
          },
          {
            "file_id": "AgACAgQAAyEFAASAP6hDAAMHZpR2TlU-0O1PBFujWST_Q4ah3IsAAv20MRvEVp1Q1Jc2lM1ZnJ8BAAMCAAN5AAM1BA",
            "file_unique_id": "AQAD_bQxG8RWnVB-",
            "file_size": 102382,
            "width": 959,
            "height": 820
          }
        ]
      },
      "text": "text"
    }
  }
]

As you noticed, this time it ignores even IMG type, not just videos.

Is there any way you guys can integrate this ?

Thanks In Advance.

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:

Hi @Moataz_Abosdera

This looks odd. Could you share a screenshot of the output? Did you get the binary tab to view the files?
I am also missing the Mime Type from that output. :thinking:

This is what I get:

Thank you @ria

the odd thing is the GET FILE option from Telegram picks the file to download.

but its not convenient, since i need to put the file_id, which is not consistent, as some pictures/videos come in 3 quality versions, and some 4 quality versions. and i didnt manage to automate downloading the highest quality.

as i need to pass {{ $json.message.reply_to_message.photo[highest_number].file_id }}

Thanks in advance.

Hi @Moataz_Abosdera

Oh I see what you mean!

If you want to always grab the last item in the array, but not sure how many there will be, you can simply use the .last() function.

So in your example, this would be:

{{ $json.message.reply_to_message.photo.last().file_id }}

Give this a go and let us know if it worked :raised_hands:

1 Like

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