Slack slash command service written in Golang
git clone https://github.com/anubhavmishra/slack-slash-command.git
brew install ngrok/ngrok/ngrok
or
sudo unzip ~/Downloads/ngrok-stable-darwin-amd64.zip -d /usr/local/bin
Build the project
cd slack-slash-command
make build-service
The video below showcases how to create a Slack app and find the verification token.
https://user-images.githubusercontent.com/4024506/158033562-b41e8678-7151-492a-9cf8-47a28a76c204.mov
Set Slack token
cd slack-slash-command
export SLACK_VERIFICATION_TOKEN="SLACK TOKEN HERE"
cd slack-slash-command
./build/slack-slash-command
Expected output
2022/03/12 18:53:59 PORT environment variable not found defaulting to port 8080
2022/03/12 18:53:59 Server listening on port 8080
The slash command application is now listening on port 8080
In a new terminal window, run the command below
ngrok http 8080
Expected output
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Session Expires 1 hour, 59 minutes
Version 2.3.40
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://8dec-49-207-209-126.ngrok.io -> http://localhost:8080
Forwarding https://8dec-49-207-209-126.ngrok.io -> http://localhost:8080
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
Copy the https
address from the output. In this case, it's https://8dec-49-207-209-126.ngrok.io
/hello
https
address and add /receive
at the end of it.https
URL will look like this https://8dec-49-207-209-126.ngrok.io/receive
The video below showcases how to create a slash command.
https://user-images.githubusercontent.com/4024506/158033572-bac3294d-4b85-43f0-b38f-8bd7ef8d3869.mov
The video below showcases how to install a Slack app.
https://user-images.githubusercontent.com/4024506/158033577-8f542a28-f304-491f-a648-a42c055af37b.mov
/hello
to invoke the slash command. You should see a message "Hello World!" back from the "Slack Slash Command" application.The video below showcases how to install Slack application in a channel and invoke /hello
slash command to get a response back from the "Slack Slash Command" application.
https://user-images.githubusercontent.com/4024506/158033583-5e245540-0702-4b43-978d-21873a1c511e.mov
Thank you to Emily Goldfein for the Creating Slack Slash Commands using Go blog post as this project uses a lot of the code in the blog post. This project just removes the Open Weather Map API usage in the application and gives users a more generic example to create a Slack slash command application.