10

I'm writing a telegram bot but I have a question. For now my bot will search for an image based on user request, but if I the bat found more than one image I want to send to the user a list of image with a link for search that iamge. Eg.

/command mickey mouse .... image 1.... I found more than one image, please be more specific [link to image 2] [link to image 3]

If the user will click the link I need to autosend message with the command and the name of the new image.

Is possible? I tried to add an hyperlink to the telegram api but i will open in the browser and send me a json with call status of the api.

Davide Martelli
  • 179
  • 1
  • 3
  • 9

2 Answers2

6

For inline mode you can simply return a list of image results that will be displayed as kind of a popup on top of keyboard.

For conversation mode you have options:

1) Return images as inline keyboard attachment to a message with array of buttons each having callback_data parameter or switch_inline_query_current_chat or url parameter. Handle one of this to display the image.

2) Return message text as HTML with list of links in form of: <a href="https://t.me/YOUR_BOT?start=image-123456789">image name</a>

Then you can parse the start command and extract image ID. This has disadvantage that user would need to click the "START" button every time after he clicked the link.

You can use the 2nd approach with inline mode as well.

In my @DebtsTrackerBot I use both callbacks & switch_inline_query_current_chat for similar task.

Alexander Trakhimenok
  • 6,019
  • 2
  • 27
  • 52
  • 1
    thanks, but giving the start button is not a valid solution, too much difficult for user I think, i think that for now I export only a list of images as simple text so the user can make a copy/paste to get the correct one – Davide Martelli Sep 20 '17 at 11:42
4

We can vote the suggestion for TelegramBotApi: https://bugs.telegram.org/c/3901

Yuriy Litvin
  • 101
  • 2
  • 3