Documentation ¶
Overview ¶
Package go209 is the core package used to build go209 slack RTM bot (and associated web app)
Index ¶
Constants ¶
const PreloadedModules = "email-mod:slackwebhook-mod"
PreloadedModules is the list of .so files from the root directory we load by default
const RedisDefaultExpiration = "29m"
RedisDefaultExpiration is the default period of time a redis state should last for slack has a 30 min window for interactive messages and the response_url even though we don't use the response_url, let's set the timeout slightly shorter
@TODO: Should this be much much shorter, like, 5 minutes? How long is an interaction meant to take?
const RedisSubTermExpiration = "5m"
RedisSubTermExpiration is the default period of time a redis state should last when handling sub-term matching
const TemplatePreParserRegex = `\[\[[\w+\|\|]+\w+\]\]`
TemplatePreParserRegex is the regular expression to parse our template pre-parser
const Version = "0.6.0"
Version of go209
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BotConfig ¶
type BotConfig struct { SlackToken string SlackSigningSecret string Debug bool RulesFileLocation string RedisAddr string RedisPwd string RedisDB int WebListen string DynamicModules string }
BotConfig defines the configuration that is used by both the slack bot app and web server
type DynamicNext ¶
type DynamicNext struct { Response string `json:"response"` NextInteraction string `json:"next_interaction"` }
DynamicNext defines dynamic branching. This occurs after an interaction, with an attachment, is responded to by a user, which subsequently sends a web hook. We use these to determine the next interaction to present to the user
type Interaction ¶
type Interaction struct { InteractionID string `json:"interaction_id"` StopWord string `json:"stop_word"` Type string `json:"type"` Response string `json:"response,omitempty"` Question string `json:"question,omitempty"` NextInteraction string `json:"next_interaction"` Attachment slack.Attachment `json:"attachment,omitempty"` NextInteractionDynamic []DynamicNext `json:"next_interaction_dynamic,omitempty"` }
Interaction defines our interactions we want to present (and handle) from a user. These could be a simple question (storing the next message from the user as a response), or a Slack Attachment (i.e. menu drop down, button)
type LoadedModules ¶
type LoadedModules struct {
Modules []Module
}
LoadedModules is a struct we use to hold modules and load modules etc
func (*LoadedModules) LoadModules ¶
func (m *LoadedModules) LoadModules() error
LoadModules loads up the plugin .so files
type Module ¶
type Module interface { Name() string EnvVars() []string Run(in interface{}, ev map[string]string, interactions map[string]string) error }
Module defines what our plugins have to define
type Rule ¶
type Rule struct { SearchTerms []string `json:"terms"` Response string `json:"response,omitempty"` Attachment slack.Attachment `json:"attachment,omitempty"` Interactions []Interaction `json:"interactions,omitempty"` InteractionStart string `json:"interaction_start,omitempty"` InteractionEndMods []string `json:"interaction_end_mods,omitempty"` SubTerms []SubTerm `json:"subterms,omitempty"` }
Rule defines the mapping of search terms (i.e. words a user may say to the bot), to a simple response, OR, the initiation of a more complex interaction
type RuleSet ¶
type RuleSet struct { Rules []Rule `json:"rules"` DefaultResponse string `json:"default"` InteractionCancelledResponse string `json:"interaction_cancelled_response,omitempty"` InteractionCompleteResponse string `json:"interaction_complete_response,omitempty"` }
RuleSet is the parent struct that defines the rules.json file
type SubTerm ¶
type SubTerm struct { SearchTerms []string `json:"terms"` Response string `json:"response,omitempty"` SubTerms []SubTerm `json:"subterms,omitempty"` }
SubTerm defines the mapping of a sub-search term The idea is that if a Rule is kicked off, we keep state, and allow secondary or more, search terms, offering simple responses. These are different from Interactions in that we aren't storing state to report anything back.