Trouble with passing JSON object (Telegram node)

Describe the problem/error/question

I’m trying to create a workflow that uses the Telegram node.
First using the Telegram trigger to get an inline request, then doing some web searching then returning results via inline callback. I’ve already been able to receive/send text messages with the Telegram node but now trying inline.

Trying to send InlineQueryResultPhotos (Telegram Bot API)
So each one needs “photo”, id, url_to_photo, url_to_thumbnail.

So after doing my websearch I have the following function block:

const results = [];

for (const item of $input.all()) {
  item.json.imagelist = results;

function grabimages(result, index) {
  results.push(["photo", index,, result.image.thumbnailLink]);

return $input.all();

I successfully get an array of results in imagelist into the input of the last node:

And here is my input to the Telegram node but then I get the error.

I’ve also tried to JSON.stringify the imagelist but that didn’t do it either.
I think I’m missing something very basic here. Any help would be appreciated!

What is the error message (if any)?

ERROR: Bad request - please check your parameters

Bad Request: can’t parse inline query result: Inline query result must be an object

The array should go like this

    "type": "photo",
    "id": "1",
    "title": "Result 1",
    "photo_url": "your_photo_url.jpeg", 
    "thumbnail_url": " ",
    "input_message_content": {
      "message_text": JSON.stringify($[0].login).replace(/^"|"$/g, '') 

Stringify the message_text value if youre passing a value from another node or you will get “Bad request: Can’t parse json encoded inline query results:


It doesn’t seem I need the input_message_content.
I’ll give it a shot with creating this type of array and report back!

Edit, yep that solved it, thank you!!

Modified my grabimages to below:

function grabimages(result, index) {
  results.push({ "type" : "photo", "id" : index, "photo_url" :, "thumbnail_url" : result.image.thumbnailLink});
1 Like

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