#100DaysOfWeb in Python Transcripts
Chapter: Days 77-80: Twitter and Slack bots
Lecture: Project: random book slash command
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Right, back on day three. I hope you had fun yesterday with Twitter or any other API and in the coming two days, we're going to look at the Slack API.
0:11
First of all, Slack API is huge, so in this lesson as we only have two days scheduled for this, I'm going
0:16
to keep it pretty simple and we're going to use a slash command. Slash commands are nice because you can just type
0:23
slash command with some text that we can parse on the backend and do something and this one will be very simple.
0:30
So we have our pubites reading list app and I made an API end point, API slash random. It fetches a random book that was added by one of our users
0:39
in a dictionary and we're going to grab that and post that to Slack and here you can see it in action.
0:46
We're going to build a small flask app that receives the request from the slash command. We're going to run ngrok to expose my local host
0:58
to the internet and then we're going to call slash book from Slack and here you should see the app returning a response.
1:06
Here's a random title for your reading list and it displays that random title and it does it in a nice format
1:12
with a big image and a link back to the reading app. The letters you're going to use, flask, again request
1:21
to pull in the random endpoint of the reading list app and ngrok, which again, makes my desktop available to the internet temporarily.
1:32
Before we can start coding, you first need to create a Slack application and submit it for approval to the admin, so let me do that first.