Skip to main content
Version: 1.10

Discord for self-hosted Botkube

Prerequisites​

  • Botkube CLI installed according to the Getting Started guide
  • Access to Kubernetes cluster
  • Discord server account

Install Botkube to the Discord Server​

Follow the steps below to install Botkube Discord app to your Discord server.

Create Botkube app at your Discord Server​

  1. Reach https://discordapp.com/developers/applications.

    discord_applications_portal

  2. Create a "New Application" named Botkube and add a bot named Botkube into the Application.

    discord_create_new

  3. Copy the Application APPLICATION ID and export it as the DISCORD_BOT_ID environment variable.

    export DISCORD_BOT_ID={APPLICATION_ID}

    discord_copy_client_id

  4. Add a description - Botkube helps you monitor your Kubernetes cluster, debug critical deployments and gives recommendations for standard practices by running checks on the Kubernetes resources..

    Set the Botkube icon (Botkube icon can be downloaded from this link).

    Click on Save Changes to update the Bot.

  5. Now, reach the Bot page and Click Add Bot to add a Discord Bot to your application.

    discord_add_bot

  6. After Bot creation, now you can see a bot is added to your application. Click on the Reset Token button.

    discord_bot_created

  7. Copy the Token and export it as the DISCORD_TOKEN environment variable.

    export DISCORD_TOKEN={TOKEN}
  8. Go to the OAuth2 page. Generate the URL with suitable permissions using the OAuth2 URL Generator available under the OAuth2 section to add bot to your Discord server.

    discord_bot_scope

    the generated URL contains YOUR_CLIENT_ID, Scope and permission details.

    https://discord.com/api/oauth2/authorize?client_id={YOUR_CLIENT_ID}&permissions={SET_OF_PERMISSIONS}&scope=bot
  9. Copy and Paste the generated URL in a new tab, select the discord server to which you want to add the bot, click Continue and Authorize Bot addition.

    discord_bot_auth

    discord_bot_auth_2

  10. Switch to the Discord app. Navigate to User settings and select Advanced tab.

    Enable the Developer Mode.

    discord_developer_mode

  11. Create a new channel or select an existing one and copy the CHANNEL ID.

    To get the channel ID, right-click on a channel you want to receive notification in and click on Copy ID.

    discord_copy_channel_id.png

    Copy the channel ID and export it as the DISCORD_CHANNEL_ID environment variable.

    export DISCORD_CHANNEL_ID={ID}
  12. Now, go ahead and install the Botkube backend on your Kubernetes cluster.

note

Follow the first 4 mins of this Video Tutorial to understand the process visually.

Install Botkube in Kubernetes cluster​

To deploy Botkube agent in your cluster, run:

export CLUSTER_NAME={cluster_name}
export ALLOW_KUBECTL={allow_kubectl}

botkube install --version v1.10.0 \
--set communications.default-group.discord.enabled=true \
--set communications.default-group.discord.channels.default.id=${DISCORD_CHANNEL_ID} \
--set communications.default-group.discord.botID=${DISCORD_BOT_ID} \
--set communications.default-group.discord.token=${DISCORD_TOKEN} \
--set settings.clusterName=${CLUSTER_NAME} \
--set 'executors.k8s-default-tools.botkube/kubectl.enabled'=${ALLOW_KUBECTL}

where:

  • DISCORD_CHANNEL_ID is the channel name where @Botkube needs to send notifications,
  • DISCORD_BOT_ID is the Botkube Application Client ID,
  • DISCORD_TOKEN is the Token you received after adding Botkube bot to your Discord Application,
  • CLUSTER_NAME is the cluster name set in the incoming messages,
  • ALLOW_KUBECTL set true to allow kubectl command execution by Botkube on the cluster.

Configuration syntax is explained here. All possible installation parameters are documented here.

Send @Botkube ping in the channel to see if Botkube is running and responding.

Remove Botkube from Discord Server​

  • Go to Discord Developers Portal Applications page,
  • Click on "Botkube" and click on "Delete App" button.

Remove Botkube from Kubernetes cluster​

Execute the following command to completely remove Botkube and related resources from your cluster:

botkube uninstall