Template for a golang slack bot via slack slash commands using apigateway and lambda
Receives the slack slack command request. For long running tasks, executes a worker function with a custom payload.
Executed by handler function for longer running tasks
Git clone this repository.
git clone git@github.com:TomSED/go-slackbot.git
Run dep ensure to pull dependencies
- Create a slack command in your Slack App. Executing the command should send a POST request with payload that looks something like this:
{
"token": "example",
"team_id": "------",
"team_domain": "------",
"channel_id": "------",
"channel_name": "------",
"user_id": "------",
"user_name": "------",
"command": "/slackbot",
"text": "test",
"api_app_id": "------",
"is_enterprise_install": "------",
"response_url": "https://hooks.slack.com/commands/example/example/example",
"trigger_id": "------"
}
- Create a
/.envfile according to/.env.template. Usetokenfrom above slack request for env variableSLACKBOT_AUTH_TOKEN:
$ export $(grep -v '^#' .env | xargs)- Deploy
$ make deploy