Random Photo in Telegram Bot

(MHDI) #1

Hey
i want make a bot show radnom photos
for example user sends /photo and bot sends a random photo of urls i set in.
how can make this bot with code? or another way?

(Karen Barker) #2

Hi there,

The best way to send a random item to the user is to the our random number generator and a google sheet.

All you would need to do is:

  • Add an “ID” field on the google sheet with the same range of numbers as you’re using in your number generator - e.g. 1 - 10 and a 2nd field for your URL.
  • When the user then triggers your flow add a task Generate Random Number. This will choose a number within your range.
  • Search for the “ID” in the google sheet and then send your image based on the URL returned for that ID.

Hope that helps. :thumbsup:

(MHDI) #3

I should test this
thanks for help
And how can send gifs to users?
When i select an URL thats gif image it’s without animation

#4

@mhdi did you ever figure this out?

@KarenBarker ?

(Karen Barker) #5

@gwalsh

In order to send an animated gif in Telegram you will need to do a Custom Request as it needs to be sent as a document.

There’s a flow here which you can install to show how to create the custom request for this.

Hope this helps :slight_smile: