How to integrate with the Slack platform

More than simply another collaboration solution, Slack has RESTful APIs that let you exchange data with -- and trigger actions in -- all sorts of dev tools and applications

Developers need collaboration tools. First there was email, then there were private IRC servers, then came public instant messaging tools -- all ways of quickly sharing information across teams. Technologies like XMPP added open protocols that allowed software to enter the conversation, a model that was extended by document and service integration points in Salesforce’s Chatter and Microsoft’s Yammer.

Now we have Slack, a popular Web-based collaboration tool that builds on the lessons of earlier applications -- and is designed to be a platform in its own right.

Slack enables developers to have both formal and informal conversations inside and outside their organizations. Externally, Slack can be used to bring together communities of interest around new technologies, development methodologies, languages, and platforms.

What makes Slack particularly interesting for developers, however, is its integration with tools used in modern development environments. For example, GitHub integration lets you monitor your project repositories, allowing you to see at a glance what code has changed and what new branches have been created.

Adding services to Slack makes it easier to view what the rest of a team is doing, whether you’re in the same office or spread around the world. Other integrations tie into the devops workflow -- linking with tools like Jenkins or Visual Studio Online for builds -- or connect with services that help manage uptime or provide user support (such as Pingdom, Zendesk, or PagerDuty). Other integration points help pull together distributed teams, adding videoconferencing support for global standups and basic tools for tracking developer and project status.

Getting in and out

The key to Slack’s rapid uptake by tool vendors is its simple RESTful API and generalized support for open Web standards. With WebHooks, for example, it’s easy for an application to send data into and get data out of Slack. There’s also the option for deep integration with the service using a real-time messaging API based on the WebSocket protocol.

Slack’s WebHook support enables you to send the same JSON payloads as you’d send to any other application. What’s important is that Slack handles the data in real time, using a bot to handle the connection and to post the data to a Slack channel. Your JSON payload can be as simple as a piece of text, though in practice you’re likely to send a link to results or an alert in another application.

Slack offers a simple way of formatting and displaying hyperlinks, digesting anything in a set of angle brackets as a URL -- and where there’s a pipe character, using the text that follows the pipe as a clickable link. For example, if a compiler sent a message payload that contained the string “<|Output of Job 2345>,” you’d be presented with “Output of Job 2345” as a clickable link. Slack offers its own formatting markup for messages, which can be used in WebHook content, and there’s the option of using attachments to deliver more complex messages.

Bots can be customized, giving your incoming WebHooks custom names and their own icons. Similarly, you can give WebHooks access to other channels, along with the ability to send direct messages to specific users.

Slack takes command

WebHooks aren’t limited to incoming connections to Slack -- they can also be used to deliver messages from a Slack channel to an external app. If you’re using Jenkins to handle a build process, for example, a trigger word on a specific channel could start a new build. Because outgoing WebHooks must be public, they can be seen by everyone in the channel, so your entire team knows that a task has been triggered.

Slack’s slash commands offer another way to trigger calls to external Web applications. These are quick shortcuts that wrap a query URL and send the appropriate data to the service. If you use a tool that has a simple query-and-response API, slash commands are a quick and easy way of adding it to a team’s Slack space.

While Slack’s basic integration tools let anyone quickly add bots to a channel and customize them, the heart of the platform is its JSON API. With HTTPS for security, it uses POST and GET to drive the service. It’s a well-designed API, with descriptive method names that make it clear what you’re calling and what responses you’re expecting. You can automate channel operations, allowing a team to capture a day’s conversations in an archive, or quickly add and remove members as teams change.

For most integrations, you’re going build tools that are at heart chatbots, posting messages to the service and listening for keywords to trigger actions. Working with chat services means you’ll be writing asynchronous code, with your application quiescent for much of the time. That’s not a problem in most cases, when you’re working with query/response services and triggers. Much of what we do as developers isn’t deeply interactive, and Slack is an appropriate surface for the interactions we have outside of specific applications.

Slack’s integration points are deliberately simple. That’s a good thing. Chat services aren’t control panels and devops frameworks -- they’re places for ad hoc (and occasionally formal) collaboration, and any application that plugs into that environment needs to respect the ways users are working with the service.

What Slack is good for is surfacing error conditions and alerts, giving us a place to see that something has happened, then a way (usually via a link) to find out more. With services like this, we’re using chat and messaging as a dashboard. We can flag messages and pin items, but it’s still up to us as users to respond to them and to make them part of how we work.

Copyright © 2015 IDG Communications, Inc.

How to choose a low-code development platform