SlideShare a Scribd company logo
/ F @ DE @D@
3C @D C DC 9 @F 1
D@ E 9 @E @F D C @
99 4 / 020
# #
A E
)
)
( )(
) (
Use Kotlin scripts and Clova SDK to build your Clova extension
• 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
• , ( ,
) (
Use Kotlin scripts and Clova SDK to build your Clova extension
/ . - . . -
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??
Use Kotlin scripts and Clova SDK to build your Clova extension
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

KEY
Zendcon 09
PDF
Tools and Projects Dec 2018 Edition
PDF
#Gophercon Talk by Smita Vijayakumar - Go's Context Library
PDF
Decoupling Objects With Standard Interfaces
KEY
Grails UI Primer
TXT
Exch test-mail flow
PDF
Joe Walker Interactivewebsites Cometand Dwr
PPTX
Building multi lingual and empatic bots - Sander van den Hoven - Codemotion A...
Zendcon 09
Tools and Projects Dec 2018 Edition
#Gophercon Talk by Smita Vijayakumar - Go's Context Library
Decoupling Objects With Standard Interfaces
Grails UI Primer
Exch test-mail flow
Joe Walker Interactivewebsites Cometand Dwr
Building multi lingual and empatic bots - Sander van den Hoven - Codemotion A...

What's hot (20)

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

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

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

More from LINE Corporation (20)

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

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PDF
Modernizing your data center with Dell and AMD
PPTX
Cloud computing and distributed systems.
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Big Data Technologies - Introduction.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Monthly Chronicles - July 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Approach and Philosophy of On baking technology
Modernizing your data center with Dell and AMD
Cloud computing and distributed systems.
Empathic Computing: Creating Shared Understanding
Understanding_Digital_Forensics_Presentation.pptx
Network Security Unit 5.pdf for BCA BBA.
Mobile App Security Testing_ A Comprehensive Guide.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Big Data Technologies - Introduction.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Monthly Chronicles - July 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
Unlocking AI with Model Context Protocol (MCP)
The Rise and Fall of 3GPP – Time for a Sabbatical?
Per capita expenditure prediction using model stacking based on satellite ima...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication

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. ) (
  • 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. • , ( , ) (
  • 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??
  • 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. !