How we integrated Talko calling & conferencing into Slack channels


UPDATE: Our Slack integration is now “official” and openly available. No longer any need to sign up for the private beta.


Slack is a wonderful communications tool. We use it every day at Talko, as do some of our customers who frequently work at their desks. Those customers asked us to better integrate their team communications by bring Talko’s mobile calling and conferencing capabilities to Slack. So we did.

You can read more about the scenarios for our Slack integration here. You can also sign up to be a beta user — we’d love to have you! In this post, we give an overview of Slack APIs that can be used for building integrations and talk about how we implemented our scenarios.

Slack APIs

Slack provides a number of integration APIs. Webhooks offer the simplest mechanism to consume or post information from/into Slack.

Incoming webhooks allow an external service to post into Slack with a simple HTTP request. Want to enable your users to see information about your service in Slack? Incoming webhooks is a great place to start. Examples include Airbrake (error reporting service), PagerDuty (alarming service), Jira (issue tracking service) and many other reporting services.

Outgoing webhooks are used to send a limited set of information to one or more external URLs and optionally post back a response into Slack. This allows Slack users to interact with your service from right inside the Slack client. However, there is one important caveat: outgoing webhooks are limited to public channels and can’t be triggered from private groups or direct messages. The way around this limitation is to use a slash command integration, which works across all types of Slack channels. Examples include Hangouts, Appear.in, Giphy and many more.

In addition to incoming and outgoing webhooks, Slack provides a much richer interaction using their Real Time Messaging API and Web API. The Real Time Messaging API is a Websocket interface that provides events for activity in Slack and the ability to post messages as the user. It serves as the basis of the Slack clients and bot integrations. The Web API provides access to the Slack data model: channels, users, team, chat, etc.

Talko integration

Our goal was to enable users to initiate Talko calls and team conferences from public channels, private groups and direct messages in Slack. Since we were triggering a call from Slack, we started with outgoing webhooks. However, to support the scenarios in private groups and direct messages, we needed to move to slash command integration. When a user types the slash command, it sends limited metadata about the Slack user, channel and team. In addition to this metadata, the Talko service needs each user’s email address so that we can match to a Talko account and ring all channel members. We use the Web API to get that information.

  • Initiate a Talko call from Slack: The slash command sends a request to the Talko service with the slack team_domain, channel_id, channel_name and user_id parameters. The Talko service stores these parameters and responds back with a message containing a link for creating the Talko call. The link contains the key which the Talko service can use to retrieve the slash command parameters.
Slash command: /talko sends request to Talko service. Talko service responds with a link to start a new Talko call.
  • Create the Talko call with a label: When the user opens the link, the Talko service gets the slack channel_id and user_id it had stored earlier and uses the Slack Web API to get emails for members of the channel. The channel members’ email addresses are used to find each user’s Talko account and initiate a call to their Talko iOS app.
Clicking Ring initiates a call and routes it to all channel members’ iOS Talko client.
  • Post back message with link to the Talko call in Slack: The contents of a Talko call don’t go away once the call ends. Live calls are saved and available in Talko to make it easy to organize, find, replay and share key moments. To make the calls available right from Slack, we post back a message with a link to the call in the channel using the Web API.
Talko service posts a link visible to all channel members to enter the call in Talko web client.

Authorization

When a user hits “Start a new Talko call in this channel” link, the Talko service needs to make Web API calls to get channel membership details to ring the Talko app. These Web API calls require an access token. Slack uses OAuth2 to seek user consent before granting this access token. The Talko service redirects the user to the Slack OAuth page where the user can grant or deny permission. On getting a user response, Slack gives the Talko service a short lived code to request the access token.

Slack OAuth page

Here are a few helpful hints for working with the authorization process.

  1. Repeated authorization induces click fatigue. To ensure a smooth user experience, we cache the access token after the user has authorized the Talko integration for the first time.
  2. A single user with multiple teams in Slack is a fairly common usage pattern. Since the access token is scoped to a user in a team, multiple access tokens need to be cached.
  3. Instead of storing the user’s access token on the service, we decided to store the token as a cookie on the client. This ensures that a potential attack on our service doesn’t compromise the user’s Slack account.

Thats a brief overview of how we built the Talko integration for Slack. Get Talko and sign up to try out the Slack integration. We hope you’ll like it as much as we do — please let us know what you think. If you have specific questions, please comment right here on Medium, email me at hemantk@talko.com, or find me on Talko by searching for my email address!