Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

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. 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.
  2. Err is a GPL3-licensed chat bot for Jabber XMPP and

    IRC networks, designed to be easily deployable, extendable and maintainable.
  3. 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!"
  4. 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!"
  5. 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!"
  6. 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!"
  7. 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!"
  8. 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!"
  9. 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!"
  10. 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!"
  11. @botcmd def hello(self, msg, args): """Say hello to the world"""

    return "Hello, world!" msg.frm -> "[email protected]/Nick Groenen" msg.type_ -> "groupchat"
  12. @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"
  13. @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
  14. @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"
  15. @botcmd def hello(self, msg, args): """Say hello to the world"""

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

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

    return "Hello, world!" !hello Err Bot -> args = ["Err", "Bot"]
  18. 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"
  19. 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"
  20. Templates hello.html: {% extends "base.html" %} {% block body %}

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

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

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

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

    @webhook def example(self, incoming_request): logging.debug(repr(incoming_request)) return "OK"
  25. 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
  26. 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"
  27. Extensive configuration # Allow everyone access by default ACCESS_CONTROLS_DEFAULT =

    {} ACCESS_CONTROLS = { 'status': {'allowrooms': ('[email protected],)}, 'about': {'denyusers': ('[email protected],), 'uptime': {'allowusers': BOT_ADMINS}, }
  28. 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()
  29. 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())