← Back to PRs

#21482: feat(line): support rich message directives in text

by puritysb open 2026-02-20 00:42 View on GitHub →
channel: line size: M
## Summary Adds support for LINE rich message directives embedded directly in agent response text. This allows agents to create interactive LINE messages without using the `sendPayload` tool. ## Supported Directives ### Quick Replies (快捷回覆) ``` [[quick_replies: Option 1, Option 2, Option 3]] ``` - Appears as tappable buttons below the message - Great for simple choices (2-4 options) ### Location (位置資訊) ``` [[location: Place Name | Address | latitude | longitude]] ``` - Sends a location pin - Example: `[[location: Tokyo Tower | 4-2-8 Shibakoen | 35.6586 | 139.7454]]` ### Confirm Dialog (確認對話框) ``` [[confirm: Question text? | Yes Label | No Label]] ``` - Yes/No style confirmation - Example: `[[confirm: Delete this file? | Delete | Cancel]]` ### Buttons Menu (按鈕選單) ``` [[buttons: Title | Description | Label:action, Label:https://url...]] ``` - Custom button menu with postback or URI actions - Example: `[[buttons: Menu | Choose | Open:https://example.com, Refresh:refresh]]` ## Usage Example Agent response: ``` Would you like to continue? [[quick_replies: Yes, continue, No, cancel]] ``` LINE displays: ``` Would you like to continue? [Yes, continue] [No, cancel] <- tappable buttons ``` ## Test Plan ✅ 19 unit tests added (`extensions/line/src/directives.test.ts`): - Quick replies parsing (whitespace, multiline, case-insensitive) - Location parsing (coordinates, negative values, malformed input) - Confirm dialog parsing - Buttons with postback and URI actions - Combined directives - Edge cases (empty string, malformed, unclosed) All tests passing. ## Files Changed - `extensions/line/src/directives.ts` - Directive parser implementation - `extensions/line/src/channel.ts` - Integration with LINE message sending + agent prompt docs - `extensions/line/src/directives.test.ts` - Unit tests (NEW) ## Notes - macOS CI failure is unrelated to this PR (bluebubbles/telegram tests, not LINE) - Directives are stripped from the final text sent to LINE API - Gracefully ignores malformed directives (passes through as plain text) <!-- greptile_comment --> <h3>Greptile Summary</h3> Added text-based directive parser for LINE rich messages, enabling agents to create interactive UI elements without using the `sendPayload` tool. Implements 4 directives: `quick_replies`, `location`, `confirm`, and `buttons`. - New parser in `directives.ts` extracts directives from agent responses using regex patterns - Integration in `channel.ts` merges parsed directives with existing `LineChannelData` - Directives are stripped from final text sent to LINE API - 19 comprehensive unit tests cover happy paths, edge cases, and malformed input - When multiple template directives present (confirm/buttons), last one wins - Gracefully ignores malformed directives (passes through as plain text) - Agent prompt already documents additional directives (media_player, event, agenda, device, appletv_remote) that remain unimplemented <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - Clean implementation with proper type safety, comprehensive test coverage (19 tests), graceful error handling for malformed input, and correct integration with existing LINE channel infrastructure. The directive parser correctly matches the `LineChannelData` type structure, and the regex patterns properly handle the documented directive formats. No security vulnerabilities or logical errors identified. - No files require special attention <sub>Last reviewed commit: 1cbf3b6</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs