Slack is a digital platform that connects businesses to the tools and people they work with daily. Thus, both HubSpot and Slack are important tools for businesses. Webhooks are defined as methods of altering or augmenting the behavior of a web application or a web page with custom callbacks.
These callbacks can then be managed, modified, and maintained by third-party developers and users who may not necessarily be associated with the originating application or website.
This blog talks about the different steps you can follow to set up Slack Webhooks integration in a seamless fashion. It also gives an introduction to Slack and Webhooks before diving into Slack Channel Webhooks Integration.
Table of Contents
What are Webhooks?
Image Source
Webhooks are the ways of communicating between two apps by sending notifications or alerts when something happens. Webhooks are automated messages sent from apps during any event. They have a payload or message, which is sent to a unique URL.
When an event happens on the trigger application, it serializes the data about that event and sends it to a Webhook URL from the action application. This is defined as the one you want to do something based on the data collated from the first application.
This Action application can then send a callback message, alongside an HTTP status code like 302. This lets the trigger application know if the data has been received successfully or a status code of 404 if not.
Generally, Webhooks can be set up with a three-step process:
- Get the Webhook URL from the application you wish to send data to.
- Next, you need to use that URL in the Webhook section of the application you want to receive the data from.
- Finally, you can choose the type of events you want the application to notify you about.
There are several use-cases when webhooks are very helpful. Here are a few examples of the same:
- Notification email from Paypal alerts you when the client pays you.
- In applications like Bitbucket, every time a user pushes commits in a repository, you can use Webhooks to instantiate the CI pipeline.
- Sending success/failure emails when the build passes/fails.
Webhooks are event-driven systems, which means it becomes active only when the desired event happens, and they are restricted to communicate over web protocol-HTTP.
What is Slack?
Image Source
Slack is a messaging tool for businesses. It connects individuals to the information that they need. Slack brings people together to work as one team, transforming the way organizations communicate.
Slack sends instant messages and it comes with many add-ins for other workplace tools. However, the add-ins are not a must for you to use Slack because its main function is to facilitate communication between people. It has two methods of chat, namely channels (the group chats) and direct message (DM).
Slack channels can be public or private. When a chat is public, any member can see and join it, but when it is private, only the members of the chat can see and invite others to the chat.
Key Features of Slack
Here are a few key features of Slack that make it an indispensable tool:
- Integration with Other Tools: There are numerous project management features that can’t be replicated through Slack alone. Slack comes to the rescue with its integrations. Jira, Trello, Asana, Blossom are just a few of the project management interactions that you can find on Slack. Therefore, you can bring in tasks, cards, conversations, and notifications from multiple apps to make Slack your central location where things get done.
Apart from these integrations, IFTTT automation lets you get automated actions and reminders. With Tettra, you can easily create a wiki for your team inside Slack. By activating these integrations, you can easily turn your team into a full-fledged powerhouse. - Project-friendly Structure: The first step in using Slack for project management is to set up your team. You can make a single team channel for your entire company to communicate in. Or, if your company employs a large number of people, you can create different teams for every segment of your group. For most cases, a single team works out just fine. Every channel in Slack represents a stream of conversations that can revolve around a predefined topic.
Channels can be location-based, project-based, topical, integration-based, used only by a certain team, or limited to any group of individuals you deem fit. Slack automatically creates #random and #general channels that can be used across teams.
For company-wide project progress, channels like #sales, #marketing, #management, and #accounting might come in handy. Slack also allows you to create private channels for one-on-one conversations or small groups as needed.
It is more useful to keep the majority of the information flowing in the public channels. This helps ensure transparency and creates a searchable archive of your conversations. Through group communications, you can let a small number of people communicate without getting their messages lost in the shuffle.
These can be used multiple times allowing team members to look back on what they talked about last week, yesterday, or last year. - Task List Management: To-do lists are mainly used to encapsulate both small priorities and large tasks. Slack can easily integrate with tools like Todoist and Wunderlist.
These integrations allow you to add items to your task list straight from a Slack channel. You can also leverage the To-do bot to keep your entire task list inside Slack. You can also create your own Slack To-do list without using an integration.
By adding a star to a message you make it easier to find in the future. All you have to do is hit the “Show Starred Items” button. This allows you to see all the messages you’ve starred so far.
Pins can also work in a similar fashion. Pinned files and messages are shown in a prominent place in the channel so that your team members can easily refer to them. - Easy and Automated Reminders: Slackbot can help you keep track of your daily to-do list. All you need to do is type “/remind” in a channel, and tell Slackbot what you would like to be reminded of, and it will then ping you at your chosen time. You can also change the set team member to remind you of the task and the time.
For instance, “/remind me to send the article in two hours.” You can also expand upon the reminder features in Slack by customizing them to meet your needs. You can input information like where the nearest coffee shop is, or what your building wi-fi password is.
Whenever anyone asks one of these questions, Slackbot can provide an answer. - Collaborations with Posts: Posts is another great note-taking option that you can avail of in Slack. Posts allow team members to share project files, share documents, and work together on items that might be too big for messages.
You can think of it as a text document that can be passed back and forth between team members. Therefore, you can add checkboxes for tasks, work together on posts, and share them with anyone when they’re ready. You can consider Slack posts as a simplified version of Google Docs built into Slack. - Easy Note-taking: If you wish to jot some notes for a project or set a reminder, you can simply start a new Slack message chain with yourself. This allows your direct messages to be stored where you can find them later with ease.
Since these messages won’t get pushed down by new messages from your teammates, they’ll always be where you left them.
A fully managed No-code Data Pipeline platform like Hevo Data helps you integrate and load data from 100+ sources (including 40 Free Data Sources like Webhooks) to a destination of your choice in real-time in an effortless manner.
Get Started with Hevo for Free
Hevo with its minimal learning curve can be set up in just a few minutes allowing the users to load data without having to compromise performance. Its strong integration with umpteenth sources allows users to bring in data of different kinds in a smooth fashion without having to code a single line.
Check out some of the cool features of Hevo:
- Completely Automated: The Hevo platform can be set up in just a few minutes and requires minimal maintenance.
- Real-Time Data Transfer: Hevo provides real-time data migration, so you can have analysis-ready data always.
- 100% Complete & Accurate Data Transfer: Hevo’s robust infrastructure ensures reliable data transfer with zero data loss.
- Scalable Infrastructure: Hevo has in-built integrations for 100+ sources that can help you scale your data infrastructure as required.
- 24/7 Live Support: The Hevo team is available round the clock to extend exceptional support to you through chat, email, and support calls.
- Schema Management: Hevo takes away the tedious task of schema management & automatically detects the schema of incoming data and maps it to the destination schema.
- Live Monitoring: Hevo allows you to monitor the data flow so you can check where your data is at a particular point in time.
Sign up here for a 14-Day Free Trial!
Creating Webhook URLs Programmatically
When you are distributing your app to be used by non-collaborators, you will have to find a way for it to generate those URLs on the move. Here, you can use standard OAuth Install Flow to easily generate Incoming Webhooks. Here are a few adjustments that you’ll have to make to process the incoming Webhooks:
- Changing Scopes: As a component of the install process, your app defines a set of initial permission scopes to request from a user. Irrespective of whether you are using your own custom OAuth redirect or using the Slack button to provide a link for users to install your app, there will be a scope parameter that can easily set this initial set of permissions.
To generate Incoming Webhook URLs, you need to make sure that you’ve included the incoming-webhook permission in that scope list. Once you’ve done it, users will see extra permission on the Authorize screen that allows them to pick the channel where the Incoming Webhooks will post to. - Getting Incoming Webhook URL from the OAuth Response: Once a user has installed your app, and the app has completed the OAuth verification code exchange, you’ll receive a JSON response similar to the following code snippet:
{ "ok": true, "access_token": "xoxp-XXXXXXXX-XXXXXXXX-XXXXX", "scope": "identify,bot,commands,incoming-webhook,chat:write:bot", "user_id": "XXXXXXXX", "team_name": "Your Workspace Name", "team_id": "XXXXXXXX", "incoming_webhook": {
"channel": "#channel-it-will-post-to", "channel_id": "C05002EAE", "configuration_url": "https://workspacename.slack.com/services/BXXXXX", "url": "https://hooks.slack.com/TXXXXX/BXXXXX/XXXXXXXXXX"
}
}
You can observe that this OAuth response contains an incoming_webhook object. In the URL field, you can see your brand new Incoming Webhook URL. You can now go ahead and use this URL to post a message as demonstrated in the previous step.
How to Build Slack Incoming Webhooks?
Image Source
Here are the steps involved in building Slack incoming webhooks for Slack Webhooks Integration.
Slack Webhooks Integration: Enable Incoming Webhooks
Once you’ve added Slack to your workforce, you’ll be redirected to the settings page of your new app. If you’re using an existing app, just load its settings through your app’s Management dashboard for Slack Webhooks Integration.
From here, you need to select the Incoming Webhooks feature and click the Activate Incoming Webhooks toggle to switch it on. If you’ve already activated this, move on to the next step of Slack Webhooks Integration.
Slack Webhooks Integration: Create an Incoming Webhook
Once you’ve enabled incoming webhooks, the settings page should refresh and some additional options will appear. From these options, you can see a really helpful button marked as Add New Webhook to Workspace for Slack Webhooks Integration.
Click it to trigger a shortcut version of the installation flow for Slack apps. Since this method is self-contained you don’t need to build any code to generate an incoming Webhook URL.
Image Source
Next, pick a channel that the app will post to, and then click Authorize to continue. You’ll be sent back to app settings where you can see a new entry under the Webhook URLs for Your Workspace Section, with a Webhook URL that looks a bit like the snippet mentioned below:
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
This URL depicts your new incoming Webhook, one that is specific to a single channel and user. Next, you’ll be taking a look at how you can use this webhook to post a message.
Slack Webhooks Integration: Post a Message using Incoming Webhooks
For the purpose of this article, you can use “Hello World” for testing purposes. Simply make an HTTP POST request like in the code snippet mentioned below in this step of Slack Webhooks Integration:
POST https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Content-type: application/json
{
"text": "Hello, world."
}
Make sure that the URL you’re making the POST request to should be the same URL that was generated by you in the previous step. This completes the last step of Slack Webhooks integration.
Now, go and check the channel that your app was installed into, and you will see that the “Hello World” message has been successfully posted in your app.
You can also use this in a real Slack app without much change, simply substituting your favorite HTTP Request library for cURL. However, you will have to structure all the requests in the same manner.
Another point to note here is that incoming Webhooks don’t allow you to delete a message after it has been posted. So, if you need a more complex chat flow, one that includes message deletion, you can call chat.postMessage.
Managing Errors in Slack Webhooks
In most cases, you will be receiving an “HTTP 200” response with a plain text OK, that serves as an indication that your message was posted successfully. But, you need to be prepared for scenarios where attempts to publish a message will fail in Slack hooks.
Incoming webhooks might throw errors when utilized webhook URLs are no longer valid, receiving malformed requests, or when something truly exceptional prevents your message from making it through to users and channels.
Incoming webhooks usually return more expressive errors as compared to Slack’s web API, including more HTTP status codes. For instance, “HTTP 404 Not Found” or “HTTP 400 Bad Request”. Here are a few common errors you might encounter while establishing Slack Webhooks Integration:
- action_prohibited: This error usually means that an admin might have placed some sort of restriction on this avenue of posting messages and that, at least for now, the request should not be attempted again.
- posting_to_general_channel_denied: This is an error that is thrown when an incoming Webhook tries to post to the “#general” channel for a workspace where posting to that channel is restricted and the creator of the same incoming Webhook isn’t allowed to post there. You will be receiving this error with an HTTP status code of 403.
- invalid_payload: This error typically indicates that the received request is malformed: perhaps the message text is not properly escaped, or the JSON code is structured incorrectly. The request should not be retried without a correction first.
- channel_is_archived: This error indicates that the specified channel has been archived and is no longer accepting new messages.
- No_team: This error means that the Slack workspace was either invalid or missing.
- no_service_id: This error means that the service_id (B00000000 for instance) was either missing or invalid.
- Invalid_token: invalid_token means that the token used was either missing or invalid.
- team_disabled: This error means that the Slack workspace is no longer active.
Conclusion
This article talks about the different steps you can use to set up Slack Webhooks integration in a seamless fashion. It gives a brief introduction to Slack and Webhooks before diving into Slack Webhooks Integration.
Extracting complex data from a diverse set of free data sources such as Webhooks can be a challenging task and this is where Hevo saves the day!
Visit our Website to Explore Hevo
Hevo Data offers a faster way to move data from 100+ data sources such as SaaS applications such as Webhooks or Databases into your Data Warehouse to be visualized in a BI tool. Hevo is fully automated and hence does not require you to code.
Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand. You can also have a look at the unbeatable pricing that will help you choose the right plan for your business needs.