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

Supercharge your chat!

Supercharge your chat!

A talk about the value of (text) chat combined with chat bots can bring to a company and a demonstration of some of Err's (http://errbot.net/) features as a framework for implementation.

22-10-2014 @ Amsterdam Python Meetup Group (http://www.meetup.com/Amsterdam-Python-Meetup-Group/events/202046722/)

18bdcd2f189a9b8fe2f836dde8db09fc?s=128

Nick Groenen

October 22, 2014
Tweet

More Decks by Nick Groenen

Other Decks in Programming

Transcript

  1. Supercharge your chat! By @NickGroenen

  2. I do… DevOps

  3. Tools and Process

  4. Wrong!

  5. People problem, tech problem

  6. Communication

  7. Text chat

  8. Human <-> computer interaction

  9. None
  10. None
  11. Credits: http://matadornetwork.com/abroad/metric-map-which-countries-dont-belong-with-the-others/

  12. None
  13. Are you finished deploying yet? Can I deploy mine? Who

    deployed that last change? Did you see that Nagios alert? Who's looking into it? Did you see issue 205? Issue 205? Yeah it's that issue about midnight being false. Oh, that one! Yes I saw it.
  14. None
  15. Err The pluggable chat-bot http://errbot.net/ https://github.com/gbin/err

  16. Err is a GPL3-licensed chat bot for Jabber XMPP and

    IRC networks, designed to be easily deployable, extendable and maintainable.
  17. Supports Python 2.7 and Python 3.3+ Platform independent (yes, Windows!)

  18. Pluggable & emphasis on sharing

  19. None
  20. Simple but powerful

  21. from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!'

    plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"
  22. from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!'

    plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"
  23. from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!'

    plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"
  24. from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!'

    plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"
  25. from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!'

    plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"
  26. from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!'

    plugin for Err""" @botcmd(name="helloworld") def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"
  27. from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!'

    plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"
  28. from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!'

    plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"
  29. @botcmd def hello(self, msg, args): """Say hello to the world"""

    return "Hello, world!" msg.frm -> "xxxxxxxx@conf.hipchat.com/Nick Groenen"
  30. @botcmd def hello(self, msg, args): """Say hello to the world"""

    return "Hello, world!" msg.frm -> "xxxxxxxx@conf.hipchat.com/Nick Groenen" msg.type_ -> "groupchat"
  31. @botcmd def hello(self, msg, args): """Say hello to the world"""

    return "Hello, world!" msg.frm -> "xxxxxxxx@conf.hipchat.com/Nick Groenen" msg.type_ -> "groupchat" msg.body -> "!hello"
  32. @botcmd def hello(self, msg, args): """Say hello to the world"""

    return "Hello, world!" msg.frm -> "xxxxxxxx@conf.hipchat.com/Nick Groenen" msg.type_ -> "groupchat" msg.body -> "!hello" msg.html -> None
  33. @botcmd def hello(self, msg, args): """Say hello to the world"""

    return "Hello, world!" msg.frm -> "xxxxxxxx@conf.hipchat.com/Nick Groenen" msg.type_ -> "groupchat" msg.body -> "!hello" msg.html -> None msg.to -> "xxxxxxxx@conf.hipchat.com/Err Bot"
  34. @botcmd def hello(self, msg, args): """Say hello to the world"""

    return "Hello, world!" !hello -> args = ""
  35. @botcmd def hello(self, msg, args): """Say hello to the world"""

    return "Hello, world!" !hello -> args = "" !hello Err Bot -> args = "Err Bot"
  36. @botcmd(split_args_with=None) def hello(self, msg, args): """Say hello to the world"""

    return "Hello, world!"
  37. @botcmd(split_args_with=None) def hello(self, msg, args): """Say hello to the world"""

    return "Hello, world!" !hello Err Bot -> args = ["Err", "Bot"]
  38. Returning multiple responses from errbot import BotPlugin, botcmd from time

    import sleep class PluginExample(BotPlugin): @botcmd def longcompute(self, mess, args): yield "Going to sleep" sleep(10) yield "Waking up"
  39. Returning multiple responses from errbot import BotPlugin, botcmd from time

    import sleep class PluginExample(BotPlugin): @botcmd def longcompute(self, mess, args): yield "Going to sleep" sleep(10) yield "Waking up"
  40. Templates hello.html: {% extends "base.html" %} {% block body %}

    <p style='font-weight:bold'>Hello, {{name}}!</p> {% endblock %}
  41. Templates from errbot import BotPlugin, botcmd class Hello(BotPlugin): @botcmd(template="hello") def

    hello(self, msg, args): """Say hello to someone""" return {'name': args}
  42. Templates from errbot import BotPlugin, botcmd class Hello(BotPlugin): @botcmd(template="hello") def

    hello(self, msg, args): """Say hello to someone""" return {'name': args}
  43. Webhooks from errbot import BotPlugin, webhook import logging class PluginExample(BotPlugin):

    @webhook def example(self, incoming_request): logging.debug(repr(incoming_request)) return "OK"
  44. Webhooks from errbot import BotPlugin, webhook import logging class PluginExample(BotPlugin):

    @webhook def example(self, incoming_request): logging.debug(repr(incoming_request)) return "OK"
  45. Webhooks $ curl -i http://localhost:3141/example HTTP/1.1 200 OK Content-Length: 2

    Content-Type: text/html; charset=UTF-8 Date: Tue, 05 Aug 2014 01:40:01 GMT Server: Rocket 1.2.4 Python/3.3.2+ Connection: keep-alive OK
  46. Webhooks from errbot import BotPlugin, webhook import logging class PluginExample(BotPlugin):

    @webhook(r'/custom_uri/.*/') def example(self, incoming_request): logging.debug(repr(incoming_request)) return "OK"
  47. None
  48. Extensive configuration # Allow everyone access by default ACCESS_CONTROLS_DEFAULT =

    {} ACCESS_CONTROLS = { 'status': {'allowrooms': ('room@conf.server.tld,)}, 'about': {'denyusers': ('baduser@server.tld,), 'uptime': {'allowusers': BOT_ADMINS}, }
  49. Extensive configuration DIVERT_TO_PRIVATE = ('help', 'about', 'status')

  50. Tests (pytest) from errbot.backends.test import \ testbot, push_message, pop_message extra_plugin_dir

    = '/foo/bar' def test_about(testbot): push_message('!about') assert "Err version" in pop_message()
  51. Tests (stdlib unittest) from errbot.backends.test import \ FullStackTest, push_message, pop_message

    class TestCommands(FullStackTest): def setUp(self): super().setUp(extra_plugin_dir='/foo/bar') def test_about(self): push_message('!about') self.assertIn("Err version", pop_message())
  52. http://errbot.net/user_guide/plugin_development/

  53. Questions?