Introduction to working with Slack programmatically

Slack API
Slack user ID by email API
Slack channel ID API
Slack Message API
slack programmatically blog trayai symbol the motis

Learn how to use Slack’s API to increase collaboration and productivity throughout your organization dramatically. Build Slack apps that help you do more faster.

Chat-based collaboration tools like Slack can improve communication across your organization, helping your employees work smarter and be productive. And as your organization grows and becomes more distributed, these tools are an increasingly important resource to share information to a large audience quickly. But did you know that you can tap into even greater alignment, efficiency, and output by integrating data from across your organization to power alerts, approvals, provisioning processes, and more?

The modern enterprise uses almost 2,000 different applications across its tech stack, meaning that the different teams in your organization likely store data in any number of systems and sources. Your sales team, for example, might work primarily out of customer relationship management systems (CRMs) such as Salesforce, HubSpot, or Zendesk Sell. And when a sales rep hears a prospect mention a top competitor in your industry, they would naturally record that information in your CRM. But what if your marketing team had insight into which of your competitors were mentioned most in sales calls to build better messaging and content that boosts win rates? Or what about senior leadership, who could use this information to direct sales strategy but might not work in a CRM day-to-day?

Working With Slack API Programatically 1

The rising number of SaaS applications at the modern enterprise. Source: McAfee

System administrators, IT techs, and many different line-of-business users can share information more effectively by integrating their business-critical data into Slack. Luckily, Slack’s application programming interface, or API, lets you pass data between Slack and your other cloud-based tools.

In this guide, we’ll teach you the fundamentals of working with Slack’s API so that you can build automated processes to improve team productivity and efficiency. First, we’ll cover the basics of the API, including the workflow builder, apps, and authorization. Then, we’ll share common use cases for which you can use Slack’s API to do more, faster, plus a few of the roadblocks that you might encounter. Finally, we’ll offer ideas and best practices on how to build apps and bots using data from your favorite tools.

Slack API 101

Slack’s API is the vehicle for building integrations that pass data between your other cloud-based tools and Slack. If, for instance, you wanted to create an alert in Slack every time a new lead submitted a form on your marketing site, you would need to engage Slack’s API to capture and deliver that alert.

Within Slack, you’ll work with four main APIs that let you move and manipulate data in different ways. These APIs are:

  • Real-Time Messaging API - Slack’s Real-Time Messaging API surfaces every single message or event inside your Slack instance in a single feed. For example, if you want to build a program that monitors every time one of your teammates reacts with an emoji, you might consider using Slack’s messaging API. Note: Unless you’re building a process that interfaces with every single message or event, Slack recommends you use other APIs that filter data into more-specific buckets.

  • Events API - Slack’s Events API lets you specify the events you want to capture in your Slack instance for a more-controlled experience. For example, you can use the Events API to access a list of message activity from a specific channel or subset of users. You’ll use the Events API when sending data from Slack to another source. The majority of data projects in Slack use either the Events or Web API.

  • Web API -The Web API acts in tandem with the Events API; The Events API sends data from Slack to another source, while the Web API receives the response. You’ll use the Web API when posting data from other sources back in Slack.

    • Conversations API -The Conversations API is a subset of the Web API. It offers additional functionality to make changes to both public and private channels, as well as shared channels and direct messages.

Outside of the tool’s more-popular APIs, Slack offers a few niche solutions, including Admin APIs, SCIM APIs, Audit Logs APIs, and the Status API. Depending on your project needs, you can use any combination of these APIs to manipulate data in Slack. Now that we’ve covered the purpose of each API, let’s review the difference between workflows and apps.

Workflows and apps

In Slack, you can power efficiency-driving automated processes using one of two features:

The workflow builder lets you build custom automated processes using data in Slack. Say, for example, you wanted to send your team a daily reminder to share their priorities for the day. Simple operations like regular notifications are easy to stand up, but you cannot use the workflow builder to design more-complex use cases that require data from external sources, as the builder does not interact with Slack’s API.

Slack apps, on the other hand, are the primary method for building API-powered integrations and other processes involving external data. With Slack apps, you can tap into far greater customization by accessing pre-built integrations in the App Directory or creating your own. Slack apps can do anything from tracking customer tickets from a support tool like Zendesk to facilitating multi-stage deal desk approvals within your sales leadership team.

While Slack’s App Directory offers a wide variety of integrations with popular tools, these apps tend to have limited functionality centered around static alerts and basic approvals. Custom apps, meanwhile, have nearly limitless capabilities but often require IT or developer resources to set up.

What are Slack bots?

Slack bots are a subset of apps that are responsive to your end-user. A Slack bot can have a conversation with your user to trigger different commands based on the responses it receives. Bots can perform administrative tasks in Slack, such as inviting someone to a channel or sending custom messages. They can also perform actions in other systems, such as creating a new lead record in a CRM like Salesforce or marking updates to an HR tool like BambooHR.

Bots can also use exciting new technologies such as natural language processing, or NLP, to deliver highly personalized actions or resources based on your responses.

Permissions and security in Slack

Slack’s API can unlock powerful integrations with your favorite tools, but unrestricted app use can present security risks. For example, your Slack instance may contain sensitive data that could be vulnerable in another application that is less secure. That’s why many security teams choose to control approval and access to apps. Your Workspace Owners can define these controls for your Slack instance in the security preferences panel. Note: For Slack’s recommendations for controlling access to apps, check out this resource.

Why we work with Slack’s API

Working with Slack’s API lets teams in marketing, sales, services, HR, IT, finance, and any other department centralize and optimize existing processes to drive productivity and efficiency gains. You can integrate Slack across your organization in your employee onboarding processes, sales approvals processes, sales development alerts, and much more.

Who works with Slack’s API?

Entire organizations use chat tools like Slack to collaborate on projects and other day-to-day tasks. Here are a few of the key roles that work specifically with Slack’s API to build apps:

  • IT and systems administrators - IT and system administrators work with Slack’s API to build custom apps for the entire organization. Often, these professionals manage all systems that your organization uses and track licenses to meet internal security requirements. Administrators can build processes for the entire organization, including provisioning, approvals, and alert-related apps.

  • HR administrators - HR administrators also work with Slack’s API to build out custom onboarding and provisioning applications to help new employees get up to speed and enable existing employees with the tools they need to be successful.

  • Line-of-business users (Marketing, sales, services, finance, and others) -

    While IT and HR administrators tend to own Slack integrations in larger organizations, there is a growing demand from line-of-business users in many organizations to tap into the benefits of automated processes in Slack and other tools. Often, these line-of-business users interact with Slack’s API and don’t realize it, such as when a user installs a pre-built app from Slack’s App Directory.

Common use cases when working with Slack’s API

Since Slack is such a flexible tool, you can use Slack’s API to fulfill any number of use cases. Here, we’ll focus on three broad categories of Slack apps: Onboarding and provisioning, approvals, and visibility and alerts.

Onboarding and provisioning

Many IT and HR teams are responsible for user provisioning, or the process where end-users request and receive access to the software they need to excel in their role. And often, these same teams manage new hire onboarding. But manually provisioning employees can be a surprisingly challenging task. Why? As your organization grows, your teams may be required to rapidly provision many new accounts for many new hires. Your company may also be needed to manage access levels on specific applications for certain users (such as giving senior engineers administrator access to technical tools and junior team members read-only access). In addition, as your company grows and changes over time, your teams may also need to change access for existing users, onboard existing users onto new applications, or even deprovision accounts for departing team members. Not to mention the growing number of SaaS tools we noted earlier (almost 2,000 tools on average) makes manual provisioning an overwhelming task that can keep you from other business-critical projects.

Luckily, you can build an automated IT provisioning process of your own using Slack’s API. Not only do these processes save significant time for your system administrators, but they can also help new employees hit the ground faster and enable existing employees to do their jobs more effectively. Automated provisioning in Slack also offers a centralized way to track active licenses to ensure you adhere to modern security standards, including SOC 2.

Working With Slack API Programatically 2

Automated IT provisioning in Slack


As your organization collaborates on recurring projects, approvals processes can align stakeholders and increase efficiency. For example, a deal desk is an approval process in sales that submits pending deals for executive approval to ensure that all engagements are worthwhile for the business and the prospect. Deal desks yield such significant efficiency gains that they have become standard in more than 70% of modern sales organizations.

At the same time, multi-stage approvals processes can take time and prevent your team from being agile and responsive. By integrating your approvals processes in Slack, you can streamline the strategic decision-making process so that you don’t need to waste time chasing down busy stakeholders.

Working With Slack API Programatically 3

A deal desk approvals alert in Slack

Visibility and alerts

Surfacing key insights and metrics to those that need them can help your organization track performance and make adjustments accordingly. Slack alerts aren’t a new invention, but they play a critical role in arming your team with valuable insights fast. Your sales team can use alerts based on actions in your sales engagement tools, such as Outreach or Salesloft, to track quota attainment and adjust efforts accordingly. Your customer support team can use churn prediction reminders to re-engage opt-out customers. And other users across product, revenue, and operations can use alerts to monitor critical systems and processes.

Working With Slack API Programatically 4

A quota alert in Slack for the sales development team

Using bots to power Slack apps

You can use bots to deliver greater customization and better user experience for the use cases we discussed above and more. As a reminder, bots are essentially the same as other Slack apps, but they can understand and satisfy different customer requests with the inputs from the end-user. For example, you can build an onboarding bot that offers different resources and provisions different tools depending on the end-user’s team. Or, you could build a bot that shares sales assets based on product or persona.

For a list of actions that a bot can execute, check out this resource from Slack.

How to build and use apps in Slack

Depending on your specific use case and technical expertise, you might consider using a pre-built Slack app or designing your very own. Here are a few things to keep in mind when using and building Slack apps:

Using Slack’s App Directory

As we mentioned earlier, many Slack users regularly interface with Slack’s API, but they don’t even realize it. These users rely on Slack’s extensive App Directory to quickly implement pre-built integrations that power simple projects. While the App Directly offers integrations with more than 1,000 different services, these apps can be quite limited in functionality and customization, making it impossible to implement more-robust automated processes.

Tips for building your own Slack apps

If you have the technical chops, you might consider building your own Slack app from scratch. Slack’s API documentation portal offers extensive tutorials and other resources on how to build a Slack app, but you should have a solid understanding of your use case before diving in. Once you’ve outlined your use case, consider which specific APIs you’ll need by referencing the list we shared above.

Referencing data in Slack with IDs

When building a Slack app, you’ll need to reference specific object IDs to reference messages, channels, users, and more. Each object has an associated ID that you can pull with a GET request and use to access or edit existing objects. You can reference objects such as a Slack Channel ID, Slack user ID by email, and more using Slack’s API. Also, you can parse object ID’s into readable formats that link directly to the reference message, channel, or other object using Slack’s syntax.

Challenges when building your own Slack apps

Non-technical can struggle when building their own Slack app, as you’ll need to have a strong understanding of both Slack’s API and extensive coding experience to build even the simplest of apps. Custom apps are built from scratch, meaning you won’t be able to rely on the pre-built functionality you’d find in the App Directory or the ease-of-use of the Slack workflow builder.

And even for technical users, there are some limitations you should consider when building out your next Slack app. For one, you can’t send data to more than one place at a time, meaning that it can be hard to route different responses to unique outcomes. Also, Slack apps can only process data from one source at a time, so it is equally challenging to take information from multiple tools and present it in a single message. And Slack apps also have limits for moving data through multi-step processes.

Challenge #1: You can’t route data to separate outcomes Every time your end-user engages with a Slack app, including actions such as button presses or slash commands, Slack’s API sends their actions to a single endpoint. This setup can present challenges if you want to create an app that handles multiple kinds of interactivity, as you’ll have to build complex filtering and other logic in the back end of your app to manage those interactions.

Say, for example, you wanted to build a conversational bot that handles both new employee onboarding and existing employee provisioning Instead of directing each button press to a different process (provisioning multiple tools vs just one), Slack’s existing functionality requires you to send both responses to the same endpoint. From there, you'd need to create additional logic that routes different actions to different outcomes. In more complex use cases, routing data to a single endpoint can be limiting as you try to map an increasing number of data points to specific outcomes.

Challenge #2: Slack apps can only process data from one source at a time Similarly, Slack apps can only present data from a single source at a time. In the same user provisioning example we mentioned above, you’d probably want to include a picklist for your employees to request access for available software tools. But the native capabilities of Slack apps prevent you from pulling that list of data from more than one source. This functionality can be limiting when attempting to combine data from multiple sources to present your end-user with a cohesive list of options.

Challenge #3: Limitations when passing data through multi-step processes Another challenge you may encounter when working with Slack’s API is the inability to pass more than small sets of data through a specific process. When working with bots that require an exchange of multiple messages from the end-user, you naturally might need data from earlier in the conversation to power additional responses from your bot. Unfortunately, Slack limits the data you can pass from one interaction to another, which can complicate more-robust processes that trigger different actions throughout a conversation.

Alternative: How AI-powered iPaaS lets you build better Slack apps

Instead of building time-consuming custom apps from scratch or relying on the limited functionality of pre-built ones, you might consider using an AI-powered iPaaS. Modern iPaaS like Tray are low-code platforms that integrate different systems to power robust automated processes called workflows. Each workflow combines pre-built connectors with logic-based helpers to let you build a custom process of your own without the traditional limitations of Slack apps.

Tray is flexible enough to satisfy any use case that you can address with Slack apps. You can unify and streamline dynamic provisioning processes by integrating Slack with your IT service desk tools. Or, you can build out approvals processes that consolidate stakeholder feedback and move projects to completion faster. And certainly, you can stand up alerting workflows to pass valuable insights from any system into your preferred channels or direct messages.

Using Tray to automate competitive intelligence in Slack

One of the many ways you can use Tray to centralize critical business data is by instantly alerting sales reps of competitor mentions in customer calls. If you’re familiar with sales strategy, you know that when a prospect mentions one of your competitors in a call, it means they may be evaluating alternative products in your industry. And research shows that deals where a prospect mentions a competitor are actually 49% more likely to close, but only if the rep acts fast to establish brand superiority early in the sales cycle. So it can be critical for your reps to have a clear understanding of when they’re in a competitive deal.

Luckily, we can use Tray to pull competitor mentions from your sales conversations into Slack:

Working With Slack API Programatically 6

Listening for competitor mentions and surfacing them in Slack

We start with a webhook trigger, which listens for competitor mentions in (you can see how we set this up in our full walkthrough). Next, we pull the full context from the call, including the competitors that your prospect mentioned and a link to the call. Then, we pull corresponding opportunity context from our CRM, Salesforce, including the account name, stage, owners, and ARR. Finally, we format and send our competitive alert in Slack, which looks something like this:

Working With Slack API Programatically 7

A competitive intelligence alert in Slack

And that’s not all you can do with competitive alerts in Slack. You can customize this logic to send messages directly to account owners and deliver competitive one-pagers to help boost win rates.

Interested in learning more about how a modern iPaaS like Tray can transform any process? Watch a quick demo.

Subscribe to our blog

Privacy Policy