← Back to PRs

#19957: feat(mattermost): add interactive buttons support

by tonydehnke open 2026-02-18 10:31 View on GitHub →
docs channel: mattermost size: XL
## Summary Adds interactive button support, directory adapter, and channel name resolution for Mattermost. **Interactive buttons:** - HMAC-SHA256 token verification for secure button callbacks - HTTP callback handler registered via `registerPluginHttpRoute` - Button click completion: replaces buttons with "✓ **Button Name** selected by @user" - Immediate agent response to button clicks via `dispatchButtonClick` pipeline - Localhost-only validation for callback requests - Stable HMAC secret derived from bot token (works across CLI/gateway) - Sorted-key HMAC generation (Mattermost reorders context keys) - `sanitizeActionId()` strips hyphens/underscores from IDs ([Mattermost routing bug](https://github.com/mattermost/mattermost/issues/25747)) - 2D→1D button array flattening (core sends `Array<Array<Button>>` for Telegram row layout) - Empty-name button filter (prevents white-box rendering) **Directory adapter:** - Channel/user name resolution via `listGroups` and `listPeers` - Multi-account support with deduplication by token - Graceful fallback when accounts are unavailable - `#channel-name` and bare names trigger directory lookup (not 403) **Channel actions:** - `listActions` returns `["send", "react"]` - `supportsButtons`, `handleAction` for the `ChannelPlugin` interface - Send action with optional button attachments **Config & types:** - Zod schema for `interactions.callbackBaseUrl` - TypeScript types for interactions config on `MattermostAccountConfig` **Also includes:** - `updateMattermostPost` for modifying existing posts (button completion) - `props` passthrough in `createMattermostPost` for attachments - `parseMattermostTarget` with channel-name and `isMattermostId` support - `fetchMattermostChannelByName` and `fetchMattermostUserTeams` client methods - Documentation for buttons and directory adapter in `docs/channels/mattermost.md` - Comprehensive test coverage (98 tests across 7 test files) ## AI-assisted Built with Claude Code. Fully tested locally on a live Mattermost instance (button rendering, HMAC verification, click handling, agent response confirmed end-to-end). ## Test plan - [x] `pnpm check` passes - [x] `pnpm test` passes (98/98 extension tests) - [x] Test button rendering in Mattermost channel - [x] Test button click callback and HMAC verification - [x] Test button completion (replacement text after click) - [x] Test agent responds to button selection - [x] Test `sanitizeActionId` with hyphenated/underscored IDs - [x] Test directory resolution (channel names, user lookup)

Most Similar PRs