<img alt=
Hey Anci
Interesting use case! At Hashlogics, we've been actively working with dynamic Telegram UIs, so I thought I'd share some thoughts.
For what you're aiming to do, the key is structuring the inline_keyboard
as an array of arrays, where each inner array represents a row of buttons. Telegram requires this nested structure, even when the data is dynamic.
If your aggregator is providing multiple separate arrays, consider using a custom JSON builder (or a simple code module) to manually define the row layout like this:
"inline_keyboard": [
[ { "text": "button_1", "callback_data": "1" } ],
[ { "text": "button_2", "callback_data": "2" }, { "text": "button_3", "callback_data": "3" } ],
[ { "text": "button_4", "callback_data": "4" }, { "text": "button_5", "callback_data": "5" } ]
]
This approach allows you to send all rows within a single message. We've been exploring similar workflows recently, involving dynamic button generation connected to Google Sheets and AI prompts, so feel free to ask if you run into any issues!
Hi, thank you for your suggestion!
The approach makes sense, but I have one important constraint:
The number of buttons is dynamic — they are pulled from a Google Sheet, and the amount can change frequently.
Sometimes there are 3 buttons, sometimes 7, sometimes even 12+.
That’s why I’m specifically looking for a fully dynamic solution, where the grouping into rows (e.g. 2 buttons per row) happens automatically, without manually hardcoding JSON rows.
What I’m trying to achieve:
- Loop through the dynamic list of buttons
- Group them into rows of 2 (last row can have 1 if needed)
- Build the final
inline_keyboard
JSON All of this should happen automatically inside callin.io, without needing to predefine the layout
Any working example, suggestion, or JavaScript snippet inside callin.io would be super helpful!
Thanks in advance!
Welcome to the callin.io community!
I've developed a new module for you that allows splitting an array (of any type, including collections) into multiple sub-arrays or bundles.
Access it here: [Free App] My Toolbox of Useful Modules
Hope this is helpful! Please let me know if you have any further questions or encounter any issues. P.S.: Investing some time in the tutorials available in the callin.io Academy can significantly reduce the time and frustration involved in using callin.io!
Hi, thank you so much for sharing your custom Chunk Array module — it’s a great idea and I really appreciate your contribution!
I’ve been trying to use it to split a list of Telegram inline keyboard buttons into multiple rows (e.g. 2 buttons per row). The module does produce a nested array like this (output simplified):
-
First row:
"{"text":"Button 1","callback_data":"architecture"}"
"{"text":"Button 2","callback_data":"cafe"}"
Which looks structurally correct. However, when I pass this to the Telegram bot module, the buttons don’t render.
As far as I understand, Telegram expects actual JSON objects, not strings. Like this:
[
[
{ “text”: “Button 1”, “callbackdata”: “architecture” },
{ “text”: “Button 2”, “callbackdata”: “cafe” }
]
]
So I think the issue is that the elements inside each sub-array are stringified JSON, not real objects.
I tried a few things inside callin.io:
- using Parse JSON inside an Iterator
- using Create JSON after chunking
But I couldn’t get the result Telegram accepts — maybe I’m missing something or misapplying the tools.
For reference, I’m attaching two screenshots that hopefully help illustrate the issue more clearly:
- First screenshot – Array Aggregator output:
You can see that each button is a proper JSON object with fields liketext
andcallback_data
. This structure looks clean and valid, but it’s not grouped into rows, so I’m not sure how to prepare it for Telegram’sinline_keyboard
format (which expects an array of arrays). - Second screenshot – Chunk Array output:
This one does split the array into chunks (2 per row), which is great! But the problem is that the items inside each chunk are stringified JSON — not actual objects. That seems to be why Telegram doesn’t render them.
If you have any tips on how to convert those strings into actual objects, I’d be really grateful!
Thanks again for your help
If you need to combine them, place them within an iterator followed by a text aggregator, using a comma as the delimiter.
You can bypass the Iterator module if you select "Output Bundles: Yes".
Text Aggregator:
Example Output:
Another approach is to utilize a Text Parser module, though this is considered a more advanced technique.
Hope this assists you! Please let me know if you have any further questions or encounter any issues. P.S.: Investing some time in the tutorials available on the callin.io Academy can significantly reduce the time and frustration involved in using callin.io!