feat(gateway/mattermost): register COMMAND_REGISTRY as custom slash commands - #6298
Closed
zerone0x wants to merge 1 commit into
Closed
feat(gateway/mattermost): register COMMAND_REGISTRY as custom slash commands#6298zerone0x wants to merge 1 commit into
zerone0x wants to merge 1 commit into
Conversation
…ommands Fixes #6296 The Mattermost mobile client intercepts any message starting with '/' and attempts to execute it as a native slash command. Because the Hermes Mattermost adapter only listened on the WebSocket 'posted' stream, commands like /approve, /deny, /help returned 'Command with a trigger of X not found' on Android/iOS, breaking the approval flow. Mirror the Telegram (set_my_commands) and Slack (slack_subcommand_map) adapters: on connect, iterate COMMAND_REGISTRY filtered by _is_gateway_available() and POST each entry to /api/v4/commands with auto_complete, auto_complete_hint, and auto_complete_desc populated. Registration is opt-in via MATTERMOST_SLASH_COMMAND_URL (the callback URL the operator wires up to re-dispatch the slash command back into the channel) with optional MATTERMOST_TEAM_ID override — the team is otherwise discovered via GET users/{id}/teams. Existing triggers are deduped against GET teams/{team_id}/commands for idempotent restarts, and registration is capped at 50 commands to match the documented Telegram cap. All failures are non-fatal; the WebSocket fallback path still works for desktop/web clients.
Contributor
Author
|
Closing to keep open PR count manageable. Will resubmit if still relevant after triage. |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6296
Summary
MattermostAdapter.connect(), iterateCOMMAND_REGISTRY(filtered by_is_gateway_available) andPOST /api/v4/commandsfor each entry so the Mattermost mobile client no longer returns "Command with a trigger of X not found" for/approve,/deny,/help, etc.set_my_commands) and Slack (slack_subcommand_map) adapters — the centralCOMMAND_REGISTRYremains the single source of truth.auto_complete,auto_complete_hint(fromCommandDef.args_hint), andauto_complete_desc(fromCommandDef.description) so users get full autocomplete when typing/in any Mattermost client.Behavior
MATTERMOST_SLASH_COMMAND_URL— operators point this at a webhook that re-dispatches the slash command text back into the channel (or at the gateway's own webhook platform). Without it, the method returns early and nothing is registered, preserving existing deployments.MATTERMOST_TEAM_IDenv var, or falls back to the bot's first team fromGET users/{id}/teams.GET teams/{team_id}/commandsso restarts don't double-register.connect()— the WebSocket fallback path still works for desktop/web clients if registration fails.Test plan
MATTERMOST_SLASH_COMMAND_URL, start gateway, confirm log lineMattermost: slash commands registered (new=N, already_present=0, team=...).new=0, already_present=N(idempotent path)./in a DM with the bot — confirm autocomplete menu shows Hermes commands with descriptions.MATTERMOST_SLASH_COMMAND_URLunset — confirm startup is unchanged and no API calls to/commandsare made.