slackbot

package module
v0.0.0-...-6581e7e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2020 License: MIT Imports: 4 Imported by: 0

README

go-slackbot

Template for a golang slack bot via slack slash commands using apigateway and lambda

Overview

Handler function

Receives the slack slack command request. For long running tasks, executes a worker function with a custom payload.

Worker fucntion

Executed by handler function for longer running tasks

Setup workspace

Git clone this repository. git clone git@github.com:TomSED/go-slackbot.git

Run dep ensure to pull dependencies

Deployment & Configuration
  1. 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": "------"
}
  1. Create a /.env file according to /.env.template. Use token from above slack request for env variable SLACKBOT_AUTH_TOKEN:
$ export $(grep -v '^#' .env | xargs)
  1. Deploy
$ make deploy
  1. Configure your slack slash command request URL using the deployment output. Remember to append the /slackbot path screenshot

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendSlackMessage

func SendSlackMessage(message string, responseURL string) error

SendSlackMessage is for sending a response text message to a slack response url

Types

type LambdaWorkerEvent

type LambdaWorkerEvent struct {
	Message     string `json:"message,omitempty"`
	ResponseURL string `json:"responseURL,omitempty"`
	ChannelID   string `json:"channelID,omitempty"`
	UserID      string `json:"userID,omitempty"`
}

LambdaWorkerEvent is for Invoking another lambda directly from a lambda

type SlackTextMessage

type SlackTextMessage struct {
	Text string `json:"text,omitempty"`
}

SlackTextMessage is a container for the text message

Directories

Path Synopsis
workers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL