Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Chat Bot Architecture

4,101 views

Published on

GeekOut 2016; Tallinn, Estonia; 9 June 2016. Video is here: https://www.youtube.com/watch?v=7yTIWFZrXpg

Published in: Software
  • Be the first to comment

Chat Bot Architecture

  1. 1. /17@yegor256 1 Chat Bot
 Architecture Yegor Bugayenko
  2. 2. /17@yegor256 2 www.rultor.com
  3. 3. /17@yegor256 3 #45 @rultor deploy @yegor256 will try @yegor256 done @yegor256
  4. 4. /17@yegor256 4 1. No schema 2. No mess 3. No DB server
  5. 5. /17@yegor256 5 talks name xml yegor256/takes#123 <talk> <server> ... </server> <daemon> ... </daemon> </talk>
  6. 6. /17@yegor256 6 active = // from github notifications for (Talk talk : active) { talk.modify( patch.apply( talk.read() ) ); }
  7. 7. /17@yegor256 7 interface Patch { Directives apply(XML talk); } xembly
  8. 8. /17@yegor256 8 XPATH “/garage”; ADD “car”; ADD “name”; SET “Toyota”; UP; ADD ”price”; SET “$15,000”; <garage/> <garage> <car> <name>Toyota</name> <price>$15,000</price> </car> </garage> xembly.org
  9. 9. /17@yegor256 9 Patch XML1 XML2 ?
  10. 10. /17@yegor256 10 new Patch.Iterative( new Understood(), new RequestBuilt(), new DaemonStarted(), new DaemonEnded() ); over 20
  11. 11. /17@yegor256 11 class Understood implements Patch { @Override public Directives apply(XML xml) { // read github and understand request return new Directives() .xpath(“/talk”) .add(“request”) .add(“type”) .set(“deploy”); // here! } }
  12. 12. /17@yegor256 12 <talk> </talk> <talk> <request> <type>deploy</type> </request> </talk> Understood
  13. 13. /17@yegor256 13 class RequestBuilt implements Agent { @Override public Directives apply(XML xml) { String type = xml.xpath( “/talk/request/type/text()” ).get(0); return new Directives() .xpath(“/talk/request”) .add(“script”) .set(“mkdir tmp; chmod ...”); } }
  14. 14. /17@yegor256 14 <talk> <request> <type>deploy</type> <script> mkdir tmp; cd tmp; ... </script> </request> </talk> RequestBuilt <talk> <request> <type>deploy</type> </request> </talk>
  15. 15. /17@yegor256 15 new Patch.Iterative( new Understood(), new Patch.If( new RequestBuilt(), “/talk/request/type” ), new Patch.If( new DaemonStarted(), “/talk/request/script” ), new DaemonEnded() );
  16. 16. /17@yegor256 16 1. Easy to extend 2. Still strict (XSD) 3. Small objects (patches) 4. Easy to test/reproduce 5. High visibility
  17. 17. /17@yegor256 17 www.yegor256.com make sense?

×