Aimybox channel

Allows to create skills for custom voice assistant applications built on top of Aimybox SDK.

How to use

1. Include Aimybox dependency to your build.gradle

implementation("com.just-ai.jaicf:aimybox:$jaicfVersion")

Replace $jaicfVersion with the latest version

2. Use Aimybox request and reactions in your scenarios’ actions

action {
    // Arbitrary JSON object passed from the device
    val data = request.aimybox?.data

    // Add custom replies
    reactions.aimybox?.question(true)
    reactions.aimybox?.say(text = "Hello!", tts = "hello, how are you?")
    reactions.aimybox?.buttons(UrlButton("Open websitte", "https://address.com"))
    
    // Or use standard response builders
    reactions.say("How are you?")
    reactions.buttons("Good", "Bad")
}

Please refer to the Aimybox HTTP API to learn more about available reply types.

3. Create and run Aimybox webhook

Using JAICP

For local development:

fun main() {
    JaicpPollingConnector(
        botApi = helloWorldBot,
        accessToken = "your JAICF project token",
        channels = listOf(
            AimyboxChannel
        )
    ).runBlocking()
}

For cloud production:

fun main() {
    JaicpServer(
        botApi = helloWorldBot,
        accessToken = "your JAICF project token",
        channels = listOf(
            AimyboxChannel
        )
    ).start(wait = true)
}

Using Ktor

fun main() {
    embeddedServer(Netty, 8000) {
        routing {
            httpBotRouting("/" to AimyboxChannel(helloWorldBot))
        }
    }.start(wait = true)
}

Using Spring Boot

@Bean
fun aimyboxServlet() {
    return ServletRegistrationBean(
        HttpBotChannelServlet(AimyboxChannel(helloWorldBot)),
        "/"
    ).apply {
        setLoadOnStartup(1)
    }
}

4. Configure Aimybox

Then you can use the public webhook URL (using ngrok for example) to register a custom voice skill via Aimybox Console or provide this URL directly to the Aimybox initialisation block of your mobile application.

Start event

If you send an empty query, Aimybox recognises this as a START event instead of query request:

state("launch") {
    activators {
        event(AimyboxEvent.START)
    }
}

This can be used to start a voice skill scenario. New user session will be started automatically.

Do not miss to include a BaseEventActivator in activators array of the BotEngine initializer.