Published: February 17, 2017
Whether you're building an app to reach the millions of users on Slack, or you're integrating with an internal process for your team, this is the place to start.
Let's build the simplest Slack app possible. You guessed it, "Hello, World 👏 🌏", an app that introduces itself to your team with a timeless statement.
Before we get started, here is what you need:
curl
is a command line utility to make HTTP requests. You don't need to be a terminal hero, we'll show you how to use it. It's built-in with macOS and many Linux distributions, and available for download on Windows and many other operating systems.Open the app creation page in a new window to follow along.
Fill in a name for your app and select your development team from the dropdown (you may need to sign in if you haven't already). All apps start off limited to just one team: the development team. This is perfect for integrating internal services and data to a team to which you belong. Later, If you choose, your app can be distributed in the App Directory for many teams to install.
You have an app! But it doesn't do anything yet. In order for the app to send its introduction, we'll make use of the most basic function of a Slack app — an incoming webhook. Click Incoming Webhooks to begin setting one up.
Incoming webhooks are URLs that Slack creates for your app to send its messages to, and then Slack posts those messages into a specific channel on the team. Activate this functionality by toggling the switch.
You'll notice the table of existing webhooks is empty, click the Add New Webhook to Team button the start creating one.
Slack generates a URL for an incoming webhook after the app has been installed to your team. This also gives the user who is installing the app a chance to pick the destination channel for the message. Proceed by selecting the channel and authorizing the installation onto your development team.
Our webhook table now contains the newly created URL for the incoming webhook; use the Copy button to stash it on your clipboard.
Let's return to the Basic Information tab of your app's configuration. Notice that the first two steps in the Building Apps for Slack section are complete. Distribution is optional and only used when you desire to ship the app to the App Directory; so that's all we need!
We're ready to implement our Hello World app. You could build a full application and get it running on a server, but the only thing that's necessary is to send a simple HTTP request. So, let's take a shortcut; let's use a simple curl
command from your terminal (or command prompt on Windows) to send the HTTP request. Before we do that, sign into your Slack team from a browser, desktop, or mobile app. Switch to the channel you chose earlier during the installation.
Type the following command in your terminal, pasting the incoming webhook URL in place of YOUR_WEBHOOK_URL
.
curl -X POST -H 'Content-type: application/json' --data '{"text":"Allow me to reintroduce myself!"}' YOUR_WEBHOOK_URL
Check your Slack channel and give yourself a round of applause! 👏
Slack apps have access to many more interesting features besides incoming webhooks. Begin building quickly using Bolt, our first-party development framework.
Want to go beyond our curl
shortcut? Take a look at one of our tutorials.