diff --git a/plugin/adapter.py b/plugin/adapter.py index 90341a8..3a37bcd 100644 --- a/plugin/adapter.py +++ b/plugin/adapter.py @@ -7547,12 +7547,24 @@ class RocketChatAdapter(BasePlatformAdapter): "style": "default", }) - # Create attachment with buttons + # Create attachment(s) with buttons — max 3 per row (UX: mobile readability) + MAX_BUTTONS_PER_ROW = 3 attachments = [{ "color": "#1d74f5", "title": "Please choose an option:", "actions": buttons, }] + if len(buttons) > MAX_BUTTONS_PER_ROW: + attachments = [] + for i in range(0, len(buttons), MAX_BUTTONS_PER_ROW): + chunk = buttons[i:i + MAX_BUTTONS_PER_ROW] + attachments.append({ + "color": "#1d74f5", + "actions": chunk, + }) + # First attachment gets the title + if attachments: + attachments[0]["title"] = "Please choose an option:" # Send message with buttons success = await self._post_message_with_retry(real_room_id, text, attachments=attachments)