Nodejs Slack



We recently announced a few new features in N|Solid with the release of N|Solid 2.3 - one of which is an expansion to threshold notifications. You can now receive notifications via Slack and webhooks, in addition to the previous email notifications.

  1. Slack Api Documentation
  2. Slack Sdk
  3. Nodejs Slack Bot
  4. Node Js Slack Tutorial
  5. Nodejs Slack

We’ve worked on making N|Solid threshold alerts more customizable, so you can start consuming them in more places that are a part of your team's natural workflow. As such, I wanted to share a quick run through on how to set up the Slack notifications from N|Solid.

In order to follow along with this guide, you'll need to have N|Solid downloaded, installed, and configured already. You can do this locally on a development environment on Mac or Linux, in a Docker container, or on a server. Check out the N|Solid page to get started, and head over to the N|Solid Docs if you have any questions from there.

Setting Up N|Solid’s Slack Integration

Start in your N|Solid Console in the application dashboard view, with at least one Node.js application connected. For this example, I used Joe McCann’s markdown editor, Dillinger, as an example app:

  1. Node Slack SDK The Slack platform offers several APIs to build apps. Each Slack API delivers part of the capabilities from the platform, so that you can pick just those that fit for your needs. This SDK offers a corresponding package for each of Slack’s APIs.
  2. Node.js Meetups; Edit on GitHub Node.js Meetups. This is a list of Node.js meetups. Please submit a PR if you'd like to add your local group! Code of Conduct. If any meetup does not have a CoC and/or is reported as an unsafe place, it will be removed from this list. Notes for adding meetups. Meetup; Frequency of meetups; How to submit a.
  3. The Slack Bot is a Node.js application that needs to run somewhere and Slack should be able to connect to it. During development, you can use ngrok to set up a local connection. Ngrok exposes your local bot to the public internet over a secure tunnel.
  4. Slack mirrors the published API docs exactly because its generated from those docs! The default interface are stateless functions and has remain unchanged since 1.0.0 and that will continue to be the case. Var slack = require('slack').

Node Slackers is a Node.js-focused Slack community. Some Working Groups have discussion channels there. The OpenJSF Slack is a Foundation run Slack with several Node.js channels (channels prefixed by #nodejs- are related to the project). Some Working Groups have discussion channels there.

Setting Up Threshold Notifications

From the application dashboard, select the 'Threshold Settings' link at the top right of the application view:

Choose whether you'd like to turn on threshold notifications for one of the three threshold parameters - CPU, Heap, or Event Loop. In my case, I set Dillinger up with a CPU threshold at 75% CPU usage for 10+ seconds with a 10 second interval (be sure to save changes before proceeding):

Sending N|Solid Notifications to Slack

After saving your threshold notification settings, you’ll need to set up tell N|Solid where to send the notification when the Threshold is triggered. Scroll down further in the threshold settings pane and select the Slack option; this will display a field where you'll enter your Slack webhooks URL:

To set up a Slack Incoming Webhook, check out this page and make sure the Slack team you want to send Threshold Notifications to is selected. On the page, select which channel you’d like your Threshold Notifications posted to - I chose #app-alerts in the NodeSource team:

Add the integration and *copy the URL on the page, *where the channel selector was. Then, head back to the N|Solid Console and paste that URL in the Slack Message option in the Actions section.

Once the Incoming Webhook URL is pasted in, you can scroll back to the top and you should be good to go with Threshold Notifications from N|Solid in Slack!

Taking Slack Notifications for a Spin

To test my notifications settings and confirm that alerts will be sent to Slack, I decided to throw some high CPU usage at Dillinger. Here's what the high CPU usage looks like in the N|Solid application dashboard:

And this is what I ended up receiving in Slack my #app-alerts Slack channel:

Wrapping Things Up

I can’t tell you how excited I am for this feature - it’s been something I’ve wanted to see for quite a while, and we’ve now landed it in N|Solid 2.3.

Huge props are due to Erin Spiceland for her extensive work on shipping the Slack and Webhooks integration, and the entire Engineering team for working to integrate and ship the new features in N|Solid 2.3.

It was a fantastic release, and we’re all looking forward to the next one.

Premise

Slack is software that falls into the category of corporate collaboration tools used to send messages instantly to team members (wikipedia). It is possible to organize communications through specific channels, generate interactions with notifications, communicate with innovativ
e methods. This article illustrates how, through a NodeJs application, messages can be sent or interactions between the management system residing in the IbmI and a Slack channel.
The article illustrates the method of interacting with the chat, and specifically an application that communicates the daily order, divided by customer, to the chat channel of the corporate workspace.
The idea is to generate a daily communication to be sent to the sales department.
This method can be used to generate notifications of system errors, execution process management messages, notifications regarding a commercial action, etc. The mes
sage can be enriched. with images, emoticons, buttons, interaction functions and much more.

Prerequisites

  • Operating system 7.2 or higher.
  • Nodejs v10.15.3 or higher.

Registration App Slack

First you need to create a new workspace in slack https://slack.com/intl/en-it/, through the use of email. After
opening the workspace and the channels, proceed with the activation of the incoming webhooks (See the pdf below). The
main difference between Webhook and API is subtle, since both services are used to move data between apps. With APIs, you get data from the provider, while notifications allow the provider to send you the data. Basically there is an answer in the API, the Webhooks simply send the data.

Nodejs application

Let’s create in the home path of our profile / home / user / … a folder that we will call slack and where we will build the application inside.

Ibmi.js module


This function is intended to access the ibmi database.
The connector is the idb-pconnector.
The connection is made through an async function and the return is a json.

The node command for installation is as follows: npm install idb-pconnector.h
ttps: //www.npmjs.com/package/idb-pconnector

MsgSlack.js module

here is the https call to the slack provider (xxxxxxxxx ….. it is the code that must be copied from the subscription to the slack webhook
service) .To this function the return json is passed by the ibmi.js function and through a loop, the ordered value of each customer is communicated.

AppSlack.js module

This is the module that manages the entire application and brings the two previous modules together.
With require the previously created modules are imported.

Application execution

The application can be launched in several ways:
– Interactive mode (call qp2term)
. – Batch mode (qsh).

To set the parameters for the automatic execution of the application it is necessary to configure a profile file in the etc folder and a .profile file in the user home user folder:

profile
PATH = / QOpenSys / pkgs / bin:
$ PATHexport
PATH.pro
filenode /home/QPGMR01/slack/appSlack.js

Example of interactive launch from an rpgfree program that we called slack:

Slack Api Documentation

Run the slack program by logging into the session with the user with whom the nodejs application was created in the system.
Call slack

Nodejs

Slack Sdk

The message is sent to the slack platform from which we can access from the browser or better on the move from any device.

Nodejs Slack Bot

Webhook nodejs

Node Js Slack Tutorial

Conclusion

Nodejs Slack

It is important to identify the most appropriate technologies in the analysis of business processes to accelerate innovations. This is one of many that can be implemented to provide quality services, such as by sending market notifications to a commercial department or making communications through chat channels more efficient. Slack also contributes to enriching the offer of products and services useful to companies to be competitive and to generate added value from the team’s work. The company is made up of people and everything is useful to strengthen the responsibility of each of us and the quality of the services offered.