Start tracking your progress
Trailhead Home
Trailhead Home

Set Up Your Server

The first thing you want to track is when a new user has joined the workspace. To do this, you first need a Signing Secret from Slack. This enables you to verify that requests are coming from Slack.

  1. Navigate to https://api.slack.com/apps
  2. Select your app Welcome Trailhead from the list.
  3. Scroll down to App Credentials.
  4. Find the Signing Secret section and click Show.
  5. Copy the Signing Secret that shows up.

The Signing Secret is an alphanumeric string that can be found near the bottom of the App Credentials section.

Time to start the verification server on your end. The verification server is there to help you set up configurations with your Slack App later on. 

  1. You should still be in your first-slack-app folder in Terminal (MAC) or Command Line (Windows). But in case you’re not, you can get there by entering cd ~/Desktop/first-slack-app for Terminal, cd c:\Users\[myUserName]\Desktop\first-slack-app  for Command Line with [myUserName] replaced by the user name you have set for your machine.
  2. Then enter the following, replacing <signingSecretYouJustGot> with your Signing Secret:
node node_modules/.bin/slack-verify --secret <signingSecrectYouJustGot> --path=/@slack/events-api --port=3000

This starts the verification server on your machine on port 3000. You should receive the following message: The verification server is now listening at the URL: http://:::3000/slack/events.

Use ngrok

Remember how we installed ngrok to this directory? Now is the time to use it!

  1. In your terminal, open a new tab and start ngrok on your port by entering ./ngrok http 3000.
  2. What should pop up in this tab, among other session information, is a Secure Forwarding URL that looks something like https://0000aaaa.ngrok.io.
  3. Make sure to highlight the address that starts with https and copy it for the next step.
Note

Note

Tabs are an effective way to keep your running processes organized. For Windows Command Line, the shortcut is ctrl+t, and for Mac Terminal, it’s command+t. Though in both, you can also find an option in the menu that says New Tab if you don’t want to use a shortcut.

Enable Events

At this point, we go back to your Slack App’s page on https://api.slack.com/, and post this URL in the right place.

  1. Go back to the API page, and click Event Subscriptions in the left-hand navigation menu.
  2. Flip the Enable Events switch on the top-right to the on position.
  3. Paste the URL into the box that appears.
  4. Add /slack/events to the end of your URL. By entering your server URL appended with /slack/events, you enable Slack to send notifications to your Slack App.
  5. Almost there! Scroll down to Subscribe to Workspace Events and click Add Workspace Event.
  6. Search for and select the team_join event—the event that signifies when a new user joins your workspace.
  7. Finally, click Save Changes at the bottom of the screen.
  8. Back in your terminal, go to the tab your verification server’s running in (the one that displays “The verification server is now listening at the URL: http://:::3000/slack/events”), and type control+c to shut it down. You won’t be needing it anymore.

Now you’re ready to detect when a new user has joined!

We won't check any of your setup. Click Verify Step to go to the next step in the project.

retargeting