SlideShare a Scribd company logo
1 of 33
Download to read offline
/ F @ DE @D@
3C @D C DC 9 @F 1
D@ E 9 @E @F D C @
99 4 / 020
# #
A E
)
)
( )(
) (
• 1 .1 1 ) - -
• 1 1 3 (- - 3 (
• 1 -2 1 )
( ) ) )
dependencies {
implementation "org.jetbrains.kotlin:kotlin-script-util:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-script-runtime:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion”
}
Add the dependencies
( ) ) )
org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory
add a file javax.script.ScriptEngineFactory in “resources/META-INF/services/”
( ) ) )
private val scriptEngine: ScriptEngine = ScriptEngineManager().getEngineByExtension("kts")!!
Get the ScriptEngine
)( ( (
(
val x = scriptEngine.eval(
"""
fun x(input: Int): Int = input + 3
""")
x=?x=null
)( ( (
(
val y = scriptEngine.eval(
"""
fun x(input: Int): Int = input + 3
val y = x(2)
""")
y=?y=null
)( ( (
(
val x = scriptEngine.eval(
"""
fun x(input: Int): Int = input + 3
x(2)
""")
x=?x=5
)( ( (
(
val value = scriptEngine.eval(
"""
fun x(input: Int): Int = input + 3
val x = x(2)
var y = x
x
y = x(7)
""")
value=?value=null
)( ( (
(
val value = scriptEngine.eval(
"""
fun x(input: Int): Int = input + 3
var x = x(2)
var y = x
x = 10
x
y + 1
""")
value=?value=6
• , ( ,
) (
/ . - . . -
val client: ClovaClient = clovaClient(applicationId = "YOUR APPLICATION ID") {
objectMapper = JacksonObjectMapper() //SDK only supports Jackson now
launchHandler { request, session ->
simpleResponse(message = " ")
}
intentHandler { request, session ->
val value = request.intent.slots["number"]?.value
simpleResponseWithReprompt(
message = " ${value} ",
repromptMessage = " ”
)
}
sessionEndedHandler { request, session ->
simpleResponse(message = " ")
}
}
val client: ClovaClient = clovaClient(applicationId = "YOUR APPLICATION ID") {
objectMapper = JacksonObjectMapper()
launchHandler { request, session ->
simpleResponse(message = “ ”) // Helper function
}
intentHandler { request, session ->
val value = request.intent.slots["number"]?.value
simpleResponseWithReprompt(
message = " ${value} ",
repromptMessage = " ”
)
}
sessionEndedHandler { request, session ->
simpleResponse(message = " ")
}
}
val client: ClovaClient = clovaClient(applicationId = "YOUR APPLICATION ID") {
objectMapper = JacksonObjectMapper()
launchHandler { request, session ->
simpleResponse(message = " ")
}
intentHandler { request, session ->
val value = request.intent.slots["number"]?.value
simpleResponseWithReprompt(
message = " ${value} ",
repromptMessage = " ”
)
}
sessionEndedHandler { request, session ->
simpleResponse(message = " ")
}
}
val client: ClovaClient = clovaClient(applicationId = "YOUR APPLICATION ID") {
objectMapper = JacksonObjectMapper()
launchHandler { request, session ->
simpleResponse(message = " ")
}
intentHandler { request, session ->
val value = request.intent.slots["number"]?.value
simpleResponseWithReprompt(
message = " ${value} ",
repromptMessage = " ”
)
}
sessionEndedHandler { request, session ->
simpleResponse(message = " ")
}
}
@Dsl
fun ClovaClient.launchHandler(handler: RequestHandler<LaunchRequest>) {
launchHandler = handler
}
@Dsl
fun ClovaClient.intentHandler(handler: RequestHandler<IntentRequest>) {
intentHandler = handler
}
@Dsl
fun ClovaClient.sessionEndedHandler(handler: RequestHandler<SessionEndedRequest>) {
sessionEndedHandler = handler
}
typealias RequestHandler<T> = suspend (T, Session) -> ClovaExtensionResponse
launchHandler { request, session ->
simpleResponse(message = “ ”) ! // return ClovaExtensionResponse
}
//requestBody and response are json strings
val response = client.handleClovaRequest(requestBody, request.headers().asHttpHeaders())
•
•
• - -
Is it possible to use Kotlin script
to create ClovaClient??
val clovaClient = scriptEngine.eval("""
clovaClient(applicationId = "APPLICATION_ID") {
launchHandler { ... }
intentHandler { ... }
sessionEndedHandler { ... }
}
""")
val clovaClient = scriptEngine.eval("""
import com.linecorp.clova.extension.client.*
import com.linecorp.clova.extension.model.util.*
import com.linecorp.clova.extension.model.response.*
import com.linecorp.clova.extension.converter.jackson.JacksonObjectMapper
clovaClient(applicationId = "YOUR APPLICATION ID") {
launchHandler { ...}
intentHandler { ... }
sessionEndedHandler { ... }
}
""")
val clovaClient = scriptEngine.eval(
"""
import …
clovaClient(applicationId = "APPLICATION_ID") {
…
}
""")
…
val response = client.handleClovaRequest(requestBody, request.headers().asHttpHeaders())
val clovaClient = scriptEngine.eval(
"""
import …
clovaClient(applicationId = "APPLICATION_ID") {
…
}
""")
…
val response = client.handleClovaRequest(requestBody, request.headers().asHttpHeaders())
! Input the script from web
/ .
• : .
• -
!

More Related Content

What's hot

Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
Thomas Weinert
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
AOE
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
Robert Nyman
 
JSON Schema: Your API's Secret Weapon
JSON Schema: Your API's Secret WeaponJSON Schema: Your API's Secret Weapon
JSON Schema: Your API's Secret Weapon
Pete Gamache
 

What's hot (20)

Javascript - Beyond-jQuery
Javascript - Beyond-jQueryJavascript - Beyond-jQuery
Javascript - Beyond-jQuery
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
 
History of jQuery
History of jQueryHistory of jQuery
History of jQuery
 
Phoenix + Reactで 社内システムを 密かに作ってる
Phoenix + Reactで 社内システムを 密かに作ってるPhoenix + Reactで 社内システムを 密かに作ってる
Phoenix + Reactで 社内システムを 密かに作ってる
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
 
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
 
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
 
React PHP: the NodeJS challenger
React PHP: the NodeJS challengerReact PHP: the NodeJS challenger
React PHP: the NodeJS challenger
 
Finch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with FinagleFinch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with Finagle
 
Introduction to Service Workers | Matteo Manchi
Introduction to Service Workers | Matteo ManchiIntroduction to Service Workers | Matteo Manchi
Introduction to Service Workers | Matteo Manchi
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
Multi tenant laravel
Multi tenant laravelMulti tenant laravel
Multi tenant laravel
 
A real-world Relay application in production - Stefano Masini - Codemotion Am...
A real-world Relay application in production - Stefano Masini - Codemotion Am...A real-world Relay application in production - Stefano Masini - Codemotion Am...
A real-world Relay application in production - Stefano Masini - Codemotion Am...
 
FwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsFwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.js
 
AngularJS - $http & $resource Services
AngularJS - $http & $resource ServicesAngularJS - $http & $resource Services
AngularJS - $http & $resource Services
 
JSON Schema: Your API's Secret Weapon
JSON Schema: Your API's Secret WeaponJSON Schema: Your API's Secret Weapon
JSON Schema: Your API's Secret Weapon
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 

Similar to Use Kotlin scripts and Clova SDK to build your Clova extension

Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010
Ismael Celis
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
yiming he
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
smueller_sandsmedia
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
it-people
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
Michael Peacock
 

Similar to Use Kotlin scripts and Clova SDK to build your Clova extension (20)

[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
 
Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010
 
The IoC Hydra
The IoC HydraThe IoC Hydra
The IoC Hydra
 
Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DIC
 
Infrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and OpsInfrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and Ops
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
AngularJs
AngularJsAngularJs
AngularJs
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
 
The IoC Hydra - Dutch PHP Conference 2016
The IoC Hydra - Dutch PHP Conference 2016The IoC Hydra - Dutch PHP Conference 2016
The IoC Hydra - Dutch PHP Conference 2016
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
 
XQuery Rocks
XQuery RocksXQuery Rocks
XQuery Rocks
 
Not your Grandma's XQuery
Not your Grandma's XQueryNot your Grandma's XQuery
Not your Grandma's XQuery
 
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12
 

More from LINE Corporation

More from LINE Corporation (20)

JJUG CCC 2018 Fall 懇親会LT
JJUG CCC 2018 Fall 懇親会LTJJUG CCC 2018 Fall 懇親会LT
JJUG CCC 2018 Fall 懇親会LT
 
Reduce dependency on Rx with Kotlin Coroutines
Reduce dependency on Rx with Kotlin CoroutinesReduce dependency on Rx with Kotlin Coroutines
Reduce dependency on Rx with Kotlin Coroutines
 
Kotlin/NativeでAndroidのNativeメソッドを実装してみた
Kotlin/NativeでAndroidのNativeメソッドを実装してみたKotlin/NativeでAndroidのNativeメソッドを実装してみた
Kotlin/NativeでAndroidのNativeメソッドを実装してみた
 
The Magic of LINE 購物 Testing
The Magic of LINE 購物 TestingThe Magic of LINE 購物 Testing
The Magic of LINE 購物 Testing
 
GA Test Automation
GA Test AutomationGA Test Automation
GA Test Automation
 
UI Automation Test with JUnit5
UI Automation Test with JUnit5UI Automation Test with JUnit5
UI Automation Test with JUnit5
 
Feature Detection for UI Testing
Feature Detection for UI TestingFeature Detection for UI Testing
Feature Detection for UI Testing
 
LINE 新星計劃介紹與新創團隊分享
LINE 新星計劃介紹與新創團隊分享LINE 新星計劃介紹與新創團隊分享
LINE 新星計劃介紹與新創團隊分享
 
​LINE 技術合作夥伴與應用分享
​LINE 技術合作夥伴與應用分享​LINE 技術合作夥伴與應用分享
​LINE 技術合作夥伴與應用分享
 
LINE 開發者社群經營與技術推廣
LINE 開發者社群經營與技術推廣LINE 開發者社群經營與技術推廣
LINE 開發者社群經營與技術推廣
 
日本開發者大會短講分享
日本開發者大會短講分享日本開發者大會短講分享
日本開發者大會短講分享
 
LINE Chatbot - 活動報名報到設計分享
LINE Chatbot - 活動報名報到設計分享LINE Chatbot - 活動報名報到設計分享
LINE Chatbot - 活動報名報到設計分享
 
在 LINE 私有雲中使用 Managed Kubernetes
在 LINE 私有雲中使用 Managed Kubernetes在 LINE 私有雲中使用 Managed Kubernetes
在 LINE 私有雲中使用 Managed Kubernetes
 
LINE TODAY高效率的敏捷測試開發技巧
LINE TODAY高效率的敏捷測試開發技巧LINE TODAY高效率的敏捷測試開發技巧
LINE TODAY高效率的敏捷測試開發技巧
 
LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹
LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹
LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹
 
LINE Things - LINE IoT平台新技術分享
LINE Things - LINE IoT平台新技術分享LINE Things - LINE IoT平台新技術分享
LINE Things - LINE IoT平台新技術分享
 
LINE Pay - 一卡通支付新體驗
LINE Pay - 一卡通支付新體驗LINE Pay - 一卡通支付新體驗
LINE Pay - 一卡通支付新體驗
 
LINE Platform API Update - 打造一個更好的Chatbot服務
LINE Platform API Update - 打造一個更好的Chatbot服務LINE Platform API Update - 打造一個更好的Chatbot服務
LINE Platform API Update - 打造一個更好的Chatbot服務
 
Keynote - ​LINE 的技術策略佈局與跨國產品開發
Keynote - ​LINE 的技術策略佈局與跨國產品開發Keynote - ​LINE 的技術策略佈局與跨國產品開發
Keynote - ​LINE 的技術策略佈局與跨國產品開發
 
LINE Ads Platformの開発を支えるKafka
LINE Ads Platformの開発を支えるKafkaLINE Ads Platformの開発を支えるKafka
LINE Ads Platformの開発を支えるKafka
 

Recently uploaded

Recently uploaded (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 

Use Kotlin scripts and Clova SDK to build your Clova extension

  • 1. / F @ DE @D@ 3C @D C DC 9 @F 1 D@ E 9 @E @F D C @ 99 4 / 020 # #
  • 3. ) (
  • 4.
  • 5. • 1 .1 1 ) - - • 1 1 3 (- - 3 ( • 1 -2 1 )
  • 6. ( ) ) ) dependencies { implementation "org.jetbrains.kotlin:kotlin-script-util:$kotlinVersion" implementation "org.jetbrains.kotlin:kotlin-script-runtime:$kotlinVersion" implementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion” } Add the dependencies
  • 7. ( ) ) ) org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory add a file javax.script.ScriptEngineFactory in “resources/META-INF/services/”
  • 8. ( ) ) ) private val scriptEngine: ScriptEngine = ScriptEngineManager().getEngineByExtension("kts")!! Get the ScriptEngine
  • 9. )( ( ( ( val x = scriptEngine.eval( """ fun x(input: Int): Int = input + 3 """) x=?x=null
  • 10. )( ( ( ( val y = scriptEngine.eval( """ fun x(input: Int): Int = input + 3 val y = x(2) """) y=?y=null
  • 11. )( ( ( ( val x = scriptEngine.eval( """ fun x(input: Int): Int = input + 3 x(2) """) x=?x=5
  • 12. )( ( ( ( val value = scriptEngine.eval( """ fun x(input: Int): Int = input + 3 val x = x(2) var y = x x y = x(7) """) value=?value=null
  • 13. )( ( ( ( val value = scriptEngine.eval( """ fun x(input: Int): Int = input + 3 var x = x(2) var y = x x = 10 x y + 1 """) value=?value=6
  • 14. • , ( , ) (
  • 15.
  • 16. / . - . . -
  • 17. val client: ClovaClient = clovaClient(applicationId = "YOUR APPLICATION ID") { objectMapper = JacksonObjectMapper() //SDK only supports Jackson now launchHandler { request, session -> simpleResponse(message = " ") } intentHandler { request, session -> val value = request.intent.slots["number"]?.value simpleResponseWithReprompt( message = " ${value} ", repromptMessage = " ” ) } sessionEndedHandler { request, session -> simpleResponse(message = " ") } }
  • 18. val client: ClovaClient = clovaClient(applicationId = "YOUR APPLICATION ID") { objectMapper = JacksonObjectMapper() launchHandler { request, session -> simpleResponse(message = “ ”) // Helper function } intentHandler { request, session -> val value = request.intent.slots["number"]?.value simpleResponseWithReprompt( message = " ${value} ", repromptMessage = " ” ) } sessionEndedHandler { request, session -> simpleResponse(message = " ") } }
  • 19. val client: ClovaClient = clovaClient(applicationId = "YOUR APPLICATION ID") { objectMapper = JacksonObjectMapper() launchHandler { request, session -> simpleResponse(message = " ") } intentHandler { request, session -> val value = request.intent.slots["number"]?.value simpleResponseWithReprompt( message = " ${value} ", repromptMessage = " ” ) } sessionEndedHandler { request, session -> simpleResponse(message = " ") } }
  • 20. val client: ClovaClient = clovaClient(applicationId = "YOUR APPLICATION ID") { objectMapper = JacksonObjectMapper() launchHandler { request, session -> simpleResponse(message = " ") } intentHandler { request, session -> val value = request.intent.slots["number"]?.value simpleResponseWithReprompt( message = " ${value} ", repromptMessage = " ” ) } sessionEndedHandler { request, session -> simpleResponse(message = " ") } }
  • 21. @Dsl fun ClovaClient.launchHandler(handler: RequestHandler<LaunchRequest>) { launchHandler = handler } @Dsl fun ClovaClient.intentHandler(handler: RequestHandler<IntentRequest>) { intentHandler = handler } @Dsl fun ClovaClient.sessionEndedHandler(handler: RequestHandler<SessionEndedRequest>) { sessionEndedHandler = handler }
  • 22. typealias RequestHandler<T> = suspend (T, Session) -> ClovaExtensionResponse launchHandler { request, session -> simpleResponse(message = “ ”) ! // return ClovaExtensionResponse }
  • 23. //requestBody and response are json strings val response = client.handleClovaRequest(requestBody, request.headers().asHttpHeaders())
  • 25. Is it possible to use Kotlin script to create ClovaClient??
  • 26.
  • 27. val clovaClient = scriptEngine.eval(""" clovaClient(applicationId = "APPLICATION_ID") { launchHandler { ... } intentHandler { ... } sessionEndedHandler { ... } } """)
  • 28. val clovaClient = scriptEngine.eval(""" import com.linecorp.clova.extension.client.* import com.linecorp.clova.extension.model.util.* import com.linecorp.clova.extension.model.response.* import com.linecorp.clova.extension.converter.jackson.JacksonObjectMapper clovaClient(applicationId = "YOUR APPLICATION ID") { launchHandler { ...} intentHandler { ... } sessionEndedHandler { ... } } """)
  • 29. val clovaClient = scriptEngine.eval( """ import … clovaClient(applicationId = "APPLICATION_ID") { … } """) … val response = client.handleClovaRequest(requestBody, request.headers().asHttpHeaders())
  • 30. val clovaClient = scriptEngine.eval( """ import … clovaClient(applicationId = "APPLICATION_ID") { … } """) … val response = client.handleClovaRequest(requestBody, request.headers().asHttpHeaders()) ! Input the script from web
  • 31. / .
  • 33. !