#21482: feat(line): support rich message directives in text
channel: line
size: M
Cluster:
Message Sending Hooks Enhancement
## 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
#22844: feat(line): add push-only deliveryMode
by loiie45e · 2026-02-21
74.8%
#17327: fix: LINE mixed rich reply order is reversed
by MisterGuy420 · 2026-02-15
72.6%
#16733: fix(ui): avoid injected newlines when tool output is hidden
by jp117 · 2026-02-15
71.5%
#14274: feat: add collapseReplyPayloads to collapse multi-message replies
by Henry-Roff-AI · 2026-02-11
71.3%
#16089: fix(tts): clarify directive syntax in prompts and strip malformed tags
by kmixter · 2026-02-14
70.4%
#17244: fix: strip TTS tags from agent replies before delivery (#14652)
by robbyczgw-cla · 2026-02-15
70.1%
#23621: fix(LINE): keep startAccount promise alive to prevent auto-restart ...
by ttakanawa · 2026-02-22
69.9%
#21271: fix(commands): pass channel/capabilities/shell/os to runtime in com...
by evansantos · 2026-02-19
69.3%
#18876: fix(outbound): strip DSML function-call markup before delivery
by BinHPdev · 2026-02-17
68.7%
#23073: fix(ui): strip reply directive tags from assistant messages in WebC...
by x4v13r1120 · 2026-02-22
68.5%