Telegram reply keyboard with variable data

(The Niqabi Coder Mum) #1

Hi,

I am making a bot where I will need to make a custom request to Telegram for inline keyboard. I want to read data from Goggle Sheets, and send each item from Google Sheets as a button.

The problem is that the data in Google Sheets may vary. For example sometimes there may be just three items in the Sheets, so the Telegram inline keyboard will have three buttons. Sometimes it may be five or even ten.

So of course I can not hard code the custom request. Is there a way where I can use something like a for loop to create the JSON for the inline keyboard dynamically?

I thought about using the custom code block in Flowxo, but since I do not know the number of items coming back from Google Sheets in advance, I can not set up the inputs for the code block in advance.

Does anyone have a solution to this?

Thanks in advance

(Daniel Beckett) #2

Hi @nqcm

For help with coding, you may want to try a development community like Stack Overflow :slight_smile:

(The Niqabi Coder Mum) #3

Actually I am not asking for help with coding. I am asking how may input a varied number of “inputs” in the code block? Or create a Telegram inline keyboard without knowing in advance how many items may be returned from Google Sheets. Its a Floxo specific question.

(Daniel Beckett) #4

Hi @nqcm

Unfortunately, there isn’t a way to insert dynamic outputs at the moment.

If you know the maximum number of returned outputs then you could add them all in. For example, if you knew that there’d always be a maximum of 5 outputs you’d add them all in:

{{output1}}
{{output2}}
{{output3}}
{{output4}}
{{output5}}

Otherwise, you can output all of the data at once by not specifying a collection/data output.

{{output}}

For settings values this would place them all in at once, however, so the first method would be needed for setting specific inputs.