Chat Bot Architecture

1,348 views

Published on

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

Published in: Software
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,348
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
12
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

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?

×