Save 37% off PRO during our Black Friday Sale! »

Embracing ChatOps @

Embracing ChatOps @

#Development #Workflow #Bot #Lita



March 17, 2017


  1. Embracing ChatOps exAspArk Evgeny Li

  2. None
  3. • Dedicated servers • Cloud servers • Cloud storage •

    Free global private network in Amsterdam, Dallas, Luxembourg, Moscow, Singapore, Washington, Hong Kong
  4. Products we use

  5. Why not to use Slack, GitHub, NewRelic, etc.? We avoid

    using SAAS
  6. We take security seriously!

  7. So what is ChatOps? Managing technical and business operations

    through a chat
  8. Who uses ChatOps

  9. Why use ChatOps • Automate manual tasks • Increase speed

    of actions • Increase visibility and transparency • Collaborate, share knowledge and learn • Use the same instrument – just your chat • Automate logging of conversations and commands • Use from mobiles
  10. How to start • Choose a framework to build

    a bot. The most popular ones are: • Hubot (CoffeeScript) • Lita (Ruby) • Errbot (Python) • Find adapters for your messenger. E.g. Slack, HipChat • Install useful Hubot scripts, Lita plugins, Errbot plugins • Write custom message handlers
  11. How we use ChatOps Self-hosted HipChat + Lita bot

  12. Lita bot sample # Gemfile source '' gem "lita" gem

    "lita-hipchat" # lita_config.rb require 'lita-hipchat' require 'handlers/exchange' Lita.register_handler(Handlers::Exchange) Lita.configure do |c| = 'bot' if ENV['CONSOLE'] c.robot.adapter = :shell else c.robot.adapter = :hipchat c.adapters.hipchat.jid = ENV['HIPCHAT_JID'] ... end end # handlers/exchange.rb module Handlers class Exchange < Lita::Handler route /exchange\s+(\w+)\s+to\s+(\w+)/i, :perform, command: true, help: { "exchange USD to EUR" => "Shows exchange rates" } def perform(response) from = response.matches[0][0] to = response.matches[0][1] rate = fetch_rate(from: from, to: to) response.reply("#{from} to #{to}: #{rate}") end end end
  13. Lita bot sample $ CONSOLE=true bundle exec lita start bot

    > bot help help - Lists help information for terms and command the robot will respond to. help COMMAND - Lists help information for terms or commands that begin with COMMAND. info - Replies with the current version of Lita. users find SEARCH_TERM - Find a Lita user by ID, name, or mention name. exchange USD to EUR - Shows exchange rates bot > bot exchange USD to EUR USD to EUR: 0.94144
  14. Example: gitflow hotfix start

  15. Example: gitflow release start

  16. Example: branch changelog

  17. Example: deploying to staging with lock

  18. Example: deploying to staging with lock

  19. Example: list stagings

  20. Example: rerunning build on CI

  21. Example: finding a scapegoat for troubleshooting :)

  22. Example: error handling

  23. Example: deploying any app / service to production

  24. Major concerns There are some issues you have to pay

    attention to before starting to use ChatOps!
  25. Security • We use self-hosted messenger • Bot is not

    reachable from the Internet • Added authorization checks for commands
  26. Old habits die hard • Some people don’t know how

    to use bots • Create useful “help” commands with descriptions • Invite and show them how to use it by example • Some people don’t trust robots and prefer to do everything manually • Let them learn from their mistakes. Bots are more reliable in performing repetitive tasks • Colleagues will like transparency of using bots
  27. Avoid information overload • Split channels in your messenger. For

    example: staging deploys, production deploys, working with repositories, builds, troubleshooting, monitoring, etc. • Mute or leave some unimportant channels. Fight your fear of missing out
  28. Prepare to write a lot of code • Start small,

    iterate quickly, think big • Make it easy to run your bot. E.g. “make run” • Allow everyone to contribute, do code reviews • Write documentation, style guides, tests, useful utils • Prepare infrastructure: access, database, deployment, logs, monitoring, error handling, CI / CD, etc.
  29. Always have a plan B • Be ready when your

    messenger / bot is unavailable • Describe how to perform the most important actions manually
  30. Thank you! Protect the children because they – and robots

    – are the future Adam Carolla