New to the slack API? To start having fun earlier and defer the detailed dive into the docs and API specs, I give you:
superslack-ui - a fantastically no-frills UI for exercising/testing your slack app. Fork and extend to play & experiment.
The idea is to shorten the amount of time it takes to get talking to slack for the very first time. You go to slack, create an app, fill in the secrets/tokens in your server's
.env file, and that's it. You can start with the UI, and then when comfy, You can peek at the server code, and then when comfy, you can throw the lot away or grow it into a more robust thing.
I started my journey with this tutorial. Do check it out to get the gist of things. What it comes down to, is:
a Setup phase, in which
a Coding phase, in which
curlin a terminal. Or even Postman. Why? Because all such tools don't care about SOP (Same Origin Policy). Browsers, otoh, are designed in such complete obeisance to SOP that you will be beset with CORS errors. I had decided to go the browser/ui testing route, so I had to build in an (admittedly straightforward) 'forget CORS' attitude into my server.
requestin nodejs, or
fetchbrowser-side, its best to explicitly set the correct headers (
application/json) yourself and also call
JSON.parse()on your json objects & string payloads. The only flawless variant of such things was the the
body-parsermodule for express, and the attendant .json() response methods, which do what it says on the tin. In spite of which:
request.body.foocalls (e.g. if using express) will barf. Take a good look at the structure of your response payloads coming back from Slack before writing the code to parse them.
For all these reasons and more, I used my "superslack tool" to help me test and learn. Check it out, in case it will be helpful to you too. It also lets you play with pushing simple as well as interactive messages to slack, and getting the response selected by a user.