The next step is to handle the Slack request. Subscribe to events on behalf of users, I chose member_joined_channel and member_left_channel. My application will gather information about who joins and leaves the channel. It contains a field challenge, you need to return this value in the response.Īfter configuring and validating the URL, you should subscribe to chosen event types. For verification purposes, a POST request will be sent to this address. In the presented scenario, /event-subscription is an endpoint that will handle the Slack notification. In my case, it works on the address /event-subscription. To do it, you should add another endpoint in your Node application. It’ll be the place where Slack will send the notifications about the events. Once you do that, you should verify your endpoint. The first thing you need to do is to enable Events for your app. The configuration starts with opening Event Subscriptions in the Features tab. If you use a real database – you obviously get way more possibilities. It’s an example of how Slack integration and the Slack Slash command can help your organisation. Once it’s done, it should properly format the result.īelow, you’ll find the final result. Then, in the body of the function which handles a POST request, you should add a code that will get the name of the requested employee from the body and look for them in the database. My file was a table that looked like the one below. The next step will be creating a table with some example data. Let’s start with creating an exemplary JSON file with employee data and let’s import it. It will be information about an employee whose name and surname was provided through the Slack slash command. Now, an app returns only the data you sent.Ī target application will get the information from a database (for the article’s purposes, it’s a JSON file). Previously opened ngrok will tunnel traffic from a local port 3000 to a public ngrok cloud. Newly created Slash command will now send a POST request. The next step is about creating an index.js file and configuring an app to make it listen on port 3000. Use the command: npm init & npm install express. įirst of all, you should create a project and install a framework express. You can check your version with the command node -v. In the presented project, I used Node (v.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |