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
- Empower your entire slack team to extend it through Node.js using Auth0 Webtasks. What can you do? Custom reports: query an internal data warehouse to retrieve customer data, generate real-time reports, check website activity. ChatOps: trigger a deployment, manage your infrastructure, diagnose problems, get systems health.
- Shortly after we started using Slack on our team in 2014, it also became my task management tool. I hate having my notes spread over multiple systems, and Slack meets all my main.
Slack Node The Slack Node allows a workflow to send messages to a Slack channel.
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.Slack Sdk
Proxy requests with a custom agent
Slack Node-red
The webhook allows you to customize the HTTP
Agent
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.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 Node Api
Import the
HttpsProxyAgent
class, and create an instance that can be used as the agent
option of theIncomingWebhook
.