Slack Developer Kit for Node.js slack typescript websocket websockets websocket-client slackapi socket-mode TypeScript MIT 616 2,887 65 (10 issues need help) 11 Updated Apr 19, 2021. A Slack account and active Slack instance to deploy your bot on Installing Node and NPM To install the necessary software for this project, we will first need Node.js, a JavaScript runtime. Visit the official Node.js website to get the installer.
The @slack/webhook
package contains a helper for making requests to Slack’s IncomingWebhooks. Use it in your app to send a notification to a channel.
Installation
Initialize the webhook
The package exports a IncomingWebhook
class. You’ll need to initialize it with the URL you received from Slack.
The URL can come from installation in your development workspace, which is shown right in the app configuration pages.Or, the URL could be in the response from oauth.v2.access
when the app isdistributed and installed into another workspace.
The webhook can be initialized with default arguments that are reused each time a notification is sent. Use the secondparameter to the constructor to set the default arguments.
Send a notification
Something interesting just happened in your app, so its time to send the notification! Just call the.send(options)
method on the webhook. The options
parameter is an object that should describe the contents ofthe message. The method returns a Promise
that resolves once the notification is sent.
Proxy requests with a custom agent
The webhook allows you to customize the HTTPAgent
used to create the connection to Slack.Using this option is the best way to make all requests from your app through a proxy, which is a common requirement inmany corporate settings.
Slack Node Js
In order to create an Agent
from some proxy information (such as a host, port, username, and password), you can useone of many npm packages. We recommend https-proxy-agent
. Startby installing this package and saving it to your package.json
.
Slack Sdk
Import the HttpsProxyAgent
class, and create an instance that can be used as the agent
option of theIncomingWebhook
.
Comments are closed.