Skip to content
morfeusys edited this page Mar 19, 2020 · 1 revision

Ktor is a framework for building asynchronous servers. It allows you to quickly setup any HTTP server like Netty or Jetty and serve your JAICF agent.

How to use

This server can be used with any channel that implements HttpBotChannel interface.

Learn more about channels here.

1. Append Ktor dependency to build.gradle

implementation("io.ktor:ktor-server-netty:1.3.1")

or

implementation("io.ktor:ktor-server-jetty:1.3.1")

2. Configure routing and run server

Use httpBotRouting extension to create a routing for HttpBotChannel endpoints.

fun main() {
    embeddedServer(Netty, 8000) {
        routing {
            httpBotRouting(
                "/alexa" to AlexaChannel(gameClockBot),
                "/actions" to ActionsFulfillment.dialogflow(gameClockBot)
            )
        }
    }.start(wait = true)
}

The same for Jetty server.

Clone this wiki locally