際際滷

際際滷Share a Scribd company logo
Clova Extension AtoZ
Clova Platform Evangelist
レ
2018-04-27
覦襭: /ClovaPlatform/
覈谿
 Clova Platform 螳
 Clova extension 螳覦 譴觜 螳
 Clova extension 焔  語覈, 覯覲, 覦壱覲
 誤磯覈 焔
 Clova extension 覯 API 螳覦
 Clova 炎骸 ろ殊擦 旧ろ 語 ろ
Clova Plaform & extension 螳
Clova Platform Overview
Clova Interface Connect
Clova Interface Connect  襦
LG U+ 觚襭貊 ろ殊擦 LG  る語渚
LG 螳蠍郁鍵 願IoT  願
LG U+ IPTV STB
- LG U+ IPTV UHD蠍 伎 STB  Clova 螻 (2017 12 )
豌 譴,
襴覈貊 side焔
or () LGUれ
襦 焔 
襴る朱 伎 るΥ 豢豌伎覃 蟆>
豌危覃企, 企覦る 蟆朱 
Clova Interface Connect  襦
Clova Interface Connect  襦 (Friends +)
ろ殊擦襦 ' 貉碁,'   給.
觚殊願骸 襴蟆 "磯"朱 語企 讌企慨語.
"磯, 覓  觜朱  谿場譴"
"磯, tvN 伎"
Clova Extensions Kit
Clova extension 企?
 Clova 弰  3rd party 襴貅伎朱, 襯 る 焔轟朱  
蟇磯 狩, IoT蠍郁鍵  煙 螳ロ.
  (: 焔) 磯 extension伎蟆   襦 Clova  企
朱 煙語, 覿  Clova 瑚概讌 蠍一  給.
extension朱 覓伎   ?
 Extension 譬襯
 (觜れ) Custom extension: 3rd party 覯 螻牛 (: ,
企語 ) 螻牛  給.
 ) "觜旧 伎り概 伎" 手 覃 "觜 extension" 企  
れ.
 () Chatbot extension: 螻螳 譯 覓視 讌覓(FAQ)螻 給 焔
  豈覺 給 蟆  extension.
 ) れ企螻螳狩 ろ伎  れ企 狩 螳蟆 觜蟲 覦覯
れ?
 (企語) Clova Home extension: IoT 蠍郁鍵願 螳
 ) "企覦, TV 譬 貅譴" 手 覃 企覦螳 TV襯 貅
Clova Extension 
 https://blog.naver.com/clova_ai/221199482419
Clova extension 襦  豌企Μ 覈覯
https://www.youtube.com/watch?v=kpkRRLWHySc
覦: 1) 豌企Μ蟆  2) 豌企Μ蟆 覓伎 覈 伎 3) 豌企Μ蟆 豌覯讌 覃覈襴 伎
Clova extension 襦  覦一′伎癌 覦一^
https://www.youtube.com/watch?v=27NWVG0yhTQ
覦: 1) 覦一′る 伎 2) 覦一′る語  覦 譟壱伎 3) 覦一′る  覦 語
Clova extension 襦  朱襷 一
https://www.youtube.com/watch?v=uCqQem8_LyQ
覦: 1) 朱襷 伎 2) 朱襷蟆 一 覓殊企譴 3) 朱襷蟆 豺 語蠍語 覓殊企譴
Clova 豈覺 extension 襦  覃覃癌 覓殊襴 覯蠍
https://www.facebook.com/ClovaAI/photos/a.1639371196371443.1073741828.1637903373184892/1783396565302238/
覦: 1) 覃覃 伎
Clova extension
襷覯 蟲(Magic ball)
 螳
 襷覯 蟲  覓殊 覩碁Μ 企 20螳讌 蠍 
 覿  譴 襯 旧朱 れ朱 extension.
 ろ 覦覯
 襷覯蟲 伎  覓願碓 , 襷  蠍壱覃 
 襷覯蟲蟆 襦 轟襖讌 覓殊企譴
https://developers.naver.com/console/clova/guide/CEK/Examples/Extension_Examples.md#MagicBall
襷覯 蟲(Magic ball)
 誤磯 覈
  覦 蟯螻 旧 伎 企れ手鍵 覓語 interaction 覈語 螳.
襷覯 蟲(Magic ball)
 API れ
 https://github.com/naver/clova-extension-sample-magicball
 旧ろ 
 https://github.com/naver/clova-extension-sample-magicball/blob/github-public/intent/answer.go
觜襴(Rain sound)
 螳
 觜襴  豌 覩碁Μ 轟企 觜襴  (.mp3)襯 企殊
誤瑚 襦 牛 extension.
  觜襴襯 覈 覯 覦覲牛伎 れ讌 蟆一  朱,  extension
interaction 覈語 覦覲   螳 slot朱 螻 給.
 企殊伎誤瑚    襦  覃讌  覓瑚規 訖襷 
 AudioPlayer.Play 讌 覃讌襯 貅 CEK襦 覲企伎.
 ろ 覦覯
 觜襴 伎
 觜襴 伎伎
 觜襴 2覯 覦覲牛企手 伎
https://developers.naver.com/console/clova/guide/CEK/Examples/Extension_Examples.md#RainSound
觜襴(Rain sound)
 誤磯 覈
  觜襴襯 覈 覯 覦覲牛伎 れ讌 蟆一  朱,  extension interaction 覈語 覦覲   螳 slot朱 
螻 給.
觜襴(Rain sound)
 誤磯 覈
觜襴(Rain sound)
 API れ
 https://github.com/naver/clova-extension-sample-rainsound
 旧ろ 
 https://github.com/naver/clova-extension-sample-rainsound/blob/github-public/clova/index.js
譯殊 (Dice drawer)
 螳
 譯殊 企  豌 螳 譯殊襯 蟲企  譯殊 螻 
 螻襯 れ朱 extension.
 蟲企Υ 譯殊 螳螳 語  螳 伎 語 磯 旧朱 れ朱 
 殊.
 ろ 覦覯
 譯殊  伎
 譯殊 伎 譯殊 2螳 語
 譯殊 伎蟆 5螳 蟲企る手 
https://developers.naver.com/console/clova/guide/CEK/Examples/Extension_Examples.md#DiceDrawer
譯殊 (Dice drawer)
 誤磯 覈
  譯殊襯 覈 螳 讌 讌 蟆一  朱,  extension interaction 覈語 譯殊 螳  螳 slot朱 螻 
給.
譯殊 (Dice drawer)
 誤磯 覈
譯殊 (Dice drawer)
 API れ
 https://github.com/naver/clova-extension-sample-dice
 旧ろ 
 https://github.com/naver/clova-extension-sample-rainsound/blob/github-public/clova/index.js
貊 (Coin helper)
 螳
 貊 朱  豌 碁 螳  蟇磯 螻牛 RESTAPI
襯 語  覲企ゼ れ朱 extension.
 ろ 覦覯
 貊誤 伎
 貊誤殊  れ
 貊誤殊 觜語  覓殊企譴
https://developers.naver.com/console/clova/guide/CEK/Examples/Extension_Examples.md#CoinHelper
貊 (Coin helper)
 誤磯 覈
  企 蟇磯 覲企ゼ 伎讌 企 螳 碁ゼ 譟壱讌 蟆一  朱,  extension interaction 覈語 蟇
 螳  譬覈  螳 slot朱 螻 給.
貊 (Coin helper)
 API れ
 https://github.com/naver/clova-extension-sample-coinhelper
 旧ろ 
 https://github.com/naver/clova-extension-sample-coinhelper/blob/github-public/intent/ask.go
Clova extension 螳覦 譴觜 螳
Clova extension 螳覦 譴觜  1 ()
 旧ろ覯
 REST API 覯襦, Clova platform Clova console 焔 REST API 覯URL襦 糾骸 豌 譯
螻 覦給.
 Clova platform 1) 旧ろ ろ 2) 誤 ろ 3) 旧ろ 譬襭朱 3螳讌 type 豌 覲企願,
旧ろ 覯 蠍一 襷蟆 旧 覃 .
 旧ろ 覯 https襦 碁襷朱 旧   覯伎伎 覃, 碁 80  443襦襷 旧
.
Clova extension 螳覦 譴觜  1 ()
 旧ろ覯
Clova extension 螳覦 譴觜  2 ()
 誤磯 覈
 殊 襴れ 觜訣る, 蠍郁 旧ろ 覯螳  襯 危危   
襦 Clova console ロ 覓語 覦 覃覲企れ.
 誤磯 覈語 襦覿 ル 襷 覓語ルり骸 螳 覓語レ 企 ろ 覈(企ゼ '誤'手
.)朱 郁屋 讌襯 れ.
 誤碁ゼ ろ   覲企れ '襦'企朱 蟆朱  豌襴.
 襯 る, 殊譯朱誤 旧ろ 蟆曙 誤語 襦  螳給.
 )  : "朱 殊 2 譯朱誤伎" --> 'OrderPizza'朱 企朱 殊譯朱 豌襴 誤碁 

 ) 'OrderPizza'誤瑚 れ 殊襯 譯朱誤蠍   覲企 '殊覈'螻 ''企, 企 螳蠍
'pizzaType', 'pizzaAmount'朱 襦朱
Clova extension 螳覦 譴觜  3 ()
 OAuth 語 覯
 襷 旧ろ  螻
語 る 旧ろ 覯
 蟷 OAuth 語 蟲
.
 OAuth 語 覯 Clova console
 焔 語覲企ゼ 伎
語 豌襴螻, 語 襭
覃 蠏狩一 覦伎 .
 語覯 蟲豢 ) 覦磯 覩殊 ̄,
LG , LGU +
蟯 螳企: /ClovaPlatform/clova-tech-summit-3-clova-extension-oauth-89597569
Clova extension 焔
旧ろ 蠍磯蓋 覲 焔蠍
 Clova console 伎 'Clova Extensions Kit' 企Ν れ '襦 旧ろ 襷り鍵'襯 襴.
 URL: https://developers.naver.com/console/clova/
 旧ろ 覲 れ
 type Custom Extension朱 螻, 襾語 螳る ロ.
 るろ伎  覿 ''襦 . ''襦  蟆曙磯   蟆曙一 .
Clova extension 語覈 れ
 螳蠍郁鍵襯 危 Custom extension (危 '旧ろ') 觜るゼ 蠏碁 覲企襦
蟆給.
 襾殊 旧ろ ろ  覿襯企 企, 讀 '語覈' 伎狩, 覈 螳讌 
曙 給.
 朱 覈  (: 覦 (X) )
 觚  覈螳 覈  螳: (: 讌炎規覦(O))
 轟 煙語   蟆曙磯 るジ 語覈朱    朱, Clova煙 
  讌 誤企慨蠍 覦.
覯 磯 れ
 碁 蠏手ロ RESTAPI 覯 endpoint URL ロ. 螻郁屋 覿 ''襦 °.
覦壱覲 れ
 蠍一 ろ語 讌伎   覓語レ 蟾  襴れ  覓語レ 語覈
覿 螳 ろ誤   覓語レ ロ.
 讌炎規覦襯 伎
 讌炎規覦 蟇一  貅譴
 讌炎規覦 蟇一  蟶殊
誤磯 覈 焔
旧ろ  襴
 豌覯讌碁 旧ろ蟆 覦襦 讌覓誤螻 旧 覦 蟆. (炎, single-turn)
 : 企覦, 讌炎規覦 蟇一  貅譴
 旧ろ: 蟇一 煙 貅譟給.
 覯讌碁 旧ろ ろ れ 讌覓誤螻 旧 覦 蟆. (覃壱,
multi-turn)
 : 企覦, 讌炎規覦襯 伎
 旧ろ: 語. 讌炎規覦螳 給. 危螻 苦 螳蠍郁鍵  覦覯
 襷語.
 : 蟇一  貅譴.
 旧ろ: 蟇一 煙 貅譟給.
旧ろ  襴 螻れ
 伎 伎狩 殊 襴り 企覦 弰 襦  蟆碁一.
 覓語 螳 螳 襷 覓殊企慨朱,   蠍蠏碁襦 襷讌
る .
 ) 蟇一  貅譴
 ) 蟇一  伎
 ) 蟇一 覿貅譴
 企蟆 螳 伎襷 れ  ロ螻 誤磯 覈語 企 
覓語 貅伎るれ  襴企   旧ろ 襷  蟆給.
誤磯 覈 焔蠍  襦 焔
 讌炎規覦 讌 讌 IoT蠍郁鍵襯 
 蟆企襦 誤碁 襷 焔覃 
螻, 襦 讌 れ レれ' 
蟆給.
 襦 焔蠍 
 襦 貉れろ 襦螻 觜語 襦 2螳
讌螳 給.
 觜語 襦  螳 れ 企
語 企れ 覈 蟆朱, 
蟆り 豌危覃 ク襴蟆   
給.
 讌 れ レれ 貉れろ 襦
朱 焔.
 IOT_TYPE
 蟇一: 襴觜襭
 覦: 豺
 覿: れ
 覯
誤磯 覈 焔蠍  襦 焔
 襦 焔覃  螳 .
誤磯 覈 焔蠍  誤 焔
 一検 '譴 Intent'  + 覯殊  turnOnIntentロ螻 '襷り鍵' 覯殊 襴.
   襴ろ語 れ ロ 蟆 螳 れ ロ, slot螻  企麹
覓語ルれ れ蟆 ロ.
 覓語レ 螳讌 襷 襦     .
 蟇一  貅譴
 覦 覿 貅譴
 豺  伎
https://developers.naver.com/console/clova/guide/Design/Des
ign_Guideline_For_Extension.md#DefineInteractionModel
誤磯 覈 焔蠍  誤 襦 焔
   襴ろ語 蟇一'企朱 企ゼ 蠏誤 れ  ロ homeSlotType企 企朱
襷ろ伎.
 襷ろ 襭覃 Slot  企麹 蠍れ  螳 企殊危 .
誤磯 覈 觜蠍
 モ 覯殊 襯 れ
 一検  '觜' 覯殊  誤磯 覈語 觜. 觜螳 襭覃 れ '觜'朱 覯殊朱 覦.
誤磯 覈 ろ
 讌 REST API 覯 螳覦伎襷, 焔 誤磯 覈語  讌 
誤.
 '觜' 覯  'ろ'襯 襴.
誤磯 覈 ろ
 豌危 誤碁 誤磯 覈語 焔 覓語リ骸 觜訣 覓語レ ロ朱 slot螻 intent螳 襴危讌 誤
蟆.
 )
 蟇一  貅譴 (誤磯 覈語  覓語)
 覿  伎 (誤磯 覈語  覓語リ骸 觜訣 伎襷, slot  るジ 覓語)
 豺 覿 貅譴 (觜訣 覓語)
Clova extension 覯 API 螳覦
螳覦 蟆 蟲
 螳覦 蟲
 IntelliJ ( with Java )
 襦 
 Spring Initializr襦 襦 
 襦 れ
 pom api test (rest-assured)  dependency れ
螳覦蟆 誤  Spring Initailzr襦 襦
螳覦蟆 誤  group 覈 れ
螳覦蟆 誤  Web貉危
螳覦蟆 誤  襦 企 れ
rest-assured 蟯 pom.xml れ 豢螳
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.0.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>xml-path</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>3.0.5</version>
<scope>test</scope>
</dependency>
Application - Run
ろ  
 http://localhost:8080/
* 譯殊:
Clova 覯 碁 80  443襷 螳
application.properties   伎 豢螳
server.port=80
譯 螳 Rest API  - Controller
 貊
 ろ 蟆郁骸
@RestController
@RequestMapping("/clova")
public class DemoApiController {
@ResponseBody
@RequestMapping(value = "/v1/hello", method= RequestMethod.GET, produces = "application/json" )
public String hello() {
return "hello clova api!";
}
}
http://localhost:8080/clova/v1/hello
豌 RestAssured ろ 貅伎 
 src-test-java 覦 HelloWorldRestAssured class 豢螳  螳 覃 
 譯殊 API る
 given()
 リ れ (朱誤, る  )
 when()
 get(path) : 讌 path襦 get 豌
 post(path) : 讌 path襦 post 豌
  焔
 then()
 語 蟆郁骸 蟆讀 ( statusCode(), body(), equals() 焔奄)
@Test
public void naverShouldBeOK() {
given().when().get("/v1/hello").then().statusCode(200);
}
覯螳 豌襴伎狩  - 1
 Clova 豌 覃讌 request type 磯 讌 襷血  襴
 Request type
 LaunchRequest : 旧ろ  (讌炎規覦 伎  蟆曙)
 SessionEndedRequest : 旧ろ 譬襭 (譬襭伎 )
 IntentRequest
 Custom Intent  螳覦 貊 ロ Intent  Slot
 Built-in Intent 
https://developers.naver.com/console/clova/guide/CEK/References/CEK_API.md#cek-api-朱一
覯螳 豌襴伎狩   2
https://developers.naver.com/console/clova/guide/CE
K/References/CEK_API.md#cek-api-朱一
給讌 蟲譟
覯螳 豌襴伎狩   3
 覃壱 豌襴
  覃讌 shouldEndSession false
 螻 讌伎  螳 sessionAttribute 伎 
http://stg.developers.naver.com/console/clova/guide/CEK/Guide
s/Build_Custom_Extension.md#DoMultiturnDialog
貉碁, api
@RequestMapping(value = "/extension", method= RequestMethod.POST, produces = "application/json" )
@ResponseBody
public ResponseEntity<MyExtensionMessage> weather (@RequestBody Map<String, Object> map) {
Map m = (HashMap)map.get("request");
String type = (String) m.get("type");
MyExtensionMessage mm = null;
if(type.equals("LaunchRequest")) { // extension 
mm = new MyExtensionMessage("turnOnIntent", " 讌炎規 覦襯 . 危る 煙 襷 語. ", false, "PlainText");
} else if (type.equals("IntentRequest")) { // extension 誤 
Map intent = (HashMap) m.get("intent");
String intentName = (String) intent.get("name");
Map slots = (HashMap) intent.get("slots");
String slotName = "";
String slotValue = "";
if (intentName.equals("turnOnIntent")) {
if (slots != null) {
Map myslot = (HashMap) slots.get("homeSlotType");
slotName = (String) myslot.get("name");
slotValue = (String) myslot.get("value");
System.out.println("slotName===" + slotName);
System.out.println("slotValue===" + slotValue);
}
mm= new MyExtensionMessage("turnOnIntent", slotValue + " 煙 貅一給. ", true, "PlainText");
// Built-in Intent 豌襴
} else if (intentName.equals("Clova.YesIntent")) {
mm = new MyExtensionMessage(intentName, " 手 ?", true, "PlainText");
} else if (intentName.equals("Clova.NoIntent")) {
mm = new MyExtensionMessage(intentName, " 手 ?", true, "PlainText");
} else if (intentName.equals("Clova.GuideIntent")) {
mm = new MyExtensionMessage("hearTestIntent", "覿  企手 企慨語", false, "PlainText");
} else if (intentName.equals("Clova.CancelIntent")) {
mm = new MyExtensionMessage("hearTestIntent", "讌炎規 覦 ろ 豬. ", true, "PlainText");
}
} else if (type.equals("SessionEndedRequest")) { // extension 譬襭
mm = new MyExtensionMessage("turnOnIntent", "讌炎規 覦襯 譬襭. ", false, "PlainText");
}
return new ResponseEntity<MyExtensionMessage>(mm, HttpStatus.OK);
}
Extension message 蟲譟
http://developers.naver.com/console/clova/guide/#/C
EK/References/CEK_API.md#message-structure-2
Extension  message 豌襴 企
public class MyExtensionMessage {
public String version = "1.0";
public Map<String, Object> sessionAttributes = new HashMap();
public MyResponse response = null;
public MyExtensionMessage(String INTENT_NAME, boolean session, ArrayList<Map> myResponseValue) {
if(!session) {
sessionAttributes.put("intent", INTENT_NAME);
}
MyResponse response = new MyResponse();
response.shouldEndSession= session;
response.outputSpeech.put("type", "SpeechList");
response.outputSpeech.put("values", myResponseValue);
this.response = response;
}
public MyExtensionMessage(String INTENT_NAME, String message, boolean session, String type) {
// MyResponseValue 螳豌
Map<String, String> myResponseValue = new HashMap<String, String>();
myResponseValue.put("type", type);
myResponseValue.put("lang", "ko");
myResponseValue.put("value", message);
if(!session) {
sessionAttributes.put("intent", INTENT_NAME);
}
MyResponse response = new MyResponse();
response.shouldEndSession= session;
response.outputSpeech.put("type", "SimpleSpeech");
response.outputSpeech.put("values", myResponseValue);
this.response = response;
}
public static class MyResponse {
public Map<String, Object> outputSpeech = new HashMap<String, Object>();
public Map<String, Map> card = new HashMap<String, Map>();
public ArrayList<String> directives = new ArrayList<String>();
public boolean shouldEndSession = false;
}
}
Api test
private final String LaunchRequest = "LaunchRequest";
private final String IntentRequest = "IntentRequest";
private final String SessionEndedRequest = "SessionEndedRequest";
private final String INTENT_NAME = "turnOnIntent";
private final String SLOT_NAME = "homeSlotType";
@Test
public void extensionShouldReturnLaunchRequest() {
given()
.header("Content-Type", "application/json")
.body(getClovaJson(LaunchRequest, INTENT_NAME, SLOT_NAME))
.when().post("/clova/extension")
.then().body("response.outputSpeech.values.value",containsString(""));
}
@Test
public void extensionShouldReturnIntentRequest() {
given()
.header("Content-Type", "application/json")
.body(getClovaJson(IntentRequest, INTENT_NAME, SLOT_NAME))
.when().post("/clova/extension")
.then().body("response.outputSpeech.values.value",containsString(""));
}
@Test
public void extensionShouldReturnEndRequest() {
given()
.header("Content-Type", "application/json")
.body(getClovaJson(SessionEndedRequest, INTENT_NAME, SLOT_NAME))
.when().post("/clova/extension")
.then().body("response.outputSpeech.values.value",containsString("譬襭"));
}
Api test
private String getClovaJson(String type, String intentName, String slotName) {
String jsonReq = "{n" +
" "version": "0.1.0",n" +
" "session": {n" +
" "sessionId": "ff5db3a3-0f67-4b24-830f-cfa785556a71",n" +
" "user": {n" +
" "userId": "azvjPlQkSCuV8LmItY2VrQ",n" +
" "accessToken": "66e7e019-cda9-4826-acdd-b1671b551e97"n" +
" },n" +
" "new": truen" +
" },n" +
" "context": {n" +
" "System": {n" +
" "user": {n" +
" "userId": "azvjPlQkSCuV8LmItY2VrQ",n" +
" "accessToken": "66e7e019-cda9-4826-acdd-b1671b551e97"n" +
" },n" +
" "device": {n" +
" "deviceId": "4a0307d4-0674-4cdb-890e-be29f049339d"n" +
" }n" +
" }n" +
" },n" +
" "request": {n" +
" "type": ""+ type +"",n" +
" "intent": {n" +
" "name": ""+ intentName +"",n"+
" "slots": {n" +
" ""+ slotName +"": {n" +
" "name": ""+ slotName +"",n" +
" "value": 蟇一"n"+
" }n" +
" }n" +
" }n" +
" }n" +
"}";
return jsonReq;
}
Clova 炎骸 ろ殊擦 旧ろ 語 ろ
ろ 螻
 螳覦 貊 test れ企 螻 焔
  ろ 覦覯1  Clova 
 Clova 煙 企 企襦 襦蠏語 
  讌炎規覦 伎 手   旧ろ 覯襦 LaunchRequest螳 る讌, 旧ろ 旧 煙朱 螳讌 
  ろ 覦覯2  Friends ろ殊擦
 ろ磯 焔 企襦 Clova煙 伎伎 ろ殊擦 れ
  讌炎規覦 伎 手   旧ろ 覯襦 LaunchRequest螳 る讌, 旧ろ 旧 煙朱 螳讌
Appendix.
 Clova  螳覦 覓語 : https://developers.naver.com/console/clova/guide/
 Design 豈 / Clova Extensions Kit 豈 / Clova Developer Console 豈 谿瑚
 襴 覦  貊 谿瑚
  貊 Github
 襷覯 蟲 : https://github.com/naver/clova-extension-sample-magicball
 觜襴 : https://github.com/naver/clova-extension-sample-rainsound
 譯殊  : https://github.com/naver/clova-extension-sample-dice
 貊  : https://github.com/naver/clova-extension-sample-coinhelper
Thank you.
蟲″朱覦: http://bit.ly/clova-dev-days
企語: dl_clova_partnership@navercorp.com

More Related Content

Clova extension A to Z

  • 1. Clova Extension AtoZ Clova Platform Evangelist レ 2018-04-27 覦襭: /ClovaPlatform/
  • 2. 覈谿 Clova Platform 螳 Clova extension 螳覦 譴觜 螳 Clova extension 焔 語覈, 覯覲, 覦壱覲 誤磯覈 焔 Clova extension 覯 API 螳覦 Clova 炎骸 ろ殊擦 旧ろ 語 ろ
  • 3. Clova Plaform & extension 螳
  • 6. Clova Interface Connect 襦 LG U+ 觚襭貊 ろ殊擦 LG る語渚 LG 螳蠍郁鍵 願IoT 願
  • 7. LG U+ IPTV STB - LG U+ IPTV UHD蠍 伎 STB Clova 螻 (2017 12 ) 豌 譴, 襴覈貊 side焔 or () LGUれ 襦 焔 襴る朱 伎 るΥ 豢豌伎覃 蟆> 豌危覃企, 企覦る 蟆朱 Clova Interface Connect 襦
  • 8. Clova Interface Connect 襦 (Friends +) ろ殊擦襦 ' 貉碁,' 給. 觚殊願骸 襴蟆 "磯"朱 語企 讌企慨語. "磯, 覓 觜朱 谿場譴" "磯, tvN 伎"
  • 10. Clova extension 企? Clova 弰 3rd party 襴貅伎朱, 襯 る 焔轟朱 蟇磯 狩, IoT蠍郁鍵 煙 螳ロ. (: 焔) 磯 extension伎蟆 襦 Clova 企 朱 煙語, 覿 Clova 瑚概讌 蠍一 給.
  • 11. extension朱 覓伎 ? Extension 譬襯 (觜れ) Custom extension: 3rd party 覯 螻牛 (: , 企語 ) 螻牛 給. ) "觜旧 伎り概 伎" 手 覃 "觜 extension" 企 れ. () Chatbot extension: 螻螳 譯 覓視 讌覓(FAQ)螻 給 焔 豈覺 給 蟆 extension. ) れ企螻螳狩 ろ伎 れ企 狩 螳蟆 觜蟲 覦覯 れ? (企語) Clova Home extension: IoT 蠍郁鍵願 螳 ) "企覦, TV 譬 貅譴" 手 覃 企覦螳 TV襯 貅
  • 12. Clova Extension https://blog.naver.com/clova_ai/221199482419
  • 13. Clova extension 襦 豌企Μ 覈覯 https://www.youtube.com/watch?v=kpkRRLWHySc 覦: 1) 豌企Μ蟆 2) 豌企Μ蟆 覓伎 覈 伎 3) 豌企Μ蟆 豌覯讌 覃覈襴 伎
  • 14. Clova extension 襦 覦一′伎癌 覦一^ https://www.youtube.com/watch?v=27NWVG0yhTQ 覦: 1) 覦一′る 伎 2) 覦一′る語 覦 譟壱伎 3) 覦一′る 覦 語
  • 15. Clova extension 襦 朱襷 一 https://www.youtube.com/watch?v=uCqQem8_LyQ 覦: 1) 朱襷 伎 2) 朱襷蟆 一 覓殊企譴 3) 朱襷蟆 豺 語蠍語 覓殊企譴
  • 16. Clova 豈覺 extension 襦 覃覃癌 覓殊襴 覯蠍 https://www.facebook.com/ClovaAI/photos/a.1639371196371443.1073741828.1637903373184892/1783396565302238/ 覦: 1) 覃覃 伎
  • 18. 襷覯 蟲(Magic ball) 螳 襷覯 蟲 覓殊 覩碁Μ 企 20螳讌 蠍 覿 譴 襯 旧朱 れ朱 extension. ろ 覦覯 襷覯蟲 伎 覓願碓 , 襷 蠍壱覃 襷覯蟲蟆 襦 轟襖讌 覓殊企譴 https://developers.naver.com/console/clova/guide/CEK/Examples/Extension_Examples.md#MagicBall
  • 19. 襷覯 蟲(Magic ball) 誤磯 覈 覦 蟯螻 旧 伎 企れ手鍵 覓語 interaction 覈語 螳.
  • 20. 襷覯 蟲(Magic ball) API れ https://github.com/naver/clova-extension-sample-magicball 旧ろ https://github.com/naver/clova-extension-sample-magicball/blob/github-public/intent/answer.go
  • 21. 觜襴(Rain sound) 螳 觜襴 豌 覩碁Μ 轟企 觜襴 (.mp3)襯 企殊 誤瑚 襦 牛 extension. 觜襴襯 覈 覯 覦覲牛伎 れ讌 蟆一 朱, extension interaction 覈語 覦覲 螳 slot朱 螻 給. 企殊伎誤瑚 襦 覃讌 覓瑚規 訖襷 AudioPlayer.Play 讌 覃讌襯 貅 CEK襦 覲企伎. ろ 覦覯 觜襴 伎 觜襴 伎伎 觜襴 2覯 覦覲牛企手 伎 https://developers.naver.com/console/clova/guide/CEK/Examples/Extension_Examples.md#RainSound
  • 22. 觜襴(Rain sound) 誤磯 覈 觜襴襯 覈 覯 覦覲牛伎 れ讌 蟆一 朱, extension interaction 覈語 覦覲 螳 slot朱 螻 給.
  • 24. 觜襴(Rain sound) API れ https://github.com/naver/clova-extension-sample-rainsound 旧ろ https://github.com/naver/clova-extension-sample-rainsound/blob/github-public/clova/index.js
  • 25. 譯殊 (Dice drawer) 螳 譯殊 企 豌 螳 譯殊襯 蟲企 譯殊 螻 螻襯 れ朱 extension. 蟲企Υ 譯殊 螳螳 語 螳 伎 語 磯 旧朱 れ朱 殊. ろ 覦覯 譯殊 伎 譯殊 伎 譯殊 2螳 語 譯殊 伎蟆 5螳 蟲企る手 https://developers.naver.com/console/clova/guide/CEK/Examples/Extension_Examples.md#DiceDrawer
  • 26. 譯殊 (Dice drawer) 誤磯 覈 譯殊襯 覈 螳 讌 讌 蟆一 朱, extension interaction 覈語 譯殊 螳 螳 slot朱 螻 給.
  • 27. 譯殊 (Dice drawer) 誤磯 覈
  • 28. 譯殊 (Dice drawer) API れ https://github.com/naver/clova-extension-sample-dice 旧ろ https://github.com/naver/clova-extension-sample-rainsound/blob/github-public/clova/index.js
  • 29. 貊 (Coin helper) 螳 貊 朱 豌 碁 螳 蟇磯 螻牛 RESTAPI 襯 語 覲企ゼ れ朱 extension. ろ 覦覯 貊誤 伎 貊誤殊 れ 貊誤殊 觜語 覓殊企譴 https://developers.naver.com/console/clova/guide/CEK/Examples/Extension_Examples.md#CoinHelper
  • 30. 貊 (Coin helper) 誤磯 覈 企 蟇磯 覲企ゼ 伎讌 企 螳 碁ゼ 譟壱讌 蟆一 朱, extension interaction 覈語 蟇 螳 譬覈 螳 slot朱 螻 給.
  • 31. 貊 (Coin helper) API れ https://github.com/naver/clova-extension-sample-coinhelper 旧ろ https://github.com/naver/clova-extension-sample-coinhelper/blob/github-public/intent/ask.go
  • 33. Clova extension 螳覦 譴觜 1 () 旧ろ覯 REST API 覯襦, Clova platform Clova console 焔 REST API 覯URL襦 糾骸 豌 譯 螻 覦給. Clova platform 1) 旧ろ ろ 2) 誤 ろ 3) 旧ろ 譬襭朱 3螳讌 type 豌 覲企願, 旧ろ 覯 蠍一 襷蟆 旧 覃 . 旧ろ 覯 https襦 碁襷朱 旧 覯伎伎 覃, 碁 80 443襦襷 旧 .
  • 34. Clova extension 螳覦 譴觜 1 () 旧ろ覯
  • 35. Clova extension 螳覦 譴觜 2 () 誤磯 覈 殊 襴れ 觜訣る, 蠍郁 旧ろ 覯螳 襯 危危 襦 Clova console ロ 覓語 覦 覃覲企れ. 誤磯 覈語 襦覿 ル 襷 覓語ルり骸 螳 覓語レ 企 ろ 覈(企ゼ '誤'手 .)朱 郁屋 讌襯 れ. 誤碁ゼ ろ 覲企れ '襦'企朱 蟆朱 豌襴. 襯 る, 殊譯朱誤 旧ろ 蟆曙 誤語 襦 螳給. ) : "朱 殊 2 譯朱誤伎" --> 'OrderPizza'朱 企朱 殊譯朱 豌襴 誤碁 ) 'OrderPizza'誤瑚 れ 殊襯 譯朱誤蠍 覲企 '殊覈'螻 ''企, 企 螳蠍 'pizzaType', 'pizzaAmount'朱 襦朱
  • 36. Clova extension 螳覦 譴觜 3 () OAuth 語 覯 襷 旧ろ 螻 語 る 旧ろ 覯 蟷 OAuth 語 蟲 . OAuth 語 覯 Clova console 焔 語覲企ゼ 伎 語 豌襴螻, 語 襭 覃 蠏狩一 覦伎 . 語覯 蟲豢 ) 覦磯 覩殊 ̄, LG , LGU + 蟯 螳企: /ClovaPlatform/clova-tech-summit-3-clova-extension-oauth-89597569
  • 38. 旧ろ 蠍磯蓋 覲 焔蠍 Clova console 伎 'Clova Extensions Kit' 企Ν れ '襦 旧ろ 襷り鍵'襯 襴. URL: https://developers.naver.com/console/clova/ 旧ろ 覲 れ type Custom Extension朱 螻, 襾語 螳る ロ. るろ伎 覿 ''襦 . ''襦 蟆曙磯 蟆曙一 .
  • 39. Clova extension 語覈 れ 螳蠍郁鍵襯 危 Custom extension (危 '旧ろ') 觜るゼ 蠏碁 覲企襦 蟆給. 襾殊 旧ろ ろ 覿襯企 企, 讀 '語覈' 伎狩, 覈 螳讌 曙 給. 朱 覈 (: 覦 (X) ) 觚 覈螳 覈 螳: (: 讌炎規覦(O)) 轟 煙語 蟆曙磯 るジ 語覈朱 朱, Clova煙 讌 誤企慨蠍 覦.
  • 40. 覯 磯 れ 碁 蠏手ロ RESTAPI 覯 endpoint URL ロ. 螻郁屋 覿 ''襦 °.
  • 41. 覦壱覲 れ 蠍一 ろ語 讌伎 覓語レ 蟾 襴れ 覓語レ 語覈 覿 螳 ろ誤 覓語レ ロ. 讌炎規覦襯 伎 讌炎規覦 蟇一 貅譴 讌炎規覦 蟇一 蟶殊
  • 43. 旧ろ 襴 豌覯讌碁 旧ろ蟆 覦襦 讌覓誤螻 旧 覦 蟆. (炎, single-turn) : 企覦, 讌炎規覦 蟇一 貅譴 旧ろ: 蟇一 煙 貅譟給. 覯讌碁 旧ろ ろ れ 讌覓誤螻 旧 覦 蟆. (覃壱, multi-turn) : 企覦, 讌炎規覦襯 伎 旧ろ: 語. 讌炎規覦螳 給. 危螻 苦 螳蠍郁鍵 覦覯 襷語. : 蟇一 貅譴. 旧ろ: 蟇一 煙 貅譟給.
  • 44. 旧ろ 襴 螻れ 伎 伎狩 殊 襴り 企覦 弰 襦 蟆碁一. 覓語 螳 螳 襷 覓殊企慨朱, 蠍蠏碁襦 襷讌 る . ) 蟇一 貅譴 ) 蟇一 伎 ) 蟇一 覿貅譴 企蟆 螳 伎襷 れ ロ螻 誤磯 覈語 企 覓語 貅伎るれ 襴企 旧ろ 襷 蟆給.
  • 45. 誤磯 覈 焔蠍 襦 焔 讌炎規覦 讌 讌 IoT蠍郁鍵襯 蟆企襦 誤碁 襷 焔覃 螻, 襦 讌 れ レれ' 蟆給. 襦 焔蠍 襦 貉れろ 襦螻 觜語 襦 2螳 讌螳 給. 觜語 襦 螳 れ 企 語 企れ 覈 蟆朱, 蟆り 豌危覃 ク襴蟆 給. 讌 れ レれ 貉れろ 襦 朱 焔. IOT_TYPE 蟇一: 襴觜襭 覦: 豺 覿: れ 覯
  • 46. 誤磯 覈 焔蠍 襦 焔 襦 焔覃 螳 .
  • 47. 誤磯 覈 焔蠍 誤 焔 一検 '譴 Intent' + 覯殊 turnOnIntentロ螻 '襷り鍵' 覯殊 襴. 襴ろ語 れ ロ 蟆 螳 れ ロ, slot螻 企麹 覓語ルれ れ蟆 ロ. 覓語レ 螳讌 襷 襦 . 蟇一 貅譴 覦 覿 貅譴 豺 伎
  • 49. 誤磯 覈 焔蠍 誤 襦 焔 襴ろ語 蟇一'企朱 企ゼ 蠏誤 れ ロ homeSlotType企 企朱 襷ろ伎. 襷ろ 襭覃 Slot 企麹 蠍れ 螳 企殊危 .
  • 50. 誤磯 覈 觜蠍 モ 覯殊 襯 れ 一検 '觜' 覯殊 誤磯 覈語 觜. 觜螳 襭覃 れ '觜'朱 覯殊朱 覦.
  • 51. 誤磯 覈 ろ 讌 REST API 覯 螳覦伎襷, 焔 誤磯 覈語 讌 誤. '觜' 覯 'ろ'襯 襴.
  • 52. 誤磯 覈 ろ 豌危 誤碁 誤磯 覈語 焔 覓語リ骸 觜訣 覓語レ ロ朱 slot螻 intent螳 襴危讌 誤 蟆. ) 蟇一 貅譴 (誤磯 覈語 覓語) 覿 伎 (誤磯 覈語 覓語リ骸 觜訣 伎襷, slot るジ 覓語) 豺 覿 貅譴 (觜訣 覓語)
  • 53. Clova extension 覯 API 螳覦
  • 54. 螳覦 蟆 蟲 螳覦 蟲 IntelliJ ( with Java ) 襦 Spring Initializr襦 襦 襦 れ pom api test (rest-assured) dependency れ
  • 55. 螳覦蟆 誤 Spring Initailzr襦 襦
  • 56. 螳覦蟆 誤 group 覈 れ
  • 57. 螳覦蟆 誤 Web貉危
  • 58. 螳覦蟆 誤 襦 企 れ
  • 59. rest-assured 蟯 pom.xml れ 豢螳 <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>3.0.5</version> <scope>test</scope> </dependency> <dependency> <groupId>io.rest-assured</groupId> <artifactId>json-path</artifactId> <version>3.0.5</version> </dependency> <dependency> <groupId>io.rest-assured</groupId> <artifactId>xml-path</artifactId> <version>3.0.5</version> </dependency> <dependency> <groupId>io.rest-assured</groupId> <artifactId>json-schema-validator</artifactId> <version>3.0.5</version> <scope>test</scope> </dependency>
  • 61. http://localhost:8080/ * 譯殊: Clova 覯 碁 80 443襷 螳 application.properties 伎 豢螳 server.port=80
  • 62. 譯 螳 Rest API - Controller 貊 ろ 蟆郁骸 @RestController @RequestMapping("/clova") public class DemoApiController { @ResponseBody @RequestMapping(value = "/v1/hello", method= RequestMethod.GET, produces = "application/json" ) public String hello() { return "hello clova api!"; } } http://localhost:8080/clova/v1/hello
  • 63. 豌 RestAssured ろ 貅伎 src-test-java 覦 HelloWorldRestAssured class 豢螳 螳 覃 譯殊 API る given() リ れ (朱誤, る ) when() get(path) : 讌 path襦 get 豌 post(path) : 讌 path襦 post 豌 焔 then() 語 蟆郁骸 蟆讀 ( statusCode(), body(), equals() 焔奄) @Test public void naverShouldBeOK() { given().when().get("/v1/hello").then().statusCode(200); }
  • 64. 覯螳 豌襴伎狩 - 1 Clova 豌 覃讌 request type 磯 讌 襷血 襴 Request type LaunchRequest : 旧ろ (讌炎規覦 伎 蟆曙) SessionEndedRequest : 旧ろ 譬襭 (譬襭伎 ) IntentRequest Custom Intent 螳覦 貊 ロ Intent Slot Built-in Intent https://developers.naver.com/console/clova/guide/CEK/References/CEK_API.md#cek-api-朱一
  • 65. 覯螳 豌襴伎狩 2 https://developers.naver.com/console/clova/guide/CE K/References/CEK_API.md#cek-api-朱一 給讌 蟲譟
  • 66. 覯螳 豌襴伎狩 3 覃壱 豌襴 覃讌 shouldEndSession false 螻 讌伎 螳 sessionAttribute 伎 http://stg.developers.naver.com/console/clova/guide/CEK/Guide s/Build_Custom_Extension.md#DoMultiturnDialog
  • 67. 貉碁, api @RequestMapping(value = "/extension", method= RequestMethod.POST, produces = "application/json" ) @ResponseBody public ResponseEntity<MyExtensionMessage> weather (@RequestBody Map<String, Object> map) { Map m = (HashMap)map.get("request"); String type = (String) m.get("type"); MyExtensionMessage mm = null; if(type.equals("LaunchRequest")) { // extension mm = new MyExtensionMessage("turnOnIntent", " 讌炎規 覦襯 . 危る 煙 襷 語. ", false, "PlainText"); } else if (type.equals("IntentRequest")) { // extension 誤 Map intent = (HashMap) m.get("intent"); String intentName = (String) intent.get("name"); Map slots = (HashMap) intent.get("slots"); String slotName = ""; String slotValue = ""; if (intentName.equals("turnOnIntent")) { if (slots != null) { Map myslot = (HashMap) slots.get("homeSlotType"); slotName = (String) myslot.get("name"); slotValue = (String) myslot.get("value"); System.out.println("slotName===" + slotName); System.out.println("slotValue===" + slotValue); } mm= new MyExtensionMessage("turnOnIntent", slotValue + " 煙 貅一給. ", true, "PlainText"); // Built-in Intent 豌襴 } else if (intentName.equals("Clova.YesIntent")) { mm = new MyExtensionMessage(intentName, " 手 ?", true, "PlainText"); } else if (intentName.equals("Clova.NoIntent")) { mm = new MyExtensionMessage(intentName, " 手 ?", true, "PlainText"); } else if (intentName.equals("Clova.GuideIntent")) { mm = new MyExtensionMessage("hearTestIntent", "覿 企手 企慨語", false, "PlainText"); } else if (intentName.equals("Clova.CancelIntent")) { mm = new MyExtensionMessage("hearTestIntent", "讌炎規 覦 ろ 豬. ", true, "PlainText"); } } else if (type.equals("SessionEndedRequest")) { // extension 譬襭 mm = new MyExtensionMessage("turnOnIntent", "讌炎規 覦襯 譬襭. ", false, "PlainText"); } return new ResponseEntity<MyExtensionMessage>(mm, HttpStatus.OK); }
  • 69. Extension message 豌襴 企 public class MyExtensionMessage { public String version = "1.0"; public Map<String, Object> sessionAttributes = new HashMap(); public MyResponse response = null; public MyExtensionMessage(String INTENT_NAME, boolean session, ArrayList<Map> myResponseValue) { if(!session) { sessionAttributes.put("intent", INTENT_NAME); } MyResponse response = new MyResponse(); response.shouldEndSession= session; response.outputSpeech.put("type", "SpeechList"); response.outputSpeech.put("values", myResponseValue); this.response = response; } public MyExtensionMessage(String INTENT_NAME, String message, boolean session, String type) { // MyResponseValue 螳豌 Map<String, String> myResponseValue = new HashMap<String, String>(); myResponseValue.put("type", type); myResponseValue.put("lang", "ko"); myResponseValue.put("value", message); if(!session) { sessionAttributes.put("intent", INTENT_NAME); } MyResponse response = new MyResponse(); response.shouldEndSession= session; response.outputSpeech.put("type", "SimpleSpeech"); response.outputSpeech.put("values", myResponseValue); this.response = response; } public static class MyResponse { public Map<String, Object> outputSpeech = new HashMap<String, Object>(); public Map<String, Map> card = new HashMap<String, Map>(); public ArrayList<String> directives = new ArrayList<String>(); public boolean shouldEndSession = false; } }
  • 70. Api test private final String LaunchRequest = "LaunchRequest"; private final String IntentRequest = "IntentRequest"; private final String SessionEndedRequest = "SessionEndedRequest"; private final String INTENT_NAME = "turnOnIntent"; private final String SLOT_NAME = "homeSlotType"; @Test public void extensionShouldReturnLaunchRequest() { given() .header("Content-Type", "application/json") .body(getClovaJson(LaunchRequest, INTENT_NAME, SLOT_NAME)) .when().post("/clova/extension") .then().body("response.outputSpeech.values.value",containsString("")); } @Test public void extensionShouldReturnIntentRequest() { given() .header("Content-Type", "application/json") .body(getClovaJson(IntentRequest, INTENT_NAME, SLOT_NAME)) .when().post("/clova/extension") .then().body("response.outputSpeech.values.value",containsString("")); } @Test public void extensionShouldReturnEndRequest() { given() .header("Content-Type", "application/json") .body(getClovaJson(SessionEndedRequest, INTENT_NAME, SLOT_NAME)) .when().post("/clova/extension") .then().body("response.outputSpeech.values.value",containsString("譬襭")); }
  • 71. Api test private String getClovaJson(String type, String intentName, String slotName) { String jsonReq = "{n" + " "version": "0.1.0",n" + " "session": {n" + " "sessionId": "ff5db3a3-0f67-4b24-830f-cfa785556a71",n" + " "user": {n" + " "userId": "azvjPlQkSCuV8LmItY2VrQ",n" + " "accessToken": "66e7e019-cda9-4826-acdd-b1671b551e97"n" + " },n" + " "new": truen" + " },n" + " "context": {n" + " "System": {n" + " "user": {n" + " "userId": "azvjPlQkSCuV8LmItY2VrQ",n" + " "accessToken": "66e7e019-cda9-4826-acdd-b1671b551e97"n" + " },n" + " "device": {n" + " "deviceId": "4a0307d4-0674-4cdb-890e-be29f049339d"n" + " }n" + " }n" + " },n" + " "request": {n" + " "type": ""+ type +"",n" + " "intent": {n" + " "name": ""+ intentName +"",n"+ " "slots": {n" + " ""+ slotName +"": {n" + " "name": ""+ slotName +"",n" + " "value": 蟇一"n"+ " }n" + " }n" + " }n" + " }n" + "}"; return jsonReq; }
  • 72. Clova 炎骸 ろ殊擦 旧ろ 語 ろ
  • 73. ろ 螻 螳覦 貊 test れ企 螻 焔 ろ 覦覯1 Clova Clova 煙 企 企襦 襦蠏語 讌炎規覦 伎 手 旧ろ 覯襦 LaunchRequest螳 る讌, 旧ろ 旧 煙朱 螳讌 ろ 覦覯2 Friends ろ殊擦 ろ磯 焔 企襦 Clova煙 伎伎 ろ殊擦 れ 讌炎規覦 伎 手 旧ろ 覯襦 LaunchRequest螳 る讌, 旧ろ 旧 煙朱 螳讌
  • 74. Appendix. Clova 螳覦 覓語 : https://developers.naver.com/console/clova/guide/ Design 豈 / Clova Extensions Kit 豈 / Clova Developer Console 豈 谿瑚 襴 覦 貊 谿瑚 貊 Github 襷覯 蟲 : https://github.com/naver/clova-extension-sample-magicball 觜襴 : https://github.com/naver/clova-extension-sample-rainsound 譯殊 : https://github.com/naver/clova-extension-sample-dice 貊 : https://github.com/naver/clova-extension-sample-coinhelper