Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Scalable Slack Bots With Go

Building Scalable Slack Bots With Go

Relax: a Slack bot framework that helps you build slack bots that scale to 1000s of teams

iamclovin

June 14, 2016
Tweet

More Decks by iamclovin

Other Decks in Programming

Transcript

  1. about • Founder of Ze Robot Labs • Have been

    building Slack bots since May ‘15 • Built Nestor — https://asknestor.me, a “hosted Hubot” that has been installed in 1300+ Slack teams • Built Relax — an open source message broker that lets you build scalable Slack bots • Run botweekly.com
  2. 2016 — year of the bots source: On Bots, Conversational

    Apps and Fin — The Information https://www.theinformation.com/on-bots-conversational-apps-and-fin
  3. design goals • Handling Messages from 1000’s of teams •

    De-Coupled from the Web App (with biz logic) • Multiplexed Single Stream of Events • Low Memory Footprint • Ability to run multiple instances of Relax
  4. implementation • One go routine per team and maintains a

    persistent websocket connection with Slack • Go routines to handle keeping connection alive, health checks and so on • Use Redis to maintain state and allow Relax to be deployed in a highly available configuration • Events are Slack are converted into JSON blobs and are pushed to a Redis queue which can be consumed by a Rails app • Events are not duplicated as they are sent to the web app no matter how many Relax instances are deployed
  5. results • Maintain connections from 1200+ teams on a single

    Heroku dyno (512MB) • Handle tens of thousands of events on a daily basis without skipping a beat • Allows developers to focus on building great value in the bot itself and not worry about scalability
  6. • People don’t want to deal with running & sysadmin’ing

    a Go daemon (& Redis) • Web developers overlook that with Slack bots you have to maintain websockets and it’s no longer a stateless Request-Response cycle • People don’t know how their bot is doing in terms of analytics/engagement
  7. enter botmetrics • “Relax as a Service” • Your web

    hook is called with JSON blobs that represent Relax events • Bot Metrics for free • Write a single line of code to use Botmetrics: https:// github.com/botmetrics