Skip to main content

Set Up Your Slack Environment

Learning Objectives 

In this project, you’ll:

  • Set up a Trailhead Slack playground.
  • Set up the Slack Command Line Interface (CLI).
  • Build a Slack app using the Bolt for Java Script framework.
  • Build simple interactivity for your Slack app.
  • Deploy your Slack app with the Slack CLI.

Before You Start

Before you start this project, we recommend you complete the following badges. This project builds on the concepts you learn in these badges.

In this project, you build an app using the Slack Bolt for JavaScript framework using several environments and tools. To complete the work, you need these components on your computer.

  • Node.js.
  • npm.
  • A text editor where you can develop your app.

Get to Know Bolt

Bolt is a development framework that makes it easier to build Slack apps with Slack’s latest platform features. It uses a listener interface that enables common patterns when handling requests coming from Slack, regardless of the type. In this project, you use the Bolt for JavaScript framework to build your app.

Bolt has a number of built-in defaults like OAuth support, verification of events, and a simplified interface for features like workflow automation. This project provides an overview of Slack’s APIs, Bolt’s listener patterns, and the creation of a Bolt for JavaScript app.

Slack APIs at a Glance

Before building with Bolt, it’s helpful to have a high-level understanding of application programming interfaces (APIs). If you aren’t familiar with APIs, we highly recommend checking out the API Basics we referenced at the beginning of the module to give you a better foundation for how your app works.

Slack apps have access to a range of APIs that enable them to read, write, and update data in Slack. The two most commonly-used APIs for apps are the Web API and Events API. Slack uses the Events API to send your app an event. Your app uses the Web API to send an interaction back to Slack.

Events API

The Events API uses event subscriptions to send JSON payloads to your app via HTTP. When your app receives an event, it acknowledges the payload and decides what action to take. Events can be anything happening inside of a workspace‌ — ‌a message posted in a channel, a user opening your app’s home tab, or a new user joining the workspace. The full Events API types list can be found on the Slack API site.

Bolt includes built-in helpers to receive and route events to your app’s listeners, and expose helpful information like the workspace and relevant users or channels. These helpers ensure your app works as it should, interacting with people in the right places, at the right time. Listeners are covered later in this project.

Web API

The Web API is a collection of HTTP methods with similar calling conventions to interact with API object types in Slack, like channels, conversations, events, and more. These interactions include sending rich, interactive messages to a channel or other app surface, or querying for workspace information like a list of users. The full list of Web API methods can be found on the Web API methods page. Bolt includes a built-in client with features like rate limit handling and retry logic to simplify calling and handling responses of Web API requests. 

And for niche use cases like administering a workspace or performing security audits, information about additional APIs can be found in the Resources section.

Retrieve Your Trailhead Slack Playground

Get hands-on with Bolt! Trailhead is integrated with the Slack Developer Program. This enables us to provide you with a special Slack playground designed for hands-on learning. When you connect your Trailhead account for the first time, you’re signed up for the Slack Developer Program, which gives you access to a wealth of Slack development resources.

More on that later. First, get your Slack Playground up and running. If you haven’t provisioned a Trailhead Slack Playground yet, follow these steps. If you’re already connected, head to the challenge section of this page and launch your sandbox.

  1. Scroll down to the Challenge section of this page, where it says Verify Step.
  2. By default, your primary Trailhead email address is selected. If you prefer another email address that’s associated to your Trailhead account, click on the email dropdown and select it.
  3. Check the box next to “I accept the Slack Developer Terms of Service.” Optionally, you can check the next box to subscribe to the Slack Developer Newsletter.

Authorize access to your Slack Playground to complete this challenge modal, the email address learningfun@gmail.com is selected, and both boxes are checked

  1. Click Create Slack Playground. After a moment, you’re taken to the Slack Developer Program terms of service page.
  2. Click I Agree. You’re then taken back to Trailhead. Your Slack Playground is now connected

Review the terms of service modal

  1. Scroll back down to the challenge section. Click Launch to open your playground in a new tab.

Confirmation of using account with options to Launch or Disconnect Slack Playground

Now head into your playground!

Create a New Channel

Here’s a scenario—you’re the go-to developer for Slack apps at your organization. The onboarding team recently approached you. They want to have an automated and fun way of welcoming new team members. You sit with the team and go over the requirements and it sounds like a simple app is the way to go. But you already know, simple doesn’t necessarily mean easy.

You review your notes. New team members need a channel to gather and get the information they need. That’s where the app will interact with them.

  1. In your Slack Playground, Click + next to Add channels.
  2. Click Create a new channel.

+ Add channels menu is displayed and the Create a new channel option is highlighted.

  1. Select New hire onboarding from the template menu.
  2. Then click Next.
  3. Leave everything as is. Click Use Template.
  4. Name your channel welcome-new-team-members.
  5. Ensure Visibility is set to Public.
  6. Click Create.
  7. If Slack asks you to add people to the channel, click Skip for now. After a moment, Slack generates your onboarding channel with prebuilt canvases and workflow.

#welcome-new-team-members channel is selected and open in Slack.

The template was helpful getting the channel up and running with essential resources. This is where the onboarding team can make announcements and host Q&A events to get people up to speed. It’s where your new app does most of its work. In the next step, you create your app using the Slack command-line interface (CLI).

Resources

Slack: Using Slack APIs

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback