Skip to content

Setup Greetbot in your Slack Workspace

johnathanDOS edited this page Apr 15, 2018 · 9 revisions

This guide will show you how to set up your .env file and add greetbot to our sandbox Slack workspace. If you don't have a Slack workspace yet, create one using their tutorial.

Create an .env file

For security purposes, we don't include an .env file. However, we do include an example file to give you an idea of environment variables that are needed for our app to work.

Duplicate the .env.example file as .env. You can leave SLACK_TOKEN and SLACK_VERIFICATION_TOKEN empty for now, but set DEV_SUBDOMAIN as your name without space. For example,

DEV_SUBDOMAIN=angelocordon

What is the DEV_SUBDOMAIN for?

We'll be using localtunnel to create a public url to your development server and for use with your sandbox workspace. Whatever you type in here will create a public url of DEV_SUBDOMAIN.localtunnel.me or in this example, angelocordon.localtunnel.me. You'll see this in action below.

Install greetbot in your sandbox Slack Workspace

Create greetbot

  1. Create a New App for Slack Visit Slack's API App Page and click on Create New App at the top right corner.

  2. Fill in the App Name (as greetbot) and select your workspace for Development Slack Workspace. You may have to click on sign in if you don't see your workspace available.

Grab your tokens for your .env file.

In order to get all the right tokens, you must create a Bot User first. On the left hand side, navigate to Bot Users. Set Display Name as greetbot and Default Username as greetbot. Click on Save.

  1. Under the Basic Information page, scroll below to the App Credentials section and grab your Verification Token. Copy this in your .env file as SLACK_VERIFICATION_TOKEN.

  2. On the left hand menu, navigate down to OAuth and Permissions and grab the Bot User OAuth Access Token. This starts with xoxb. Use this as your SLACK_TOKEN.

Set up greetbot

From here, when we refer to your localtunnel URL, we mean the URL generated from localtunnel. If you filled out the .env file as noted above, it should be DEV_SUBDOMAIN.localtunnel.me. You can also see this URL printed in the console after running npm run start:dev.

  1. On the left hand menu, navigate down to Interactive Components. Fill in the Request URL with yourlocaltunnelURL/interactive-message. For example: (https://angelocordon.localtunnel.me/interactive-message).

  2. From the left hand menu again, navigate down to Slash Commands and click on Create New Command. Fill in the information as follows:

Command: /welcome

Request URL: yourlocaltunnelurl/welcome

Short Description: Show the welcome text!

Important: Make sure to check off the option for Escape channels, users, and links sent to your app located under Usage Hints

Click on Save.

  1. Move on to Event Subscriptions. Fill in the Request URL with yourlocaltunnelURL/events. This will send a post request to this URL. If you don't pass the verification:
  • First, make sure that your server is running (run npm start:dev in your console) or make sure that your tokens are listed correctly. See this step again for reference.

  • If you still don't pass verification after checking the steps above, you can try running npm run start:dev-server and npm run start:dev-tunnel in two separate instances of your terminal.

Subscribe to both Workspace Events and Bot User Events with team_join.

Put greetbot in the right place

Lastly, install greetbot in your sandbox work place. Navigate back up to Basic Information and click on Install your app to your workplace.

Testing greetbot

Congratulations, you should have greetbot up and running with your sandbox channel 🎉 To try this out, type in /welcome test in your Slack and you should get a private message from greetbot!