![node js slack client node js slack client](https://blog.ona.io/assets/images/2019-04-17/create-slack-app.png)
Instead of a black box, you'll see your very own access token here. Authorize it, and your OAuth & Permission page will now contain an access token: Scroll back up to the top of the ' OAuth & Permissions' page, and you'll see a nice inviting green button you can click:Ĭlick it, and you'll be taken to a screen asking you to give you app access to your workspace.
#NODE JS SLACK CLIENT INSTALL#
Once you've added this scope, you'll be able to install the app to your workspace. The one you're looking for is ' Send messages as Super Amazing Test App,' though instead of Super Amazing Test App, you'll see whatever super amazing name you gave your own application. This makes sense, because without any authorized scopes, your app wouldn't be allowed to do anything, and an access token that grants you the ability to do nothing at all wouldn't be very useful!Ĭlick on the drop down box to see a list of scopes you can add. When this page loads, scroll down to ' Scopes.' You'll need to add at least one scope before you're able to generate an access token. When your app's admin page loads, click on ' OAuth and Permissions' in the menu on the left. Start by finding your app's admin page by navigating to the Slack API apps page and then clicking on your app in the list that appears. To get started, we'll need to install our app into our Slack workspace, which will give us an access token we can use to post messages to channels in the workspace.
#NODE JS SLACK CLIENT CODE#
If you're reading this in the year 2057 and you're running Node.js 257.8.11, this code will probably work there too - assuming ECMAScript 2015 hasn't been deprecated, and assuming Slack still exists. If you have an older 8.x release installed, the code we're going to write should be there as well. I recommend the latest LTS release, which at the time of writing is 10.14.2. If you don't already have it installed, you can grab a copy of it from the Node.js website.
![node js slack client node js slack client](https://miro.medium.com/max/5120/1*v7OfirwzOkEJBfKM928Y1w.png)
Since this functionality is built into Node's standard library, creating our app will be quick and easy. So all we need to do to write to a Slack channel is make HTTP POST requests.
![node js slack client node js slack client](https://codehangar.io/content/images/2017/07/example_bot_name.png)
To keep things nice and simple, we're going to be using Slack's Web API. If you haven't completed the first tutorial in this series where you learn about Slack's APIs and create your first workspace and application, please do that first. In this article, we'll be creating a simple Node.js application that can write to a Slack channel. Note: This tutorial is part of CodeProject's Slack API Challenge.