reminderbot

package module
v0.0.0-...-2d346a5 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: MIT Imports: 9 Imported by: 0

README

Slack Bot SMS Reminders

This project is primarily an experiment and learning tool for playing with slack bots and AWS Lambda. Please do not actually use this, it's just not that good :-)

Setup

  1. Create a new app at https://api.slack.com
  2. If you do not already have a Nexmo account, register for one at https://www.nexmo.com
  3. Copy aws.env.example to aws.env
  4. Edit aws.env and populate with appropriate values
  5. Make sure you have Docker and Docker Compose installed
  6. Run make deploy - This will compile the Go binaries and run serverless deploy to create an API Gateway and deploy the functions to Lambda
  7. From the output, copy the endpoint, something like https://1j876uqzle.execute-api.us-east-1.amazonaws.com/dev/sms
  8. In your Slack App configuration, add a Slash command for /sms and paste in the endpoint url you just copied.
  9. Install the app into a Slack workspace you have permission to do so in
  10. Test the integration by typing in /sms [yourphonenumber] 1m your message and you should get a response telling you when it was scheduled for and then in that much time you should also receive the text message. Note that if you are using a free trial Nexmo account you wont be able to text any numbers than the one you registered with.
  11. To destroy all the provisioned AWS resources run make destroy

About

This app was created as a demo for a presentation given to the Charlotte Golang Meetup group in August 2018. The slides for that talk are available at https://bit.ly/golang-clt-serverless

Documentation

Index

Constants

View Source
const CmdSms = "/sms"
View Source
const DynamoDBTableName = "reminderbot_queue"

Variables

View Source
var Client *slack.Client
View Source
var Env envConfig
View Source
var ErrorLogger = log.New(os.Stderr, "ERROR ", log.Llongfile)

Log errors to stderr

Functions

func ClientError

func ClientError(status int, body string) (events.APIGatewayProxyResponse, error)

Similarly add a helper for send responses relating to client errors.

func GetDbTableName

func GetDbTableName(table string) string

GetTableName returns the env var value of the string passed in or the string itself

func GetRandString

func GetRandString(length int) string

GetRandString returns a random string of given length

func LoadEnvConfig

func LoadEnvConfig() error

func ServerError

func ServerError(err error) (events.APIGatewayProxyResponse, error)

Add a helper for handling errors. This logs any error to os.Stderr and returns a 500 Internal Server Error response that the AWS API Gateway understands.

Types

type SlashCommand

type SlashCommand struct {
	Token          string `json:"token"`
	TeamID         string `json:"team_id"`
	TeamDomain     string `json:"team_domain"`
	EnterpriseID   string `json:"enterprise_id,omitempty"`
	EnterpriseName string `json:"enterprise_name,omitempty"`
	ChannelID      string `json:"channel_id"`
	ChannelName    string `json:"channel_name"`
	UserID         string `json:"user_id"`
	UserName       string `json:"user_name"`
	Command        string `json:"command"`
	Text           string `json:"text"`
	ResponseURL    string `json:"response_url"`
	TriggerID      string `json:"trigger_id"`
}

SlashCommand contains information about a request of the slash command

func SlashCommandParse

func SlashCommandParse(r *http.Request) (s SlashCommand, err error)

SlashCommandParse will parse the request of the slash command

func (SlashCommand) ValidateToken

func (s SlashCommand) ValidateToken(verificationTokens ...string) bool

ValidateToken validates verificationTokens

type SmsMessage

type SmsMessage struct {
	ID          string
	SendAt      int64
	CreatedAt   string
	PhoneNumber string
	Message     string
}

Directories

Path Synopsis
lambdas
sms
lib
db

Jump to

Keyboard shortcuts

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