Skip to content

Implement slash (/) commands for Assistant #1

Description

@vanguard-hack

Feature Ticket: Slash Commands for Crime Analytics Assistant Chatbot

Summary

Add slash command support to the assistant chatbot's input bar. Users should be able to type / to trigger an autocomplete dropdown of predefined commands, select or type a command with arguments, and get a fast, structured response instead of relying purely on free-text natural language queries.


Background / Motivation

Officers repeatedly run the same categories of queries (FIR lookup, case status, suspect check, crime stats, etc.). Free-text queries work but are slower and less predictable. Slash commands give a fast, discoverable, keyboard-driven shortcut for the most common actions, similar to Slack/Notion/Linear command patterns.


Scope

In scope

  • Slash command autocomplete UI in the chat input bar
  • Command parsing/routing on submit
  • Backend handlers for the 10 approved commands (list below)
  • Role-based visibility/filtering of commands and results
  • Audit logging for data-sensitive commands

Out of scope (for this ticket)

  • Any command not in the approved list below
  • Voice input handling
  • Multi-language command aliases (future ticket)

Input Bar Placeholder Text

Default (empty state):

Ask a question or type / for commands...

When / is typed, placeholder is replaced by the live command dropdown (see UI behavior below).


Approved Slash Commands

Keep this list locked to these 10. Do not add more without a follow-up scoping discussion — the goal is a focused, low-friction set, not a full command palette.

Command Arguments Description Category
/fir [FIR number] Get FIR details and current status Lookup
/case [case ID] Case summary, IO assigned, current stage Lookup
/suspect [name or ID] Criminal record / antecedents check Lookup
/vehicle [registration no] Vehicle ownership & crime linkage check Lookup
/person [name or phone] Person search across connected records Lookup
/crime-stats [district/PS] [date range] Crime count summary by type Analytics
/hotspot [area] Crime hotspot data for a location Analytics
/wanted [name or area] Search wanted/absconding offenders list Alerts
/missing [name or ID] Missing person case lookup Alerts
/help List all available commands System
/clear Clear current chat context System

Note: /suspect and /person may return overlapping results depending on backend data sources. Confirm with data team whether these hit the same index before building separate handlers — may be mergeable into one command with a type filter.


UI Behavior

  1. Trigger: User types / as the first character in the input bar (or after clearing input).
  2. Dropdown appears: Shows all 10 commands, each with:
    • Command name (e.g., /fir)
    • Short description (e.g., "Get FIR details and status")
    • Expected argument hint, greyed out (e.g., [FIR number])
  3. Filtering: As the user continues typing after /, filter the list by matching command name (e.g., /fi → shows /fir).
  4. Selection:
    • Click/tap or arrow-key + Enter selects a command.
    • On selection, input bar auto-fills /command with cursor positioned after the space, ready for argument entry.
  5. Argument hint: While typing arguments, show the expected format as placeholder-style greyed text (e.g., /fir [FIR number] fades as user types real value).
  6. Submit: Enter or send button triggers parsing and routes to the relevant backend handler.
  7. Invalid command: If typed command doesn't match any of the 10, show inline suggestion for closest match (e.g., "Did you mean /fir?") rather than a hard error or falling silently into free-text mode. If no close match, fall back to treating the input as a normal natural-language query.
  8. Empty argument: If user submits a command with no argument (e.g., just /fir), prompt inline for the missing value rather than sending an invalid request to backend.

Command Parsing Logic (backend)

  • Detect leading / in submitted message.
  • Extract command token (up to first space) and match against the approved command list (case-insensitive).
  • Remaining text after the command = argument string.
  • Route to corresponding handler/service based on command.
  • For /crime-stats, argument string may contain two parts (location + date range) — parse via simple delimiter (comma or keyword like "from...to") rather than complex NLP; confirm exact input format with design before building parser.
  • If command not recognized, do not attempt backend routing — pass through to standard chatbot NLU pipeline.


Audit Logging

Every execution of /fir, /case, /suspect, /vehicle, /person, /wanted, and /missing must log:

  • User ID / badge number
  • Command + arguments used
  • Timestamp
  • Result returned (or reference ID to result)

This is required for compliance and internal review — same standard as any other sensitive data access on the platform.


Acceptance Criteria

  • Typing / in the input bar opens the command dropdown with all 10 commands visible
  • Dropdown filters correctly as user types after /
  • Selecting a command auto-fills the input with correct syntax and argument placeholder
  • All 10 commands route to correct backend handlers and return expected data
  • Invalid/unmatched commands fall back gracefully to normal chat (no hard errors)
  • Commands respect existing role-based access control
  • Sensitive commands are logged per audit requirements
  • /help returns an accurate, up-to-date list of all commands
  • /clear resets chat context without requiring page reload
  • Placeholder text displays correctly in default (non-/) state

Also for the UI designs, take inspiration from the below designs:

Image Image Image

Also the Assistant must be required to give out the latest info based on the slash commands,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions