Learn to send Slack notifications swiftly with Novu (manually managed)
In this guide, you’ll learn how to use Novu to send notifications directly to a Slack channel. But before coding anything up, we first need to go through a setup process. The corresponding docs for this guide are available on our docs.
So let’s begin!
Creating a Slack app is fairly simple. Follow these steps to create your app:
Create an app from Slack's app dashboard
Select 'From Scratch' in the following dialog
Name your app and select the workspace
Click on the 'Create App' button
Slack greets you with this screen
Client Id
from the Slack Developer’s Dashboard for configuring Slack Integration in the Novu Web Dashboard later, so keep it handy.Get 'Client Id' from the Slack developer's dashboard
Create a workflow from the Novu Web Dashboard
Drag and drop the 'chat' option
Configure the step as per your liking
Make sure that Slack integration is set to active
Client Id
. You should have it already but if you don’t, you can obtain it from the Slack Developer’s Dashboard.Get 'Client Id' from the Slack developer's dashboard
Plug the 'Client Id' into the Slack Integration setting in Novu web dashboard
The backend for this app is quite simple. Simply install the Novu package:
Now, create a route that you’ll hit when called from the front end. We’ll also need to add it to our Slack app (discussed below). For our demo app, this is the route I’ve created:
Now, we need a controller function to handle what is to be sent in the trigger’s function payload. Here’s the controller I wrote:
To make it modular, we’ll keep the trigger code in a separate function in a separate file, novu.js
, in our case, which is as follows:
In this code snippet above, we’re first initializing a new instance of Novu, then using it to ‘identify’ or create a subscriber.
Click the 'Get Snippet' button to get trigger code
Paste this trigger code in your backend
There are two ways to configure the Slack app. One is the Novu managed option and another the manually managed option. Since the Novu managed is fairly straightforward, I’ll demonstrate the manual method here. Follow along to set it up!
Turn on 'Incoming Webhooks' in your Slack app
Click the 'Add New Webhook to Workspace' button
Select the channel
Copy the webhookUrl from Slack
webhookUrl
Novu will use to authenticate when using the Slack provider.In our case, we’ll add it to the Novu.js
file we created earlier so that the final file becomes :
Add your endpoint to the redirect URL section on Slack
For our demonstration purposes, the front end is pretty basic. All we have to do is have an input field to take the notification text in and send the payload. The front end code for this demo app is available on our Github repo. And here’s our app in all its glory!
Our app in action!
This is how we send Slack notifications using Novu!
Learn to send Slack notifications swiftly with Novu (manually managed)
In this guide, you’ll learn how to use Novu to send notifications directly to a Slack channel. But before coding anything up, we first need to go through a setup process. The corresponding docs for this guide are available on our docs.
So let’s begin!
Creating a Slack app is fairly simple. Follow these steps to create your app:
Create an app from Slack's app dashboard
Select 'From Scratch' in the following dialog
Name your app and select the workspace
Click on the 'Create App' button
Slack greets you with this screen
Client Id
from the Slack Developer’s Dashboard for configuring Slack Integration in the Novu Web Dashboard later, so keep it handy.Get 'Client Id' from the Slack developer's dashboard
Create a workflow from the Novu Web Dashboard
Drag and drop the 'chat' option
Configure the step as per your liking
Make sure that Slack integration is set to active
Client Id
. You should have it already but if you don’t, you can obtain it from the Slack Developer’s Dashboard.Get 'Client Id' from the Slack developer's dashboard
Plug the 'Client Id' into the Slack Integration setting in Novu web dashboard
The backend for this app is quite simple. Simply install the Novu package:
Now, create a route that you’ll hit when called from the front end. We’ll also need to add it to our Slack app (discussed below). For our demo app, this is the route I’ve created:
Now, we need a controller function to handle what is to be sent in the trigger’s function payload. Here’s the controller I wrote:
To make it modular, we’ll keep the trigger code in a separate function in a separate file, novu.js
, in our case, which is as follows:
In this code snippet above, we’re first initializing a new instance of Novu, then using it to ‘identify’ or create a subscriber.
Click the 'Get Snippet' button to get trigger code
Paste this trigger code in your backend
There are two ways to configure the Slack app. One is the Novu managed option and another the manually managed option. Since the Novu managed is fairly straightforward, I’ll demonstrate the manual method here. Follow along to set it up!
Turn on 'Incoming Webhooks' in your Slack app
Click the 'Add New Webhook to Workspace' button
Select the channel
Copy the webhookUrl from Slack
webhookUrl
Novu will use to authenticate when using the Slack provider.In our case, we’ll add it to the Novu.js
file we created earlier so that the final file becomes :
Add your endpoint to the redirect URL section on Slack
For our demonstration purposes, the front end is pretty basic. All we have to do is have an input field to take the notification text in and send the payload. The front end code for this demo app is available on our Github repo. And here’s our app in all its glory!
Our app in action!
This is how we send Slack notifications using Novu!