- main.go - Server setup and route handling.
- slack/sendMessage.go - Interactions with the slack api
- experiment/main.go - Just a test of the slack api
- Run
git clone git@github.com:HunterHeston/badger-slack.git
. - Create an
.env
file based on.env.example
at the project root. - You may need to run
go get
to install dependencies. - Run
go run .
from the root directory. - In another terminal run either of the commands from the "Testing" section.
I found these steps and was able to get it working. Your milage may very.
- Go to the Slack API website.
- Click on the "Create New App" button to create a new Slack app.
- Choose a name and a workspace for your app.
- In the "Add features and functionality" section, click on "Bots" and add a new bot user to your app.
- In the "Install App" section, click on the "Install App to Workspace" button to install your app in your workspace.
- After installation, you'll be redirected to a page with your Slack API token. Copy this token and store it securely.
- echo framework for Go.
- slack-go a community maintained slack API as a library.
- dotenv parse and process .env files.
Quick and dirty testing to start:
curl -X POST \
http://localhost:3000/record \
-H 'Content-Type: application/json' \
-d '{
"RecordType": "Bounce",
"MessageStream": "outbound",
"Type": "SpamNotification",
"TypeCode": 512,
"Name": "Spam notification",
"Tag": "",
"Description": "The message was delivered, but was either blocked by the user, or classified as spam, bulk mail, or had rejected content.",
"Email": "zaphod@example.com",
"From": "notifications@honeybadger.io",
"BouncedAt": "2023-02-27T21:41:30Z"
}'
curl -X POST \
http://localhost:3000/record \
-H 'Content-Type: application/json' \
-d '{
"RecordType": "Bounce",
"MessageStream": "outbound",
"Type": "HardBounce",
"TypeCode": 1,
"Name": "Hard bounce",
"Tag": "Test",
"Description": "The server was unable to deliver your message (ex: unknown user, mailbox not found).",
"Email": "arthur@example.com",
"From": "notifications@honeybadger.io",
"BouncedAt": "2019-11-05T16:33:54.9070259Z"
}'