Random caption from file.txt for a message in telegram

I want to put a random title to each photo or video that I send via Telegram. Those titles I have saved in a list.
image

Here’s a formula you could use:

{{get(split(1.text; newline); floor(random * (length(split(1.text; newline)))) + 1)}}

This assumes 1.text is a bunch of lines of text.

Basically it will split the file into separate lines to make an array and determine how many lines there are.
Then, pick a random number between 1 and the number of lines.
Then, use that number to go and get that item from the array, which would correspond to a line number in the file.

Hope that helps, and makes sense!

3 Likes