Skip to content

Draft: Add Support for ChatOps in Discord

What does this MR do and why?

This adds the possibility to use GitLab ChatOps from the Discord Platform.

Screenshots or screen recordings

Discord

image

image

How to set up and validate locally

Requirements

  • GDK is externally reachable
  • Discord Account

Setup

This instructions cover the setup on GitPod, as locally will be different for everyone (making the GDK externally available).

  1. Open MR in GitPod
  2. Wait for port 3000
  3. Make port 3000 publicly accessible
  4. Log in to the Discord Developer Dashboard
  5. Create a new application
  6. Add a bot user to the application (Is done in the Bot side-nav tab)
  7. Note the bot token, if it is not visisble, use Reset Token to get it
  8. Switch to the OAuth2 / URL Generator tab
  9. Select bot and applications.commands scopes
  10. Open the generated URL in a new tab and add/authorize the bot to a guild you can manage (I suggest creating a test guild for that)
  11. Select a GitLab project and go to the settings
  12. Open settings for Discord slash commands
  13. Enter the bot token you noted before
  14. Enter the application id (can be copied from the General information tab in the Discord Developer Dashboard for your application)
  15. Enter the public key (also found in General information)
  16. Enter the guild id of the guild you added the bot to (have developer mode enabled [User Settings -> Advanced -> turn Developer Mode on], rightclick on your server icon and use Copy ID from the menu)
  17. Save changes
  18. Switch to the Discord Developer Dashboard and fill in the Interactions Endpoint URL (https://3000-<workspace>.gitpod.io/api/v4/projects/<project-id>/integrations/discord_slash_commands/trigger)
  19. Save changes

Validate

  1. Switch to Discord and select the guild you created for testing
  2. Verify that there is a /chatops command
  3. Execute /chatops help (the help will be in the input parameter, thats normal)
  4. You should get a message with a link to connect your account (it should be ephemeral)
  5. Click the link and connect your account
  6. Execute /chatops help again and see that the command gets executed properly

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #367722

Edited by Niklas van Schrick

Merge request reports