from __future__ import annotations def build_quick_reply_items(options: list[str]) -> list[dict]: items = [] for label in options[:13]: if not label or not label.strip(): continue safe_label = label.strip()[:20] items.append( { "type": "action", "action": {"type": "message", "label": safe_label, "text": label}, } ) return items def build_text_with_quick_reply(text: str, options: list[str]) -> dict: if not options: return {"type": "text", "text": text[:5000]} items = build_quick_reply_items(options) return { "type": "text", "text": text[:5000], "quickReply": {"items": items}, }