Part I: Overview of Concepts - Jfeatherstone/SlackAppTutorial GitHub Wiki

Howdy, and welcome to my tutorial on how to setup a Slack app to better utilize and personalize your workspace!

As the title suggests, I will begin by covering some of the basic topics that will be utilized throughout the tutorial. If you are well versed in programming/server administration, these will probably be pretty elementary, especially since I won't be going into technical details, so feel free to skip ahead. That being said, let's begin!

Slack Apps

If you've found this tutorial, you probably know what a Slack app is, but in case you don't, they provide an interface to interact with information outside of Slack. Examples include having Google Calendar events show up in a channel, creating Zoom meetings with commands, and (you guessed it) sending messages anonymously. The former two things I mentioned are available without any of the work detailed in this guide, since they are distributed by their respective companies. There are great and all, but sometimes you want to streamline something specific to your workspace, and no preexisting solution fits your niche.

Slack Apps usually include a bot user, who can send messages in a channel, direct message members, and interact with users in various other ways. An example you've probably seen of this is the stock SlackBot that will message upon first joining a workspace.

HTTP Requests (aka How the Internet Works)

Just a warning that I am not a sysadmin, and therefore the following information may be greatly simplified. I can assure you that there are some things I may say that, although not outright incorrect, are a bit of a stretch, but bear with me here.

Assuming you've been alive at any point during the past two decades (which I believe is a prerequisite for reading this page) you have certainly interacted with web servers through HTTP requests. These requests are how every browser works, as well as how anything connected to the internet in general communicates. When you click on a link, or search something up in your favorite search engine, you are making an HTTP request, whether you know it or not.

Your computer doesn't contain the entire internet on it locally, and so you have to be able to look somewhere else for whatever information you want. This tends to be a server (just another computer) that could be anywhere around the world, and is assigned a "location" on the internet (IP address) These IP addresses tend to be strings of numbers (and letters, in the case of IPv6) along the lines of 192.168.1.1. We don't want to have to remember these numbers (I can barely remember phone numbers) so we can assign nice, comfy words/sentences to redirect to these numbers, like google.com or github.com. So now we know where the information we want is kept, so how do we get it?

We ask for it of course, making sure not to forget to be polite -- though in this case, our "politeness" means that we format our request properly, and don't send too many requests. Your browser will send a message to google.com saying "I would like information on X", and Google will the send tons of messages to other websites asking something similar. These websites will respond with information, and Google will then respond to you with some of the information it found, and ta-da, you've successfully used a search engine to navigate the internet (you should be proud of yourself). We could of course cut out the middle-man and just go directly to a website but we would need to know about that website in the first place.

Our app will work like the latter scenario: we will tell Slack what website it should go to, and then when we do something in our Slack workspace, it will send a message to that website, and show us how it responded. The biggest (and scariest) difference here is that the 'website' will not be something that shows up on Google, but something that we will have made ourselves!

Programming

In the previous section I talked mostly about what a request is and how they allow us to get information for the internet, but I didn't say at all how one would actually make a request. The answer is probably pretty obvious considering the section heading: we are going to use a programming language to make this request. Just about every modern programming language has a built-in way to make such a request, usually in only a single line of code! If you've never programmed anything before, that's perfectly fine, I'll be here every step of the way to help out, and maybe you'll even decide to delve deeper. Programming is essentially just writing very detailed instructions for your computer to carry out, so the possibilities are endless!

Python

There are tons of programming languages that could do what we need, since it is rather simple, but I have chosen Python for a few reasons:

  • It has very simple syntax: this is like the grammar of a (verbal) language being simple. We don't have to worry so much about whether we should be saying 'who' vs. 'whom' and can instead focus on what we want to talk about.
  • It works nicely with servers: I have written the later parts of this guide for two different server hosting platforms, both of which work very nicely with Python. This means we spend less time setting up our environment and can get right into the details!
  • It's popular: if you're learning programming these days, you have very likely interacted with Python in one way or another. It is one of the fastest growing languages in terms of popularity, and therefore more people are likely to know it.

So what does Python actually look like? Let's look at some basic examples:

  • Add two numbers together, and print out what the sum is
a = 1
b = 3
print(a + b)
  • Check if the value of a variable is equal to another variable
a = 3
b = 5
if a == b:
    print('a equals b')
  • Count up to 10
for i in range(10):
    print(i)

As you can see, the code is pretty verbose about what is going on, even if there are a few things you have to know (using ==, indenting things, where to put parenthesis, etc.). That being said, I'll always explain exactly what's going on in the code both, but to do so, there one very important programming concept to introduce: commenting. Just like when writing a paper, we might want to make comments about certain parts that we don't want to actually show up in the final draft. Programming does this through commenting, which means we are putting something in our code that doesn't actually get run by the computer. These comments are indicated by a # before the text, which tells the computer to ignore this part. I will always comment my code so each step is as explicit as possible, so keep an eye out for that.

You may not be an expert in any of these topics, but you're more than likely ready to dive into the rest of the tutorial! Next up, we'll be talking about Slack apps in more detail, and how to actually create (an empty) one for your workspace.