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

{:clova, "~> 0.2.2"}

{:clova, "~> 0.2.2"}

Introduction of the Clova library for developing skills for Line's Clova AI Assistant, and a discussion of issues and concerns I had implementing a library as my first Elixir project.

Adam Millerchip

August 24, 2018
Tweet

More Decks by Adam Millerchip

Other Decks in Technology

Transcript

  1. JSON webhook "version": "1.0", "session": { "new": false, "sessionAttributes": {},

    "sessionId": "a29cfead-c5ba-474d-8745-6c1a6625f0c5", "user": { "userId": "U399a1e08a8d474521fc4bbd8c7b4148f", "accessToken": "XHapQasdfsdfFsdfasdflQQ7" } }, "context": { "System": { "application": { "applicationId": “com.example.pizzabot" }, "user": { "userId": "U399a1e08a8d474521fc4bbd8c7b4148f", "accessToken": "XHapQasdfsdfFsdfasdflQQ7" }, "device": { "deviceId": "096e6b27-1717-33e9-b0a7-510a48658a9b", "display": { "size": "l100", "orientation": "landscape", "dpi": 96, "contentLayer": { "width": 640, "height": 360 } } } } }, "request": { "type": "IntentRequest", "intent": { "name": "OrderPizza", "slots": { "pizzaType": { "name": "pizzaType", "value": "ϖύϩχ" { "version": "1.0", "sessionAttributes": {}, "response": { "outputSpeech": { "type": "SpeechList", "values": [ { "type": "PlainText", "lang": "ja", "value": "ՎΛՎͬͯΈ·͢ɻ" }, { "type": "URL", "lang": "" , "value": “https://example.com/song.mp3” } ] }, "card": {}, "directives": [], "shouldEndSession": true } }
  2. Anatomy of a Knock Knock Joke A: Knock Knock! B:

    Who’s there? A: anything B: anything who? A: μδϟϨ A: Knock Knock! B: Who’s there? A: Tank B: Tank who? A: You’re welcome!
  3. ύοέʔδͷ࣮૷Ͱ೰Μͩͱ͜Ζ • ॳΊͯͷElixir • ApplicationΛ࡞Δͷ͸ඞཁʁ • See what others did:

    https://github.com/col/alexa def application do [applications: [:logger, :alexa]] end worker(MyAwesomeSkill, [[app_id: Application.get_env(:my_awesome_skill, :alexa_app_id)]]) response = Alexa.handle_request(request) mix.exs README.md lib/alexa/application.ex
  4. εΩϧͷͨΊʹඞཁͳରԠ • HTTPͷΤϯυϙΠϯτΛఏڙ • HTTPͷϦΫΤετΛύʔζ͢Δ • ॺ໊Λݕূ͢Δ • JSONΛύʔζ͢Δ •

    ΫϩʔόͷϦΫΤετΛಡΉ • ΫϩʔόͷϨεϙϯεΛ࡞Δ • JSONʹΤϯίʔυ͢Δ • HTTPͷϨεϙϯεΛฦ͢ Plug / Cowboy Plug / Cowboy ExCrypto Poison Clova Clova Poison Plug / Cowboy
  5. Good points • Simple. Easy to Understand. • Signature Validation

    + JSON Parsing is handled automatically • Dispatcher: More declarative than calling manually inside endpoint Bad points • Forces all requests through pipeline so cannot serve any non-clova requests. • Can only validate one app_id • Can only dispatch to one callback module ύοέʔδͷ࣮૷Ͱ೰Μͩͱ͜Ζ