cloudposse
slack-notifier
Go

Command line utility to send messages with attachments to Slack channels via Incoming Webhooks

Last updated Feb 9, 2026
79
Stars
18
Forks
13
Issues
0
Stars/day
Attention Score
38
Language breakdown
Go 94.7%
Makefile 2.7%
Dockerfile 2.6%
Files click to expand
README

slack-notifier

Command line utility to send messages with attachments to Slack channels via Incoming Webhooks.

GitHub Commit Status

Usage

NOTE: The module accepts parameters as command-line arguments or as ENV variables (or any combination of command-line arguments and ENV vars). Command-line arguments take precedence over ENV vars.

NOTE: The module supports up to 8 Fields in an attachment ###

| Command-line argument | ENV var | Description | |:----------------------|:--------------------|:-------------------------------------------------------------------------------------------------------------------------------------| | webhookurl | SLACKWEBHOOKURL | Slack Webhook URL | | username | SLACKUSER_NAME | Slack user name (the username from which the messages will be sent) | | iconemoji | SLACKICONEMOJI | Slack icon emoji for the user's avatar | | fallback | SLACK_FALLBACK | A plain-text summary of the attachment. This text will be used in clients that don't show formatted text | | color | SLACKCOLOR | An optional value that can either be one of good, warning, danger, or a color code (e.g._ #439FE0) | | channel | SLACK_CHANNEL | Slack channel to send to | | thread | SLACK_THREAD | Slack channel thread to send to | | pretext | SLACK_PRETEXT | Optional text that appears above the message attachment block | | authorname | SLACKAUTHOR_NAME | Small text to display the attachment author's name | | authorlink | SLACKAUTHORLINK | URL that will hyperlink the author's name. Will only work if authorname is present | | authoricon | SLACKAUTHORICON | URL of a small 16x16px image to the left of the author's name. Will only work if authorname is present | | title | SLACK_TITLE | The title is displayed as larger, bold text near the top of a message attachment | | titlelink | SLACKTITLE_LINK | URL for the title text to be hyperlinked | | text | SLACK_TEXT | Main text in a message attachment | | thumburl | SLACKTHUMB_URL | URL to an image file that will be displayed as a thumbnail on the right side of a message attachment | | footer | SLACK_FOOTER | Brief text to help contextualize and identify an attachment | | footericon | SLACKFOOTER_ICON | URL of a small icon beside the footer text | | imageurl | SLACKIMAGE_URL | URL to an image file that will be displayed inside a message attachment | | field1title | SLACKFIELD1_TITLE | Field1 title | | field1value | SLACKFIELD1_VALUE | Field1 value | | field1short | SLACKFIELD1_SHORT | An optional boolean indicating whether the value is short enough to be displayed side-by-side with other values (default false) | | field2title | SLACKFIELD2_TITLE | Field2 title | | field2value | SLACKFIELD2_VALUE | Field2 value | | field2short | SLACKFIELD2_SHORT | An optional boolean indicating whether the value is short enough to be displayed side-by-side with other values (default false) | | field3title | SLACKFIELD3_TITLE | Field3 title | | field3value | SLACKFIELD3_VALUE | Field3 value | | field3short | SLACKFIELD3_SHORT | An optional boolean indicating whether the value is short enough to be displayed side-by-side with other values (default false) | | field4title | SLACKFIELD4_TITLE | Field4 title | | field4value | SLACKFIELD4_VALUE | Field4 value | | field4short | SLACKFIELD4_SHORT | An optional boolean indicating whether the value is short enough to be displayed side-by-side with other values (default false) | | field5title | SLACKFIELD5_TITLE | Field5 title | | field5value | SLACKFIELD5_VALUE | Field5 value | | field5short | SLACKFIELD5_SHORT | An optional boolean indicating whether the value is short enough to be displayed side-by-side with other values (default false) | | field6title | SLACKFIELD6_TITLE | Field6 title | | field6value | SLACKFIELD6_VALUE | Field6 value | | field6short | SLACKFIELD6_SHORT | An optional boolean indicating whether the value is short enough to be displayed side-by-side with other values (default false) | | field7title | SLACKFIELD7_TITLE | Field7 title | | field7value | SLACKFIELD7_VALUE | Field7 value | | field7short | SLACKFIELD7_SHORT | An optional boolean indicating whether the value is short enough to be displayed side-by-side with other values (default false) | | field8title | SLACKFIELD8_TITLE | Field8 title | | field8value | SLACKFIELD8_VALUE | Field8 value | | field8short | SLACKFIELD8_SHORT | An optional boolean indicating whether the value is short enough to be displayed side-by-side with other values (default false) | | field9title | SLACKFIELD9_TITLE | Field9 title | | field9value | SLACKFIELD9_VALUE | Field9 value | | field9short | SLACKFIELD9_SHORT | An optional boolean indicating whether the value is short enough to be displayed side-by-side with other values (default false) | | field10title | SLACKFIELD10_TITLE | Field10 title | | field10value | SLACKFIELD10_VALUE | Field10 value | | field10short | SLACKFIELD10_SHORT | An optional boolean indicating whether the value is short enough to be displayed side-by-side with other values (default false) |

build the Go program locally

go get

CGO_ENABLED=0 go build -v -o "./dist/bin/slack-notifier" *.go

run locally with ENV vars

export SLACKWEBHOOKURL="https://hooks.slack.com/services/XXXXXXXX/XXXXXXXX/XXXXXXXXXXXXXXXXXXXXXX"
export SLACKUSERNAME="CodeFresh"
export SLACK_IC
export SLACK_FALLBACK="Deployed to Staging environment"
export SLACK_COLOR="good"
export SLACK_PRETEXT="Added XYZ to feature-104"
export SLACKAUTHORNAME="Auto Deploy Robot"
export SLACKAUTHORLINK="https://cloudposse.com/wp-content/uploads/sites/29/2018/02/small-cute-robot-square.png"
export SLACKAUTHORICON="https://cloudposse.com/wp-content/uploads/sites/29/2018/02/small-cute-robot-square.png"
export SLACK_TITLE="Environment Updated"
export SLACKTITLELINK="http://demo1.cloudposse.com"
export SLACK_TEXT="The latest changes have been deployed"
export SLACKTHUMBURL="https://cloudposse.com/wp-content/uploads/sites/29/2018/02/SquareLogo2.png"
export SLACK_FOOTER="Helm Deployment"
export SLACKFOOTERICON="https://cloudposse.com/wp-content/uploads/sites/29/2018/02/kubernetes.png"
export SLACKFIELD1TITLE="Environment"
export SLACKFIELD1VALUE="Staging"
export SLACKFIELD1SHORT="true"
export SLACKFIELD2TITLE="Namespace"
export SLACKFIELD2VALUE="feature-104"
export SLACKFIELD2SHORT="true"

./dist/bin/slack-notifier

run locally with command-line arguments

./dist/bin/slack-notifier \
    -webhook_url "https://hooks.slack.com/services/XXXXXXXX/XXXXXXXX/XXXXXXXXXXXXXXXXXXXXXX" \
    -user_name "CodeFresh" \
    -iconemoji ":whitecheck_mark:" \
    -fallback "Deployed to Staging environment" \
    -color "good" \
    -pretext "Added XYZ to feature-104" \
    -author_name "Auto Deploy Robot" \
    -author_link "https://cloudposse.com/wp-content/uploads/sites/29/2018/02/small-cute-robot-square.png" \
    -author_icon "https://cloudposse.com/wp-content/uploads/sites/29/2018/02/small-cute-robot-square.png" \
    -title "Environment Updated" \
    -title_link "http://demo1.cloudposse.com" \
    -text "The latest changes have been deployed" \
    -thumb_url "https://cloudposse.com/wp-content/uploads/sites/29/2018/02/SquareLogo2.png" \
    -footer "Helm Deployment" \
    -footer_icon "https://cloudposse.com/wp-content/uploads/sites/29/2018/02/kubernetes.png" \
    -field1_title "Environment" \
    -field1_value "Staging" \
    -field1_short true \
    -field2_title "Namespace" \
    -field2_value "feature-104" \
    -field2_short true

build the Docker image

NOTE: it will download all Go dependencies and then build the program inside the container (see Dockerfile)
docker build --tag slack-notifier  --no-cache=true .

run in a Docker container with ENV vars

docker run -i --rm \
    -e SLACKWEBHOOKURL="https://hooks.slack.com/services/XXXXXXXX/XXXXXXXX/XXXXXXXXXXXXXXXXXXXXXX" \
    -e SLACKUSERNAME="CodeFresh" \
    -e SLACK_IC \
    -e SLACK_FALLBACK="Deployed to Staging environment" \
    -e SLACK_COLOR="good" \
    -e SLACK_PRETEXT="Added XYZ to feature-104" \
    -e SLACKAUTHORNAME="Auto Deploy Robot" \
    -e SLACKAUTHORLINK="https://cloudposse.com/wp-content/uploads/sites/29/2018/02/small-cute-robot-square.png" \
    -e SLACKAUTHORICON="https://cloudposse.com/wp-content/uploads/sites/29/2018/02/small-cute-robot-square.png" \
    -e SLACK_TITLE="Environment Updated" \
    -e SLACKTITLELINK="http://demo1.cloudposse.com" \
    -e SLACK_TEXT="The latest changes have been deployed" \
    -e SLACKTHUMBURL="https://cloudposse.com/wp-content/uploads/sites/29/2018/02/SquareLogo2.png" \
    -e SLACK_FOOTER="Helm Deployment" \
    -e SLACKFOOTERICON="https://cloudposse.com/wp-content/uploads/sites/29/2018/02/kubernetes.png" \
    -e SLACKFIELD1TITLE="Environment" \
    -e SLACKFIELD1VALUE="Staging" \
    -e SLACKFIELD1SHORT="true" \
    -e SLACKFIELD2TITLE="Namespace" \
    -e SLACKFIELD2VALUE="feature-104" \
    -e SLACKFIELD2SHORT="true" \
    slack-notifier

References

  • https://get.slack.help/hc/en-us/articles/115005265063-Incoming-WebHooks-for-Slack
  • https://api.slack.com/incoming-webhooks
  • https://api.slack.com/docs/message-attachments
  • https://api.slack.com/docs/message-formatting
  • https://www.webpagefx.com/tools/emoji-cheat-sheet

Help

Got a question?

File a GitHub issue, send us an email or reach out to us on Gitter.

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Developing

If you are interested in being a contributor and want to get involved in developing slack-notifier, we would love to hear from you! Shoot us an email.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

1. Fork the repo on GitHub 2. Clone the project to your own machine 3. Commit changes to your own branch 4. Push your work back up to your fork 5. Submit a Pull request so that we can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a pull request!

License

APACHE 2.0 © 2018 Cloud Posse, LLC

See LICENSE for full details.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

slack-notifier is maintained and funded by [Cloud Posse, LLC][website].

Cloud Posse

Like it? Please let us know at

We love Open Source Software!

See [our other projects][community] or [hire us][hire] to help build your next cloud platform.

[website]: https://cloudposse.com/ [community]: https://github.com/cloudposse/ [hire]: https://cloudposse.com/contact/

Contributors

| [![Erik Osterman][erikimg]][erikweb]
[Erik Osterman][erikweb] | [![Andriy Knysh][andriyimg]][andriyweb]
[Andriy Knysh][andriy
web] | |-------------------------------------------------------|------------------------------------------------------------------|

[erik_img]: http://s.gravatar.com/avatar/88c480d4f73b813904e00a5695a454cb?s=144 [erik_web]: https://github.com/osterman/ [andriy_img]: https://avatars0.githubusercontent.com/u/7356997?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 [andriy_web]: https://github.com/aknysh/

🔗 More in this category

© 2026 GitRepoTrend · cloudposse/slack-notifier · Updated daily from GitHub