Implement GraphQL Query to Fetch Available DuoChat Slash Commands
What does this MR do and why?
This MR creates a GraphQL query that can be used to receive the Duo Chat slash commands available for a particular user and a particular URL.
MR acceptance checklist
Screenshots or screen recordings
Note: Query name was changed to aiSlashCommands

How to set up and validate locally
You can test this with Graphiql locally
Here are some example queries
Any URL
User can obtain basic Duo Chat commands for any input into the URL field.
query {
aiSlashCommands(
url: "<ANY URL>",
) {
name
description
command
}
}
Special commands
The following are all special commands, which require Duo Enterprise enabled for the group of the URL that is passed in.
Vulnerabilities
Prerequisites:
- Vulnerability must be of
sasttype to receive the/vulnerability_explaincommand
Steps:
-
Create vulnerability via UI:
- Navigate to
Secure -> Vulnerability report -> Submit vulnerability - Required fields:
- Identifier code: e.g. "1228"
- URL: e.g. "https://cwe.mitre.org/data/definitions/1228.html"
- Navigate to
-
Update type in rails console:
# Convert to sast type
Vulnerability.last.update!(report_type: :sast)
- Test slash command availability:
query {
aiSlashCommands(
userId: "gid://gitlab/User/1"
) {
name
description
command
}
}
Jobs
Prerequisites:
- Job must be in failed state to receive
/troubleshootcommand - The easiest way to do this might be to go your Duo Enterprise group, click
Builds -> Jobson the sidebar,Create CI/CD configurationfile,Commit changes, and then update the last job to be failed manually in the rails console.
Ci::Build.last.update!(status: :failed)
query {
aiSlashCommands(
url: "<JOB URL>",
) {
name
description
command
}
}
Issues
query {
aiSlashCommands(
url: "<ISSUE URL>",
) {
name
description
command
}
}
Related to #497335 (closed)
Edited by Lesley Razzaghian