$30 off During Our Annual Pro Sale. View Details »

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/)

Nick Groenen

October 22, 2014
Tweet

More Decks by Nick Groenen

Other Decks in Programming

Transcript

  1. Supercharge your chat!
    By @NickGroenen

    View Slide

  2. I do…
    DevOps

    View Slide

  3. Tools and
    Process

    View Slide

  4. Wrong!

    View Slide

  5. People problem,
    tech problem

    View Slide

  6. Communication

    View Slide

  7. Text chat

    View Slide

  8. Human <-> computer
    interaction

    View Slide

  9. View Slide

  10. View Slide

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

    View Slide

  12. View Slide

  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.

    View Slide

  14. View Slide

  15. Err
    The pluggable chat-bot
    http://errbot.net/
    https://github.com/gbin/err

    View Slide

  16. Err is a GPL3-licensed chat bot for Jabber
    XMPP and IRC networks, designed to be easily
    deployable, extendable and maintainable.

    View Slide

  17. Supports Python 2.7 and Python 3.3+
    Platform independent (yes, Windows!)

    View Slide

  18. Pluggable & emphasis
    on sharing

    View Slide

  19. View Slide

  20. Simple but powerful

    View Slide

  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!"

    View Slide

  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!"

    View Slide

  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!"

    View Slide

  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!"

    View Slide

  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!"

    View Slide

  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!"

    View Slide

  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!"

    View Slide

  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!"

    View Slide

  29. @botcmd
    def hello(self, msg, args):
    """Say hello to the world"""
    return "Hello, world!"
    msg.frm -> "[email protected]/Nick Groenen"

    View Slide

  30. @botcmd
    def hello(self, msg, args):
    """Say hello to the world"""
    return "Hello, world!"
    msg.frm -> "[email protected]/Nick Groenen"
    msg.type_ -> "groupchat"

    View Slide

  31. @botcmd
    def hello(self, msg, args):
    """Say hello to the world"""
    return "Hello, world!"
    msg.frm -> "[email protected]/Nick Groenen"
    msg.type_ -> "groupchat"
    msg.body -> "!hello"

    View Slide

  32. @botcmd
    def hello(self, msg, args):
    """Say hello to the world"""
    return "Hello, world!"
    msg.frm -> "[email protected]/Nick Groenen"
    msg.type_ -> "groupchat"
    msg.body -> "!hello"
    msg.html -> None

    View Slide

  33. @botcmd
    def hello(self, msg, args):
    """Say hello to the world"""
    return "Hello, world!"
    msg.frm -> "[email protected]/Nick Groenen"
    msg.type_ -> "groupchat"
    msg.body -> "!hello"
    msg.html -> None
    msg.to -> "[email protected]/Err Bot"

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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"]

    View Slide

  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"

    View Slide

  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"

    View Slide

  40. Templates
    hello.html:
    {% extends "base.html" %}
    {% block body %}
    Hello, {{name}}!
    {% endblock %}

    View Slide

  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}

    View Slide

  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}

    View Slide

  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"

    View Slide

  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"

    View Slide

  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

    View Slide

  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"

    View Slide

  47. View Slide

  48. Extensive configuration
    # Allow everyone access by default
    ACCESS_CONTROLS_DEFAULT = {}
    ACCESS_CONTROLS = {
    'status':
    {'allowrooms': ('[email protected],)},
    'about':
    {'denyusers': ('[email protected],),
    'uptime':
    {'allowusers': BOT_ADMINS},
    }

    View Slide

  49. Extensive configuration
    DIVERT_TO_PRIVATE = ('help', 'about', 'status')

    View Slide

  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()

    View Slide

  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())

    View Slide

  52. http://errbot.net/user_guide/plugin_development/

    View Slide

  53. Questions?

    View Slide