I am trying to send three photos using a node-red-contrib-telegrambot. My approach consists of the following steps:
- Generating the File Paths:
- The first function determines the file paths of the three images dynamically.
- It constructs an array of file paths based on a variable
number_of_pages
:
var number_of_pages = 1;
msg.payload = [
`/data/photos/${number_of_pages}.jpg`,
`/data/photos/${number_of_pages+1}.jpg`,
`/data/photos/${number_of_pages+2}.jpg`
];
return msg;
Processing the Images:
The paths are split, and each file is read individually.
After reading, the images are grouped together again.
Once joined, the msg.payload appears as an array of buffers:
2.2025, 22:10:08 node: debug 2
msg.payload : array[3]
[ buffer[3097142], buffer[1620527], buffer[1667224] ]
Formatting the Telegram Message:
- A function formats the message to be sent via the Telegram bot.
It encapsulates the buffer array within an object containing the chat_id, content, and type:
msg.payload = {
chat_id: 1099927519, //example
content: msg.payload,
type: "photo"
};
return msg;
Final node before sending;
msg.payload : Object
object
chat_id: 1099927519 //example
content: array[3]
type: "photo"
The error that i got;
Caught exception in sender node:
Error: EPARSE: Error parsing response: <html>
<head><title>414 Request-URI Too Large</title></head>
<body>
<center><h1>414 Request-URI Too Large</h1></center>
<hr><center>nginx/1.18.0</center>
</body>
</html>
when processing message:
{"payload":{"content":[{"type":"Buffer","data":[255,216,255,225,31,136,69,120,105,102,0,0,77,77,0,42,0,0,0,8,0,12,1,0,0,3,0,0,0,1,7,181,0,0,1,1,0,3,0,0,0,1,11,4
I also tried "sendMediaGroup" method but it didnt work.
Any suggestions?