Skip to content

feat(gateway/mattermost): register COMMAND_REGISTRY as custom slash commands - #6298

Closed
zerone0x wants to merge 1 commit into
NousResearch:mainfrom
zerone0x:fix/mattermost-slash-command-registration
Closed

feat(gateway/mattermost): register COMMAND_REGISTRY as custom slash commands#6298
zerone0x wants to merge 1 commit into
NousResearch:mainfrom
zerone0x:fix/mattermost-slash-command-registration

Conversation

@zerone0x

@zerone0x zerone0x commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #6296

Summary

  • On MattermostAdapter.connect(), iterate COMMAND_REGISTRY (filtered by _is_gateway_available) and POST /api/v4/commands for each entry so the Mattermost mobile client no longer returns "Command with a trigger of X not found" for /approve, /deny, /help, etc.
  • Mirrors the pattern already used by the Telegram (set_my_commands) and Slack (slack_subcommand_map) adapters — the central COMMAND_REGISTRY remains the single source of truth.
  • Populates auto_complete, auto_complete_hint (from CommandDef.args_hint), and auto_complete_desc (from CommandDef.description) so users get full autocomplete when typing / in any Mattermost client.

Behavior

  • Opt-in via 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.
  • Team resolution: MATTERMOST_TEAM_ID env var, or falls back to the bot's first team from GET users/{id}/teams.
  • Idempotent: dedupes against GET teams/{team_id}/commands so restarts don't double-register.
  • Capped at 50 commands, matching the Telegram cap documented in fix: cap Telegram menu at 50 commands — API rejects above ~60 #4006.
  • Non-fatal: wrapped in try/except in connect() — the WebSocket fallback path still works for desktop/web clients if registration fails.

Test plan

  • Set MATTERMOST_SLASH_COMMAND_URL, start gateway, confirm log line Mattermost: slash commands registered (new=N, already_present=0, team=...).
  • Restart gateway, confirm new=0, already_present=N (idempotent path).
  • In Mattermost Android, type / in a DM with the bot — confirm autocomplete menu shows Hermes commands with descriptions.
  • Leave MATTERMOST_SLASH_COMMAND_URL unset — confirm startup is unchanged and no API calls to /commands are made.

…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.
@zerone0x

Copy link
Copy Markdown
Contributor Author

Closing to keep open PR count manageable. Will resubmit if still relevant after triage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Mattermost adapter should register COMMAND_REGISTRY as custom slash commands with autocomplete

1 participant