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
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).
- Open MR in GitPod
- Wait for port 3000
- Make port 3000 publicly accessible
- Log in to the Discord Developer Dashboard
- Create a new application
- Add a bot user to the application (Is done in the
Bot
side-nav tab) - Note the bot token, if it is not visisble, use
Reset Token
to get it - Switch to the
OAuth2 / URL Generator
tab - Select
bot
andapplications.commands
scopes - 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)
- Select a GitLab project and go to the settings
- Open settings for
Discord slash commands
- Enter the bot token you noted before
- Enter the application id (can be copied from the
General information
tab in the Discord Developer Dashboard for your application) - Enter the public key (also found in
General information
) - 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) - Save changes
- 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
) - Save changes
Validate
- Switch to Discord and select the guild you created for testing
- Verify that there is a
/chatops
command - Execute
/chatops help
(thehelp
will be in theinput
parameter, thats normal) - You should get a message with a link to connect your account (it should be ephemeral)
- Click the link and connect your account
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #367722
Edited by Niklas van Schrick