Recognise PNG with message route node

Describe the problem/error/question

I created a ComfyUI workflow node to post a generated image to a local installation of n8n (docker)
The POSTed png file is received and can be viewed, but how to recognize it with the message route node

What is the error message (if any)?

Unclear what to set in the message route* node

Please share your workflow

{
“nodes”: [
{
“parameters”: {
“chatId”: “",
“text”: “={{ $json.body.text }}”,
“additionalFields”: {
“appendAttribution”: false
}
},
“type”: “n8n-nodes-base.telegram”,
“typeVersion”: 1.2,
“position”: [
-600,
-460
],
“id”: “e4ad3b27-83e4-4190-a0ab-cd965bb7390d”,
“name”: “Telegram”,
“webhookId”: “73aaaf2b-dcdb-45c0-bbab-1f9e98a9a110”,
“credentials”: {
“telegramApi”: {
“id”: “iutFkKAfs9lZJIZH”,
“name”: “Telegram account”
}
}
},
{
“parameters”: {
“httpMethod”: “POST”,
“path”: “583b3f83-d6f1-4aed-acf0-a3dfc123b400”,
“options”: {}
},
“type”: “n8n-nodes-base.webhook”,
“typeVersion”: 2,
“position”: [
-1040,
-280
],
“id”: “e5123203-b7fd-4e32-8213-c86c3495a57b”,
“name”: “Webhook”,
“webhookId”: “583b3f83-d6f1-4aed-acf0-a3dfc123b400”
},
{
“parameters”: {
“chatId”: "
”,
“text”: “={{ $json.body.photo }}”,
“additionalFields”: {
“appendAttribution”: false
}
},
“id”: “ad2d6276-53c1-4605-b458-a3ad62173bf9”,
“name”: “Image Message”,
“type”: “n8n-nodes-base.telegram”,
“position”: [
120,
-280
],
“typeVersion”: 1.2,
“webhookId”: “92f1de0f-3b42-481d-9873-c5e877ac26f9”,
“credentials”: {
“telegramApi”: {
“id”: “iutFkKAfs9lZJIZH”,
“name”: “Telegram account”
}
}
},
{
“parameters”: {
“operation”: “toBinary”,
“sourceProperty”: “data”,
“options”: {
“fileName”: “={{ $json.result.file_path }}”
}
},
“id”: “a006c0ef-8918-4dfb-8391-a14c142ee645”,
“name”: “Convert to Image File”,
“type”: “n8n-nodes-base.convertToFile”,
“position”: [
-60,
-280
],
“typeVersion”: 1.1
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “17989eb0-feca-4631-b5c8-34b1d4a6c72b”,
“name”: “image_file_id”,
“type”: “string”,
“value”: “={{ $json.body.file.last().file_id }}”
}
]
},
“options”: {}
},
“id”: “9fb2e87a-a811-4155-a648-3f83c2f738ff”,
“name”: “Image Schema”,
“type”: “n8n-nodes-base.set”,
“position”: [
-600,
-280
],
“typeVersion”: 3.4
},
{
“parameters”: {
“resource”: “file”,
“fileId”: “={{ $json.image_file_id }}”
},
“id”: “0edf37b0-4876-496d-af29-f66944d6b440”,
“name”: “Get Image”,
“type”: “n8n-nodes-base.telegram”,
“position”: [
-420,
-280
],
“typeVersion”: 1.2,
“webhookId”: “be5ab8b9-ca7e-4ae2-a23a-df7a60302986”,
“credentials”: {
“telegramApi”: {
“id”: “iutFkKAfs9lZJIZH”,
“name”: “Telegram account”
}
}
},
{
“parameters”: {
“operation”: “binaryToPropery”,
“options”: {}
},
“id”: “c509e5fd-319a-4ddc-b066-b5b64b2c50da”,
“name”: “Extract from File to Base”,
“type”: “n8n-nodes-base.extractFromFile”,
“position”: [
-260,
-280
],
“typeVersion”: 1
},
{
“parameters”: {
“rules”: {
“values”: [
{
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “loose”,
“version”: 2
},
“conditions”: [
{
“id”: “342f0883-d959-44a2-b80d-379e39c76218”,
“operator”: {
“type”: “string”,
“operation”: “exists”,
“singleValue”: true
},
“leftValue”: “={{ $json.body.text }}”,
“rightValue”: “”
}
],
“combinator”: “and”
}
},
{
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “loose”,
“version”: 2
},
“conditions”: [
{
“id”: “ded3a600-f861-413a-8892-3fc5ea935ecb”,
“operator”: {
“type”: “string”,
“operation”: “contains”
},
“leftValue”: “={{ $json.headers.content-type}}”,
“rightValue”: “multipart/form-data”
}
],
“combinator”: “and”
},
“renameOutput”: true,
“outputKey”: “image”
}
]
},
“looseTypeValidation”: true,
“options”: {
“fallbackOutput”: “extra”
}
},
“id”: “988cb400-6861-483c-af6f-dfc07bc46726”,
“name”: “Message Router”,
“type”: “n8n-nodes-base.switch”,
“position”: [
-860,
-280
],
“typeVersion”: 3.2
},
{
“parameters”: {
“chatId”: “************”,
“text”: “=Unable to process your message.”,
“additionalFields”: {
“appendAttribution”: false
}
},
“id”: “f1a14ff4-ad1e-4a13-b264-8da09df1d444”,
“name”: “Error message”,
“type”: “n8n-nodes-base.telegram”,
“position”: [
-600,
-100
],
“typeVersion”: 1.2,
“webhookId”: “17ec733a-a48d-4b98-8451-fd758de95901”,
“credentials”: {
“telegramApi”: {
“id”: “iutFkKAfs9lZJIZH”,
“name”: “Telegram account”
}
}
}
],
“connections”: {
“Telegram”: {
“main”: [

]
},
“Webhook”: {
“main”: [
[
{
“node”: “Message Router”,
“type”: “main”,
“index”: 0
}
]
]
},
“Convert to Image File”: {
“main”: [
[
{
“node”: “Image Message”,
“type”: “main”,
“index”: 0
}
]
]
},
“Image Schema”: {
“main”: [
[
{
“node”: “Get Image”,
“type”: “main”,
“index”: 0
}
]
]
},
“Get Image”: {
“main”: [
[
{
“node”: “Extract from File to Base”,
“type”: “main”,
“index”: 0
}
]
]
},
“Extract from File to Base”: {
“main”: [
[
{
“node”: “Convert to Image File”,
“type”: “main”,
“index”: 0
}
]
]
},
“Message Router”: {
“main”: [
[
{
“node”: “Telegram”,
“type”: “main”,
“index”: 0
}
],
[
{
“node”: “Image Schema”,
“type”: “main”,
“index”: 0
}
],
[
{
“node”: “Error message”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “657284b9098fdf118c349334a8ed9c27af13341655e19cb223fa011ef53c5085”
}
}

Share the output returned by the last node

It shows a table with binary information and I can view the image, not sure what to paste here.

Information on your n8n setup

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

Do you mean something like:

I just tested it and was able to get the image in the chat.

Hi thanks for the reply, but the flow I use now, and partially works is this. Up until Message Router, I am unsure what to set to. have it process the POSTed PNG

Not sure if I’m understanding you right, but this is what I understood:

  • you want to have a webhook that may receive a JSON body or a binary
  • if you receive a JSON body, you wish to send the text as a message
  • if you receive a binary (an image), you wish to send it as a photo

If that’s what you want to do, the following does it:

Thank you for this, the Switch is working now, last step for me would be this

I have an error in the Send Photo node “Cannot read properties of undefined (reading ‘fileName’)”

This what I see in the Webhook, the image data you see is posted (using pyhton)

So it seams a small change still needed

It basicly comes down to this:

How to get n8n (telegram send photo node ) to pick up de photo/file on the left in this screen?

Try changing data0 to file in the Telegram image node.

1 Like

Yes, that was the change needed, thank you!

I now have a local ComyUI, with a brand new ComfyUI node I am working on, that can send an image to a webhook. The webhook is the one in my local n8n workflow, which will send it to my telegram channel.

Thanks again.

Please consider marking the reply as solution :slight_smile:

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