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.
- Navigate to https://api.slack.com/apps
- Select your app Welcome Trailhead from the list.
- Scroll down to App Credentials.
- Find the Signing Secret section and click Show.
- Copy the Signing Secret that shows up.
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.
- You should still be in your
first-slack-appfolder in Terminal (MAC) or Command Line (Windows). But in case you’re not, you can get there by entering
cd ~/Desktop/first-slack-appfor Terminal,
cd c:\Users\[myUserName]\Desktop\first-slack-appfor Command Line with
[myUserName]replaced by the user name you have set for your machine.
- 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.
Remember how we installed ngrok to this directory? Now is the time to use it!
- In your terminal, open a new tab and start ngrok on your port by entering
./ngrok http 3000.
- What should pop up in this tab, among other session information, is a Secure Forwarding URL that looks something like
- Make sure to highlight the address that starts with
httpsand copy it for the next step.
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.
- Go back to the API page, and click Event Subscriptions in the left-hand navigation menu.
- Flip the Enable Events switch on the top-right to the on position.
- Paste the URL into the box that appears.
/slack/eventsto the end of your URL.
- Almost there! Scroll down to Subscribe to Workspace Events and click Add Workspace Event.
- Search for and select the
team_joinevent—the event that signifies when a new user joins your workspace.
- Finally, click Save Changes at the bottom of the screen.
- 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+cto 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.