TemplatesModules
Back to Modules
Slack Me Icon

Slack Me
44433 Installs

By:
Send a Slack message when a command finishes inside a workspace!
README
Variables (3)
Scripts (1)
Source

Add the slackme command to your workspace that DMs you on Slack when your command finishes running.

1slackme npm run long-build

Setup

  1. Navigate to Create a Slack App and select "From an app manifest". Select a workspace and paste in the following manifest, adjusting the redirect URL to your Coder deployment:

    1{
    2  "display_information": {
    3    "name": "Command Notify",
    4    "description": "Notify developers when commands finish running inside Coder!",
    5    "background_color": "#1b1b1c"
    6  },
    7  "features": {
    8    "bot_user": {
    9      "display_name": "Command Notify"
    10    }
    11  },
    12  "oauth_config": {
    13    "redirect_urls": [
    14      "https://<your coder deployment>/external-auth/slack/callback"
    15    ],
    16    "scopes": {
    17      "bot": ["chat:write"]
    18    }
    19  }
    20}
  2. In the "Basic Information" tab on the left after creating your app, scroll down to the "App Credentials" section. Set the following environment variables in your Coder deployment:

    1CODER_EXTERNAL_AUTH_1_TYPE=slack
    2CODER_EXTERNAL_AUTH_1_SCOPES="chat:write"
    3CODER_EXTERNAL_AUTH_1_DISPLAY_NAME="Slack Me"
    4CODER_EXTERNAL_AUTH_1_CLIENT_ID="<your client id>
    5CODER_EXTERNAL_AUTH_1_CLIENT_SECRET="<your client secret>"
  3. Restart your Coder deployment. Any Template can now import the Slack Me module, and slackme will be available on the $PATH:

    1module "slackme" {
    2  source           = "registry.coder.com/modules/slackme/coder"
    3  version          = "1.0.2"
    4  agent_id         = coder_agent.example.id
    5  auth_provider_id = "slack"
    6}

Examples

Custom Slack Message

  • $COMMAND is replaced with the command the user executed.
  • $DURATION is replaced with a human-readable duration the command took to execute.
1module "slackme" {
2  source           = "registry.coder.com/modules/slackme/coder"
3  version          = "1.0.2"
4  agent_id         = coder_agent.example.id
5  auth_provider_id = "slack"
6  slack_message    = <<EOF
7šŸ‘‹ Hey there from Coder! $COMMAND took $DURATION to execute!
8EOF
9}