In this repository we build a simple slack bot to calculate age.
-
You must have a Slack Workspace and you must be an admin of that.
-
If you don't have it, create a new workspace.
-
Then go to https://api.slack.com/apps
-
Click on create an app and select from scratch.
-
Enter the name of your app and select the workspace for that app.
-
Then go to socket mode and click on enable socket mode.
-
Enter your token-name and generate the app token.
-
Copy you app token and save it in a text file to use it later.
-
Then go to event subscriptions.
-
Click on add bot user events.
-
Add required bot event subscriptions for the bot.
-
Now go to auth & permissions
-
click on add an OAuth Scope under Bot Token Scopes section.
-
Give necessary authorization and permission by selecting required OAuth scopes.
-
Click on install to workspace to install your bot to your workspace.
-
After installation, copy your Bot token and save it in a text file to use it later.
-
Initiate your go project and install the shomali11/slacker package by using following commands
go mod init github.com/usename/project-name go get "github.com/shomali11/slacker"
-
Clone the repository.
-
Replace App Token & Bot Token with your tokens.
-
Open terminal and run
go build
-
run
go run main.go
and if you the result as shown in picture below, it mean bot is running and connected to slack -
Open your Slack Workspace then open any chat channel and mention the bot and say "my yob is ". The bot will give you the age.