Slide 1

Slide 1 text

{:clova, "~> 0.2.2"} fukuoka.ex#13ɿՆͷfukuoka.exࡇ ϛϥʔνοϓ ΞμϜ • Adam Millerchip LINE KYOTO ։ൃࣨ 2018-08-24

Slide 2

Slide 2 text

Clova

Slide 3

Slide 3 text

ClovaͷεΩϧ

Slide 4

Slide 4 text

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 } }

Slide 5

Slide 5 text

Package
 https://hex.pm/packages/clova Docs
 https://hexdocs.pm/clova Code
 https://github.com/line/clova-cek-sdk-elixir

Slide 6

Slide 6 text

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!

Slide 7

Slide 7 text

Set up HTTP Endpoint lib/knock/router.ex

Slide 8

Slide 8 text

Implement Handler lib/knock.ex

Slide 9

Slide 9 text

Add Callbacks ୭Ͱ͔͢ʁ ϊοΫϊοΫΛىಈͯ͠

Slide 10

Slide 10 text

όʔϏʔ୭ʁ A: ϊοΫϊοΫ B: ୭Ͱ͔͢ʁ A: όʔϏʔ B: όʔϏʔ୭ʁ A: όʔϏʔΩϡʔʂ

Slide 11

Slide 11 text

Stateful Requests A: ϊοΫϊοΫ B: ୭Ͱ͔͢ʁ A: όʔϏʔ B: όʔϏʔ୭ʁ A: όʔϏʔΩϡʔʂ

Slide 12

Slide 12 text

Stateful Requests A: ϊοΫϊοΫ B: ୭Ͱ͔͢ʁ A: όʔϏʔ B: όʔϏʔ୭ʁ A: όʔϏʔΩϡʔʂ

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

ύοέʔδͷ࣮૷Ͱ೰Μͩͱ͜Ζ • ॳΊͯͷ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

Slide 15

Slide 15 text

εΩϧͷͨΊʹඞཁͳରԠ • HTTPͷΤϯυϙΠϯτΛఏڙ • HTTPͷϦΫΤετΛύʔζ͢Δ • ॺ໊Λݕূ͢Δ • JSONΛύʔζ͢Δ • ΫϩʔόͷϦΫΤετΛಡΉ • ΫϩʔόͷϨεϙϯεΛ࡞Δ • JSONʹΤϯίʔυ͢Δ • HTTPͷϨεϙϯεΛฦ͢ Plug / Cowboy Plug / Cowboy ExCrypto Poison Clova Clova Poison Plug / Cowboy

Slide 16

Slide 16 text

ύοέʔδͷ࣮૷Ͱ೰Μͩͱ͜Ζ

Slide 17

Slide 17 text

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 ύοέʔδͷ࣮૷Ͱ೰Μͩͱ͜Ζ

Slide 18

Slide 18 text

ॺ໊Λݕূ͢Δ • Plug.Parsers.JSONΛͦͷ··࢖͍͍ͨ • Headerʹ͋Δॺ໊Λݕূ͍ͨ͠ • ݕূ͢ΔͨΊʹHTTPϦΫΤετͷϘσΟ͕ඞཁ • ͚ͲɺJSONͷParser͕Plug.Conn.read_body/2ΛݺΜͰ͍Δ • Plug.Conn.read_body/2͸Ұճ͔͠࢖͑ͳ͍ • ࣗ෼ͷParserΛ࡞ͬͯɺread_bodyͷ݁ՌΛݕূͷͨΊʹconnʹอଘ͓ͯ͘͠

Slide 19

Slide 19 text

ParserErrorΛൃੜͤ͞Δ

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Can’t load private key https://github.com/ntrepid8/ex_crypto/issues/27

Slide 23

Slide 23 text

defstruct

Slide 24

Slide 24 text

Everything Can Change • https://github.com/line/clova-cek-sdk-elixir • ·ͩ0.2.2 • PRΛ଴͓ͪͯ͠Γ·͢ʂ

Slide 25

Slide 25 text

https://www.line-community.me/awards/ https://linedev.connpass.com/ આ໌ձ
 ϋϯζΦϯ
 ϋοΧιϯ
 ΋͘΋͘ձ ϗʔϜϖʔδ

Slide 26

Slide 26 text

Clova Friends Mini 2୆