This is a Slack bot. It is primarily for demonstration purposes.
The bot listens for HTTP requests from Slack's Events API. When it receives an event, it can take action using Slack's Web API methods.
Programs
There are two programs:
- yorick (cmd/yorick): The Slack bot.
- When run, it starts an HTTP server and listens for Events API HTTP requests.
- horatio (cmd/horatio): An IRC bot that acts as both a Slack Events API
and a Slack Web API.
- It connects to an IRC server and joins a channel. It sends Events API-like HTTP requests for each message in the channel. It also runs an HTTP server where it listens for Web API-like HTTP requests to send messages to the channel.
- Why? This is so we do not have to depend on configuring a bot in Slack's interface, nor having a Slack workspace accessible. This is useful for getting started quickly and in the event of workspace issues.
Supported Events API events
Currently the bot knows about two events:
- url_verification (required to configure the bot in Slack's API)
- message (a channel message)
Supported Web API methods
Its only action is to post a message in a channel using the chat.postMessage method.
Adding your bot to a Slack workspace
You first need to get yorick running somewhere Slack will be able to send HTTP requests.
- Go to api.slack.com/slack-apps and choose Create a Slack app
- Pick an App Name and a Development Slack Workspace
- Go to Event Subscriptions under Features in the left hand menu
- Click Add a bot user and do that
- Go to Event Subscriptions again
- Enter your Request URL (this is yorick's endpoint URL)
- Under Subscribe to Bot Events, choose Add Bot User Event
- Choose message.channels
- Go to Install App under Settings in the left hand menu
- Choose Install App to Workspace and authorize it
- Run yorick with the token listed as Bot User OAuth Access Token
- In Slack, invite the bot to a channel (/invite @bot_name)
- You should see your bot join and you can now interact with it