Access Wikipedia content directly from Slack with slash commands
-
Create your Account at Slack, if you don't already have one.
-
Create your App at Slack App Creation.
Give a name to your app. Select the Workspace where you to install the app to.
-
Once your Application is created, Click on the Basic Information Page and scroll down to find App Credentials section.
Copy the values of Client ID, Client Secret and Signing Secret and store these values in environment variables. Open the shell of your choice and enter,
$ export CLIENT_ID="<enter your client id>" $ export CLIENT_SECRET="<enter your client secret>" $ export SLACK_SIGNING_SECRET="<enter your signing secret>"
-
Click on "Incoming Webhooks" Page and slide the toggle of "Activate Incoming Webhooks". Once it is toggled, click on "Add New Webhook to Workspace" button in th end
-
Now, Slack will ask to authorize the access to your workspace. Select any channel from the dropdown box and click "Allow"
Now that we have setup our Slack App, it is time for us to deploy our Application.
Slack will send a request to the Public URL that we've configured in Slash Commands. So, if we are to develop locally, I would suggest you to go with ngrok. Ngrok will provide a secure URL to our localhost server through NAT. Please read Using ngrok to develop locally for Slack for setting up your application to run locally.
We'll be using Heroku's platform to deploy the Application
- Create a free account, if you already don't have one.
- Click on the button below which will automatically take you to the Heroku's Page.
- Enter a name for your App and fill the Config Vars that we got from above.
The final step is to configure the slash commands
-
Click on "Slash Commands" Page and click "Create New Command" button
-
Refer Slash Commands for list of supported commands
-
The Request URL will be the URL of your deployed application. If you used Heroku, it'll be something like
https://app-name.herokuapp.com
. If you are using ngrok, it'll be something likehttp://39ade6ce6764.ngrok.io
-
Save the Command that you just created.
- Login to Heroku and go to your apps' page.
- Click on Deploy Tab and follow the instructions to deploy the changes to Heroku.