├── docs ├── runtime-shared │ ├── index.md │ ├── org.rewedigital.konversation │ │ ├── index.md │ │ ├── kotlin.collections.-iterable.md │ │ ├── -reader │ │ │ ├── -init-.md │ │ │ ├── load-reply.md │ │ │ └── index.md │ │ ├── -random │ │ │ ├── -init-.md │ │ │ ├── next.md │ │ │ └── index.md │ │ ├── -file-checker │ │ │ ├── -init-.md │ │ │ ├── exists.md │ │ │ └── index.md │ │ ├── -konversation │ │ │ ├── regex.md │ │ │ ├── random.md │ │ │ ├── name.md │ │ │ ├── -init-.md │ │ │ ├── create-output.md │ │ │ └── index.md │ │ ├── -environment │ │ │ ├── locale.md │ │ │ ├── platform.md │ │ │ ├── -init-.md │ │ │ └── index.md │ │ ├── -output │ │ │ ├── display-text.md │ │ │ ├── ssml.md │ │ │ ├── plus.md │ │ │ ├── suggestions.md │ │ │ ├── extras.md │ │ │ ├── reprompts.md │ │ │ ├── -init-.md │ │ │ └── index.md │ │ ├── -formatter │ │ │ ├── -init-.md │ │ │ ├── format.md │ │ │ └── index.md │ │ └── kotlin.collections.-iterable │ │ │ ├── for-each-iterator.md │ │ │ └── index.md │ ├── package-list │ └── alltypes │ │ └── index.md ├── shared │ ├── package-list │ ├── index.md │ ├── org.rewedigital.konversation │ │ ├── -part-type │ │ │ ├── -text.md │ │ │ ├── -voice-only.md │ │ │ └── index.md │ │ ├── -part │ │ │ ├── type.md │ │ │ ├── variants.md │ │ │ └── index.md │ │ ├── -reply │ │ │ ├── parts.md │ │ │ ├── suggestions.md │ │ │ ├── reprompts.md │ │ │ ├── -init-.md │ │ │ └── index.md │ │ └── index.md │ └── alltypes │ │ └── index.md ├── runtime-js │ ├── package-list │ ├── org.rewedigital.konversation │ │ ├── -math │ │ │ ├── -init-.md │ │ │ ├── random.md │ │ │ └── index.md │ │ ├── -reader │ │ │ ├── -init-.md │ │ │ ├── load-reply.md │ │ │ └── index.md │ │ ├── require.md │ │ ├── -random │ │ │ ├── -init-.md │ │ │ ├── next.md │ │ │ └── index.md │ │ ├── -file-checker │ │ │ ├── -init-.md │ │ │ ├── exists.md │ │ │ └── index.md │ │ ├── -konversation-js │ │ │ ├── -output-js │ │ │ │ ├── extras.md │ │ │ │ ├── reprompts.md │ │ │ │ ├── display-text.md │ │ │ │ ├── ssml.md │ │ │ │ ├── suggestions.md │ │ │ │ ├── -init-.md │ │ │ │ └── index.md │ │ │ ├── -init-.md │ │ │ ├── create-java-script-output.md │ │ │ └── index.md │ │ ├── -formatter │ │ │ ├── -init-.md │ │ │ ├── format.md │ │ │ └── index.md │ │ └── index.md │ ├── index.md │ └── alltypes │ │ └── index.md └── runtime-jvm │ ├── package-list │ ├── org.rewedigital.konversation │ ├── -part-impl │ │ ├── type.md │ │ ├── variants.md │ │ ├── -init-.md │ │ └── index.md │ ├── -adapter-factory │ │ ├── -init-.md │ │ ├── create.md │ │ └── index.md │ ├── -reader │ │ ├── -init-.md │ │ ├── load-reply.md │ │ └── index.md │ ├── -part-impl-json-adapter │ │ ├── -init-.md │ │ ├── to-string.md │ │ ├── from-json.md │ │ ├── to-json.md │ │ └── index.md │ ├── -answer-impl-json-adapter │ │ ├── -init-.md │ │ ├── to-string.md │ │ ├── from-json.md │ │ ├── to-json.md │ │ └── index.md │ ├── -random │ │ ├── -init-.md │ │ ├── next.md │ │ └── index.md │ ├── -file-checker │ │ ├── -init-.md │ │ ├── exists.md │ │ └── index.md │ ├── -answer-impl │ │ ├── parts.md │ │ ├── suggestions.md │ │ ├── reprompts.md │ │ ├── -init-.md │ │ └── index.md │ ├── -formatter │ │ ├── -init-.md │ │ ├── format.md │ │ └── index.md │ └── index.md │ ├── index.md │ └── alltypes │ └── index.md ├── runtime-js ├── .gitignore ├── src │ ├── main │ │ ├── javascript │ │ │ ├── .gitignore │ │ │ ├── .npmignore │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── resources │ │ │ └── test.kson │ │ └── kotlin │ │ │ └── org │ │ │ └── rewedigital │ │ │ └── konversation │ │ │ ├── Random.kt │ │ │ ├── Answer.kt │ │ │ ├── FileChecker.kt │ │ │ ├── Formatter.kt │ │ │ ├── Reader.kt │ │ │ └── InterOp.kt │ └── test │ │ ├── javascript │ │ ├── package.json │ │ ├── example.js │ │ └── simpleTest.js │ │ └── kotlin │ │ └── org │ │ └── rewedigital │ │ └── konversation │ │ └── KonversationJsTest.kt ├── example.js ├── start-node.js ├── start-browser.html └── readme.md ├── gradle-plugin ├── .gitignore ├── src │ └── main │ │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ ├── konversation.properties │ │ └── com.rewedigital.voice.konversation.properties └── build.gradle ├── plugin-example ├── src │ └── main │ │ ├── resources │ │ └── example │ │ ├── konversation │ │ ├── ExampleIntent.kvs │ │ └── help.kvs │ │ └── kotlin │ │ └── org │ │ └── rewedigital │ │ └── example │ │ └── Example.kt └── build.gradle ├── MAINTAINERS ├── cli ├── .gitignore ├── src │ ├── test │ │ ├── resources │ │ │ ├── dub.kvs │ │ │ ├── foo │ │ │ │ └── ExampleIntent.kvs │ │ │ ├── konversation │ │ │ │ ├── fail │ │ │ │ ├── colors.values │ │ │ │ └── help.kvs │ │ │ ├── konversation-alexa │ │ │ │ ├── fail │ │ │ │ └── help.kvs │ │ │ ├── huge.grammar │ │ │ ├── help.grammar │ │ │ ├── help-expected-alexa-result-minified.json │ │ │ ├── konversation-en │ │ │ │ └── help.kvs │ │ │ ├── help.kvs │ │ │ ├── konversation-alexa-de │ │ │ │ └── help.kvs │ │ │ ├── help-expected-kson-result-minified.json │ │ │ ├── help-expected-alexa-result.json │ │ │ ├── huge-expected-alexa-result-limited.json │ │ │ └── help-expected-kson-result.json │ │ ├── konversation │ │ │ ├── fail │ │ │ ├── alexa │ │ │ │ ├── fail │ │ │ │ ├── help.kvs │ │ │ │ └── de │ │ │ │ │ └── help.kvs │ │ │ ├── pets.values │ │ │ ├── animal-selection.kvs │ │ │ ├── annotations.kvs │ │ │ ├── help.kvs │ │ │ └── en │ │ │ │ └── help.kvs │ │ └── kotlin │ │ │ └── org │ │ │ └── rewedigital │ │ │ └── konversation │ │ │ ├── TestHelper.kt │ │ │ ├── generator │ │ │ ├── kson │ │ │ │ └── KsonExporterTest.kt │ │ │ ├── dialogflow │ │ │ │ └── EntityTest.kt │ │ │ └── alexa │ │ │ │ └── AlexaExporterTest.kt │ │ │ └── parser │ │ │ └── PermutatorTest.kt │ └── main │ │ └── kotlin │ │ └── org │ │ └── rewedigital │ │ └── konversation │ │ ├── Entities.kt │ │ ├── Entity.kt │ │ ├── LoggerFacade.kt │ │ ├── parser │ │ ├── KonversationSyntaxError.kt │ │ └── Permutator.kt │ │ ├── generator │ │ ├── Exporter.kt │ │ └── dialogflow │ │ │ ├── EntityMetaData.kt │ │ │ ├── Entity.kt │ │ │ ├── Message.kt │ │ │ ├── QuickReply.kt │ │ │ ├── Response.kt │ │ │ ├── ResponseParameter.kt │ │ │ ├── DialogflowIntent.kt │ │ │ └── DialogflowUtterance.kt │ │ └── Intent.kt └── build.gradle ├── cli-integrations └── chocolatey │ ├── tools │ ├── chocolateyUninstall.ps1 │ └── chocolateyInstall.ps1 │ ├── legal │ ├── VERIFICATION.txt │ └── LICENSE.txt │ └── konversation.nuspec ├── travis_rsa.enc ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── runtime-jvm ├── src │ ├── test │ │ ├── resources │ │ │ ├── konversation │ │ │ │ ├── ApplyVariableTest.kson │ │ │ │ └── help.kson │ │ │ ├── test.json │ │ │ └── test.kson │ │ └── kotlin │ │ │ └── org │ │ │ └── rewedigital │ │ │ └── konversation │ │ │ └── KonversationTest.kt │ └── main │ │ └── kotlin │ │ └── org │ │ └── rewedigital │ │ └── konversation │ │ ├── FileChecker.kt │ │ ├── Random.kt │ │ ├── Answer.kt │ │ ├── AdapterFactory.kt │ │ ├── Formatter.kt │ │ └── Reader.kt └── build │ └── generated │ └── source │ └── kaptKotlin │ └── main │ └── org │ └── rewedigital │ └── konversation │ └── PartImplJsonAdapter.kt ├── runtime-shared ├── src │ ├── main │ │ └── kotlin │ │ │ └── org │ │ │ └── rewedigital │ │ │ └── konversation │ │ │ ├── Extensions.kt │ │ │ ├── FileChecker.kt │ │ │ ├── Random.kt │ │ │ ├── Environment.kt │ │ │ ├── Reader.kt │ │ │ ├── Formatter.kt │ │ │ ├── Output.kt │ │ │ ├── ResourceLocator.kt │ │ │ └── Konversation.kt │ └── test │ │ └── kotlin │ │ └── org │ │ └── rewedigital │ │ └── konversation │ │ └── ResourceLocatorTest.kt └── build.gradle ├── .travis ├── deploy_chocolaty.sh ├── configure_jvm.sh ├── configure_js.sh ├── prepare_deployment.sh ├── configure.sh ├── configure_cli.sh └── prepare_cli_deployment.sh ├── docu.gradle ├── shared ├── src │ └── main │ │ └── kotlin │ │ └── org │ │ └── rewedigital │ │ └── konversation │ │ ├── Part.kt │ │ ├── Reply.kt │ │ └── PartType.kt └── build.gradle ├── settings.gradle ├── LICENSE ├── dialogflowDemo └── Demo.kvs ├── file-formats.md ├── konversation.json ├── gradlew.bat ├── upload-cli.sh ├── .travis.yml └── Update-Guide.md /docs/runtime-shared/index.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /runtime-js/.gitignore: -------------------------------------------------------------------------------- 1 | build -------------------------------------------------------------------------------- /gradle-plugin/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /plugin-example/src/main/resources/example: -------------------------------------------------------------------------------- 1 | example -------------------------------------------------------------------------------- /runtime-js/src/main/javascript/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /MAINTAINERS: -------------------------------------------------------------------------------- 1 | René Kilczan -------------------------------------------------------------------------------- /cli/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | cachedPermutations 3 | Help.txt -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/index.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cli/src/test/resources/dub.kvs: -------------------------------------------------------------------------------- 1 | Copy: 2 | !I am a copy 3 | !i AM a CoPy -------------------------------------------------------------------------------- /runtime-js/src/main/javascript/.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | !index.js 3 | !runtime* 4 | !test/*.js -------------------------------------------------------------------------------- /cli-integrations/chocolatey/tools/chocolateyUninstall.ps1: -------------------------------------------------------------------------------- 1 | Uninstall-BinFile "konversation" -------------------------------------------------------------------------------- /travis_rsa.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rewe-digital/Konversation/HEAD/travis_rsa.enc -------------------------------------------------------------------------------- /cli/src/test/konversation/fail: -------------------------------------------------------------------------------- 1 | This file is for a test to ensure that no unrelated files are processed -------------------------------------------------------------------------------- /cli/src/test/resources/foo/ExampleIntent.kvs: -------------------------------------------------------------------------------- 1 | ExampleIntent: 2 | !How are you 3 | -I am fine 4 | [bye] -------------------------------------------------------------------------------- /cli/src/test/konversation/alexa/fail: -------------------------------------------------------------------------------- 1 | This file is for a test to ensure that no unrelated files are processed -------------------------------------------------------------------------------- /cli/src/test/resources/konversation/fail: -------------------------------------------------------------------------------- 1 | This file is for a test to ensure that no unrelated files are processed -------------------------------------------------------------------------------- /docs/shared/package-list: -------------------------------------------------------------------------------- 1 | $dokka.format:gfm 2 | $dokka.linkExtension:md 3 | 4 | org.rewedigital.konversation 5 | -------------------------------------------------------------------------------- /plugin-example/src/main/konversation/ExampleIntent.kvs: -------------------------------------------------------------------------------- 1 | ExampleIntent: 2 | !How are you 3 | -I am fine 4 | [bye] -------------------------------------------------------------------------------- /runtime-js/src/main/javascript/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require("./runtime.js").org.rewedigital.konversation; -------------------------------------------------------------------------------- /cli/src/test/resources/konversation-alexa/fail: -------------------------------------------------------------------------------- 1 | This file is for a test to ensure that no unrelated files are processed -------------------------------------------------------------------------------- /docs/runtime-js/package-list: -------------------------------------------------------------------------------- 1 | $dokka.format:gfm 2 | $dokka.linkExtension:md 3 | 4 | org.rewedigital.konversation 5 | -------------------------------------------------------------------------------- /docs/runtime-jvm/package-list: -------------------------------------------------------------------------------- 1 | $dokka.format:gfm 2 | $dokka.linkExtension:md 3 | 4 | org.rewedigital.konversation 5 | -------------------------------------------------------------------------------- /cli/src/test/resources/huge.grammar: -------------------------------------------------------------------------------- 1 | Test: 2 | {0|1|2|3|4|5|6|7|8|9}{0|1|2|3|4|5|6|7|8|9}{0|1|2|3|4|5|6|7|8|9} 3 | 4 | Foo: -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rewe-digital/Konversation/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /cli/src/test/resources/help.grammar: -------------------------------------------------------------------------------- 1 | Help: 2 | Hilf{e| mir| uns|e wie funktioniert die App} 3 | Wie {funktioniert|benutze ich} die{|se} App -------------------------------------------------------------------------------- /gradle-plugin/src/main/resources/META-INF/gradle-plugins/konversation.properties: -------------------------------------------------------------------------------- 1 | implementation-class=org.rewedigital.konversation.KonversationPlugin -------------------------------------------------------------------------------- /cli/src/test/konversation/pets.values: -------------------------------------------------------------------------------- 1 | {species1:cat|cats|kitt|kitten} 2 | {species2:dog|dogs|pup|pups|puppy|puppies} 3 | {species3:fish|fishes|carp|carps|eel|eels} -------------------------------------------------------------------------------- /cli/src/test/resources/konversation/colors.values: -------------------------------------------------------------------------------- 1 | {hex00f:blue|light blue|dark blue|baby blue} 2 | {hexf00:red|blood} 3 | {hex0f0:green} 4 | black 5 | {purple|violet} -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/Entities.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | data class Entities(val name: String, val values: List) -------------------------------------------------------------------------------- /gradle-plugin/src/main/resources/META-INF/gradle-plugins/com.rewedigital.voice.konversation.properties: -------------------------------------------------------------------------------- 1 | implementation-class=org.rewedigital.konversation.KonversationPlugin -------------------------------------------------------------------------------- /cli/src/test/konversation/animal-selection.kvs: -------------------------------------------------------------------------------- 1 | AnimalSelectionIntent: 2 | !My favorit animal is a {{species:pets}} 3 | !My favorit animal is a {{species:pets}} and {he|she|it} is called {{name}} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea/* 3 | local.properties 4 | build 5 | out 6 | *.iml 7 | travis_rsa 8 | publish 9 | cli-integrations/chocolatey/tools/*.jar 10 | cli-integrations/chocolatey/*.nupkg -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/Entity.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | data class Entity( 4 | val master: String, 5 | val key: String?, 6 | val synonyms: List) -------------------------------------------------------------------------------- /runtime-js/example.js: -------------------------------------------------------------------------------- 1 | const Konversation = require("konversation").Konversation; 2 | const test = new Konversation("test"); 3 | for (let i = 0; i < 10; i++) { 4 | console.log(test.createOutput()); 5 | } 6 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-math/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Math](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Math()` -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-part-impl/type.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartImpl](index.md) / [type](./type.md) 2 | 3 | # type 4 | 5 | `val type: ` -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/kotlin.collections.-iterable.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../index.md) / [org.rewedigital.konversation](index.md) / [kotlin.collections.Iterable](./kotlin.collections.-iterable.md) 2 | 3 | -------------------------------------------------------------------------------- /runtime-js/start-node.js: -------------------------------------------------------------------------------- 1 | const konversation = require("./runtime.js"); 2 | const test = new konversation.org.rewedigital.konversation.Konversation("test"); 3 | for (let i = 0; i < 10; i++) { 4 | console.log(test.createOutput()); 5 | } 6 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-adapter-factory/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AdapterFactory](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `AdapterFactory()` -------------------------------------------------------------------------------- /docs/shared/index.md: -------------------------------------------------------------------------------- 1 | [shared](./index.md) 2 | 3 | ### Packages 4 | 5 | | Name | Summary | 6 | |---|---| 7 | | [org.rewedigital.konversation](org.rewedigital.konversation/index.md) | | 8 | 9 | ### Index 10 | 11 | [All Types](alltypes/index.md) -------------------------------------------------------------------------------- /docs/runtime-js/index.md: -------------------------------------------------------------------------------- 1 | [runtime-js](./index.md) 2 | 3 | ### Packages 4 | 5 | | Name | Summary | 6 | |---|---| 7 | | [org.rewedigital.konversation](org.rewedigital.konversation/index.md) | | 8 | 9 | ### Index 10 | 11 | [All Types](alltypes/index.md) -------------------------------------------------------------------------------- /docs/runtime-jvm/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](./index.md) 2 | 3 | ### Packages 4 | 5 | | Name | Summary | 6 | |---|---| 7 | | [org.rewedigital.konversation](org.rewedigital.konversation/index.md) | | 8 | 9 | ### Index 10 | 11 | [All Types](alltypes/index.md) -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-reader/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reader](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Reader()` 6 | 7 | Helper class to read files. 8 | 9 | -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-part-type/-text.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartType](index.md) / [Text](./-text.md) 2 | 3 | # Text 4 | 5 | `Text` 6 | 7 | A Text block which should be spoken and displayed. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-reader/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reader](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Reader()` 6 | 7 | Helper class to read files. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-reader/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reader](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Reader()` 6 | 7 | Helper class to read files. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-part-impl-json-adapter/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartImplJsonAdapter](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `PartImplJsonAdapter(moshi: )` -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jan 14 08:16:47 CEST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-math/random.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Math](index.md) / [random](./random.md) 2 | 3 | # random 4 | 5 | `fun random(): `[`Double`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html) -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/require.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../index.md) / [org.rewedigital.konversation](index.md) / [require](./require.md) 2 | 3 | # require 4 | 5 | `external fun require(module: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): dynamic` -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-answer-impl-json-adapter/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AnswerImplJsonAdapter](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `AnswerImplJsonAdapter(moshi: )` -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-random/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [Random](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Random()` 6 | 7 | Java implementation for a random number generator. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-random/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Random](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Random()` 6 | 7 | JavaScript implementation for a random number generator. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-random/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Random](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Random()` 6 | 7 | Abstraction layer for a random number generator. 8 | 9 | -------------------------------------------------------------------------------- /runtime-jvm/src/test/resources/konversation/ApplyVariableTest.kson: -------------------------------------------------------------------------------- 1 | {"parts":[{"type":"Text","variants":["Hallo $planet. You are ${user.name}!"]},{"type":"VoiceOnly","variants":["And I know this age: %1.2f$age"]}],"suggestions":["Tell me more about $planet","Tell me more about ${user.name}"],"reprompts":{}} -------------------------------------------------------------------------------- /runtime-shared/src/main/kotlin/org/rewedigital/konversation/Extensions.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | fun Iterable.forEachIterator(block: Iterator.(element: T) -> Unit) { 4 | val iterator = iterator() 5 | while (iterator.hasNext()) block(iterator, iterator.next()) 6 | } -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-file-checker/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [FileChecker](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `FileChecker()` 6 | 7 | Helper tool to verify if the given file exists. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-file-checker/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [FileChecker](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `FileChecker()` 6 | 7 | Helper tool to verify if the given file exists. 8 | 9 | -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-part/type.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Part](index.md) / [type](./type.md) 2 | 3 | # type 4 | 5 | `abstract val type: `[`PartType`](../-part-type/index.md) 6 | 7 | The type of this part can be Text and VoiceOnly. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-file-checker/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [FileChecker](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `FileChecker()` 6 | 7 | Helper tool to verify if the given file exists. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-konversation/regex.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Konversation](index.md) / [regex](./regex.md) 2 | 3 | # regex 4 | 5 | `val regex: ` 6 | 7 | A regular expression to apply the actual values. 8 | 9 | -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-part-type/-voice-only.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartType](index.md) / [VoiceOnly](./-voice-only.md) 2 | 3 | # VoiceOnly 4 | 5 | `VoiceOnly` 6 | 7 | A voice only block which should be just spoken and never displayed. 8 | 9 | -------------------------------------------------------------------------------- /cli/src/test/konversation/annotations.kvs: -------------------------------------------------------------------------------- 1 | @Fallback 2 | FallbackIntent: 3 | 4 | @ListParameters("colors") 5 | @Event 6 | ColorIntent: 7 | ! Ich mag {{colors:color}} 8 | ! Ich mag die Farben {{colors:color}} 9 | 10 | NumberIntent: 11 | ! Ich denke an {{number}} 12 | 13 | @Event("Surprise") 14 | ExampleEvent: 15 | - Gut -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-konversation-js/-output-js/extras.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../../index.md) / [org.rewedigital.konversation](../../index.md) / [KonversationJs](../index.md) / [OutputJs](index.md) / [extras](./extras.md) 2 | 3 | # extras 4 | 5 | `val extras: dynamic` 6 | 7 | The strings for UI elements 8 | 9 | -------------------------------------------------------------------------------- /runtime-shared/src/main/kotlin/org/rewedigital/konversation/FileChecker.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * Helper tool to verify if the given file exists. 5 | */ 6 | expect class FileChecker() { 7 | /** Returns `true` if the file exists at the given path. */ 8 | fun exists(path: String): Boolean 9 | } -------------------------------------------------------------------------------- /runtime-shared/src/main/kotlin/org/rewedigital/konversation/Random.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * Abstraction layer for a random number generator. 5 | */ 6 | expect class Random() { 7 | /** 8 | * Returns a random number between 0 and [max]. 9 | */ 10 | fun next(max: Int): Int 11 | } -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-answer-impl/parts.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AnswerImpl](index.md) / [parts](./parts.md) 2 | 3 | # parts 4 | 5 | `val parts: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<>` -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-part-impl-json-adapter/to-string.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartImplJsonAdapter](index.md) / [toString](./to-string.md) 2 | 3 | # toString 4 | 5 | `fun toString(): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-answer-impl-json-adapter/to-string.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AnswerImplJsonAdapter](index.md) / [toString](./to-string.md) 2 | 3 | # toString 4 | 5 | `fun toString(): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) -------------------------------------------------------------------------------- /cli/src/test/resources/help-expected-alexa-result-minified.json: -------------------------------------------------------------------------------- 1 | {"interactionModel":{"languageModel":{"invocationName":"test","intents":[{"name":"Help","slots":[],"samples":["Hilfe","Hilf mir","Hilf uns","Hilfe wie funktioniert die App","Wie funktioniert die App","Wie funktioniert diese App","Wie benutze ich die App","Wie benutze ich diese App"]}],"types":[]}}} -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-environment/locale.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Environment](index.md) / [locale](./locale.md) 2 | 3 | # locale 4 | 5 | `val locale: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) 6 | 7 | The locale the for the output. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-formatter/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [Formatter](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Formatter()` 6 | 7 | Java implementation to format a string. This function just provides a platform specific `sprintf()` implementation. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-output/display-text.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Output](index.md) / [displayText](./display-text.md) 2 | 3 | # displayText 4 | 5 | `val displayText: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) 6 | 7 | The display test. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-formatter/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Formatter](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Formatter()` 6 | 7 | JavaScript implementation to format a string. This function just provides a platform specific `sprintf()` implementation. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-formatter/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Formatter](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Formatter()` 6 | 7 | Abstraction layer to format a string. This function just provides a platform specific `sprintf()` implementation. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-output/ssml.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Output](index.md) / [ssml](./ssml.md) 2 | 3 | # ssml 4 | 5 | `val ssml: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) 6 | 7 | The Speech Synthesis Markup Language, the spoken output. 8 | 9 | -------------------------------------------------------------------------------- /runtime-jvm/src/main/kotlin/org/rewedigital/konversation/FileChecker.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * Helper tool to verify if the given file exists. 5 | */ 6 | actual class FileChecker { 7 | /** Returns `true` if the file exists at the given path. */ 8 | actual fun exists(path: String): Boolean = javaClass.getResource("/$path") != null 9 | } -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-konversation-js/-output-js/reprompts.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../../index.md) / [org.rewedigital.konversation](../../index.md) / [KonversationJs](../index.md) / [OutputJs](index.md) / [reprompts](./reprompts.md) 2 | 3 | # reprompts 4 | 5 | `val reprompts: dynamic` 6 | 7 | The reprompts which should the user hear when the user gives no input. 8 | 9 | -------------------------------------------------------------------------------- /runtime-js/src/test/javascript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kotlin-tests", 3 | "version": "1.0.0", 4 | "description": "This is just a helper to run the tests via gradle", 5 | "main": "node-test.js", 6 | "scripts": { 7 | "test": "mocha" 8 | }, 9 | "author": "René Kilczan", 10 | "license": "MIT", 11 | "dependencies": { 12 | "mocha": "^5.2.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /cli-integrations/chocolatey/tools/chocolateyInstall.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = 'Stop' # Recommended to use, so the script will stop if there is a problem 2 | $toolsDir = Split-Path $MyInvocation.MyCommand.Definition 3 | 4 | "@java -jar $toolsDir\konversation.jar %*" | out-file -encoding ASCII "$toolsDir\konversation.bat" 5 | Install-BinFile -Name "konversation" -Path "$toolsDir\konversation.bat" -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-environment/platform.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Environment](index.md) / [platform](./platform.md) 2 | 3 | # platform 4 | 5 | `val platform: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) 6 | 7 | The platform for the reply should be optimized. 8 | 9 | -------------------------------------------------------------------------------- /.travis/deploy_chocolaty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | version=`git describe --tags|cut -d- -f 2-` 3 | 4 | cp publish/konversation.jar tools/konversation.jar 5 | cd cli-integrations/chocolatey 6 | docker run --rm -v $PWD:$PWD -w $PWD linuturk/mono-choco pack 7 | docker run --rm -v $PWD:$PWD -w $PWD linuturk/mono-choco push --key ${chocolatey_key} konversation.${version}.nupkg --source https://push.chocolatey.org/ -------------------------------------------------------------------------------- /.travis/configure_jvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | VERSION=`git describe --tags|cut -d- -f 2-` 3 | 4 | echo Updating version numbers... 5 | sed -i -E "s/JVM runtime version is [0-9][^]\"]+/JVM runtime version is $VERSION/g" docs/index.md 6 | git add docs/index.md 7 | 8 | sed -i -e "s/versions.runtime_jvm = '.*'/versions.runtime_jvm = '$VERSION'/g" build.gradle 9 | git add build.gradle 10 | 11 | sed -i '' publish/* -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-part-impl-json-adapter/from-json.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartImplJsonAdapter](index.md) / [fromJson](./from-json.md) 2 | 3 | # fromJson 4 | 5 | `fun fromJson(reader: ): `[`PartImpl`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-part-impl/index.md) -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-reply/parts.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reply](index.md) / [parts](./parts.md) 2 | 3 | # parts 4 | 5 | `open val parts: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`Part`](../-part/index.md)`>` 6 | 7 | The parts of the response which should be build. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-konversation-js/-output-js/display-text.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../../index.md) / [org.rewedigital.konversation](../../index.md) / [KonversationJs](../index.md) / [OutputJs](index.md) / [displayText](./display-text.md) 2 | 3 | # displayText 4 | 5 | `val displayText: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) 6 | 7 | The display test. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-konversation-js/-output-js/ssml.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../../index.md) / [org.rewedigital.konversation](../../index.md) / [KonversationJs](../index.md) / [OutputJs](index.md) / [ssml](./ssml.md) 2 | 3 | # ssml 4 | 5 | `val ssml: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) 6 | 7 | The Speech Synthesis Markup Language, the spoken output. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-part-impl/variants.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartImpl](index.md) / [variants](./variants.md) 2 | 3 | # variants 4 | 5 | `val variants: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` -------------------------------------------------------------------------------- /runtime-shared/src/main/kotlin/org/rewedigital/konversation/Environment.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * The environment holds data about the environment where is voice application is running. 5 | */ 6 | data class Environment( 7 | /** The platform for the reply should be optimized. */ 8 | val platform: String, 9 | /** The locale the for the output. */ 10 | val locale: String) -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-answer-impl-json-adapter/from-json.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AnswerImplJsonAdapter](index.md) / [fromJson](./from-json.md) 2 | 3 | # fromJson 4 | 5 | `fun fromJson(reader: ): `[`AnswerImpl`](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-answer-impl/index.md) -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-answer-impl/suggestions.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AnswerImpl](index.md) / [suggestions](./suggestions.md) 2 | 3 | # suggestions 4 | 5 | `val suggestions: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` -------------------------------------------------------------------------------- /docs/runtime-shared/package-list: -------------------------------------------------------------------------------- 1 | $dokka.format:gfm 2 | $dokka.linkExtension:md 3 | $dokka.location:org.rewedigital.konversation$forEachIterator(kotlin.collections.Iterable((org.rewedigital.konversation.forEachIterator.T)), kotlin.Function2((kotlin.collections.Iterator((org.rewedigital.konversation.forEachIterator.T)), , kotlin.Unit)))org.rewedigital.konversation/kotlin.collections.-iterable/for-each-iterator.md 4 | org.rewedigital.konversation 5 | -------------------------------------------------------------------------------- /runtime-js/src/test/javascript/example.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const Konversation = require("@rewe-digital/konversation").Konversation; 3 | describe('Konversation', function() { 4 | // describe('#indexOf()', function() { 5 | it('should load data', function() { 6 | //assert.equal([1,2,3].indexOf(4), -1); 7 | const test = new Konversation("test"); 8 | }); 9 | // }); 10 | }); 11 | -------------------------------------------------------------------------------- /docu.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'org.jetbrains.dokka' 2 | 3 | dokka { 4 | outputFormat = 'gfm' 5 | outputDirectory = "$rootDir/docs" 6 | jdkVersion = 8 7 | includeNonPublic = false 8 | reportUndocumented = true 9 | 10 | linkMapping { 11 | dir = "src/main/kotlin" 12 | url = "https://github.com/rewe-digital/${rootProject.name}/blob/master/$moduleName/src/main/kotlin" 13 | suffix = "#L" 14 | } 15 | } -------------------------------------------------------------------------------- /runtime-shared/src/main/kotlin/org/rewedigital/konversation/Reader.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * Helper class to read files. 5 | */ 6 | expect class Reader() { 7 | /** 8 | * Loads a reply for a given environment. 9 | * @param name The name of the reply. 10 | * @param environment The environment of the reply. 11 | */ 12 | fun loadReply(name: String, environment: Environment) : Reply 13 | } -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-konversation/random.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Konversation](index.md) / [random](./random.md) 2 | 3 | # random 4 | 5 | `val random: `[`Random`](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-random/index.md) 6 | 7 | The randomness implementation which can be modified for testing. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-part-impl/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartImpl](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `PartImpl(variants: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>, type: )` -------------------------------------------------------------------------------- /runtime-js/src/test/kotlin/org/rewedigital/konversation/KonversationJsTest.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import kotlin.test.Test 4 | 5 | class KonversationJsTest { 6 | @Test 7 | fun bla() { 8 | val konversation = KonversationJs("Help", Environment(platform = "", locale = "")) 9 | val output = konversation.createJavaScriptOutput(JSON.parse("""{"a":1, "b":"bb"}""")) 10 | println(output) 11 | } 12 | } -------------------------------------------------------------------------------- /cli/src/test/resources/konversation-en/help.kvs: -------------------------------------------------------------------------------- 1 | Help: 2 | !Help {|me|us|how does this app work} 3 | !How {works|do I use} this App 4 | -You can use this app to 5 | -With this app you can 6 | + 7 | -{read|hear} 8 | + 9 | -recipes and offers. 10 | -offers and recipes. 11 | + 12 | ~Cool isn't it? 13 | + 14 | ~How should {we|I} continue now? 15 | ~What should {we|I} do now? 16 | ?1 How can I help you{| now}? 17 | ?2 What should {I|we} do now? 18 | [Offers] [Recipes] -------------------------------------------------------------------------------- /cli/src/test/kotlin/org/rewedigital/konversation/TestHelper.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import kotlin.test.asserter 4 | 5 | /** Asserts that the [expected] value is equal to the [actual] value, with an optional [message], ignoring line breaks. */ 6 | fun assertEqualsIgnoringLineBreaks(expected: String, actual: String, message: String? = null) { 7 | asserter.assertEquals(message, expected.filterNot { it == '\r' }, actual.filterNot { it == '\r' }) 8 | } -------------------------------------------------------------------------------- /plugin-example/src/main/kotlin/org/rewedigital/example/Example.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.example 2 | 3 | import org.rewedigital.konversation.Environment 4 | import org.rewedigital.konversation.Konversation 5 | 6 | class Example { 7 | companion object { 8 | @JvmStatic 9 | fun main(args: Array) { 10 | println(Konversation("ExampleIntent", Environment("example", "DE-de")).createOutput().displayText) 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-file-checker/exists.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [FileChecker](index.md) / [exists](./exists.md) 2 | 3 | # exists 4 | 5 | `actual fun exists(path: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) 6 | 7 | Returns `true` if the file exists at the given path. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-file-checker/exists.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [FileChecker](index.md) / [exists](./exists.md) 2 | 3 | # exists 4 | 5 | `actual fun exists(path: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) 6 | 7 | Returns `true` if the file exists at the given path. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-file-checker/exists.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [FileChecker](index.md) / [exists](./exists.md) 2 | 3 | # exists 4 | 5 | `fun exists(path: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) 6 | 7 | Returns `true` if the file exists at the given path. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-output/plus.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Output](index.md) / [plus](./plus.md) 2 | 3 | # plus 4 | 5 | `operator fun plus(output: `[`Output`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-output/index.md)`): `[`Output`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-output/index.md) -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-part-impl-json-adapter/to-json.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartImplJsonAdapter](index.md) / [toJson](./to-json.md) 2 | 3 | # toJson 4 | 5 | `fun toJson(writer: , value: `[`PartImpl`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-part-impl/index.md)`?): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-output/suggestions.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Output](index.md) / [suggestions](./suggestions.md) 2 | 3 | # suggestions 4 | 5 | `val suggestions: `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` 6 | 7 | The list of suggestions which should been displayed. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-konversation-js/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [KonversationJs](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `KonversationJs(name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, environment: dynamic)` 6 | 7 | This class is the interop layer to use just primitiv values. Lists will be converted to Arrays and Maps to simple objects. 8 | 9 | -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-reply/suggestions.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reply](index.md) / [suggestions](./suggestions.md) 2 | 3 | # suggestions 4 | 5 | `open val suggestions: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` 6 | 7 | The suggestions which are used in context of the runtime. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-answer-impl-json-adapter/to-json.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AnswerImplJsonAdapter](index.md) / [toJson](./to-json.md) 2 | 3 | # toJson 4 | 5 | `fun toJson(writer: , value: `[`AnswerImpl`](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-answer-impl/index.md)`?): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) -------------------------------------------------------------------------------- /cli/src/test/resources/help.kvs: -------------------------------------------------------------------------------- 1 | Help: 2 | !Hilf{e| mir| uns|e wie funktioniert die App} 3 | !Wie {funktioniert|benutze ich} die{|se} App 4 | -Du kannst mit dieser App 5 | -Mit dieser App kannst du 6 | + 7 | -Rezepte und Angebote 8 | -Angebote und Rezepte 9 | + 10 | -{anhören|vorlesen lassen}. 11 | ~Cool nicht wahr? 12 | + 13 | ~Womit soll{en wir| ich} weiter machen? 14 | ~Was möchtest du jetzt tun? 15 | 16 | ?1 Kann ich dir {|jetzt} noch helfen? 17 | ?2 Womit sollen wir weitermachen? 18 | [Angebote] [Rezepte] -------------------------------------------------------------------------------- /cli/src/test/konversation/help.kvs: -------------------------------------------------------------------------------- 1 | Help: 2 | !Hilf{e| mir| uns|e wie funktioniert die App} 3 | !Wie {funktioniert|benutze ich} die{|se} App 4 | -Du kannst mit dieser App 5 | -Mit dieser App kannst du 6 | + 7 | -Rezepte und Angebote 8 | -Angebote und Rezepte 9 | + 10 | -{anhören|vorlesen lassen}. 11 | ~Cool nicht wahr? 12 | + 13 | ~Womit soll{en wir| ich} weiter machen? 14 | ~Was möchtest du jetzt tun? 15 | 16 | ?1 Kann ich dir {|jetzt} noch helfen? 17 | ?2 Womit sollen wir weitermachen? 18 | [Angebote] [Rezepte] -------------------------------------------------------------------------------- /cli/src/test/konversation/alexa/help.kvs: -------------------------------------------------------------------------------- 1 | Help: 2 | !Hilf{e| mir| uns|e wie funktioniert die App} 3 | !Wie {funktioniert|benutze ich} die{|se} App 4 | -Du kannst mit dieser App 5 | -Mit dieser App kannst du 6 | + 7 | -Rezepte und Angebote 8 | -Angebote und Rezepte 9 | + 10 | -{anhören|vorlesen lassen}. 11 | ~Cool nicht wahr? 12 | + 13 | ~Womit soll{en wir| ich} weiter machen? 14 | ~Was möchtest du jetzt tun? 15 | 16 | ?1 Kann ich dir {|jetzt} noch helfen? 17 | ?2 Womit sollen wir weitermachen? 18 | [Angebote] [Rezepte] -------------------------------------------------------------------------------- /cli/src/test/konversation/en/help.kvs: -------------------------------------------------------------------------------- 1 | Help: 2 | !Hilf{e| mir| uns|e wie funktioniert die App} 3 | !Wie {funktioniert|benutze ich} die{|se} App 4 | -Du kannst mit dieser App 5 | -Mit dieser App kannst du 6 | + 7 | -Rezepte und Angebote 8 | -Angebote und Rezepte 9 | + 10 | -{anhören|vorlesen lassen}. 11 | ~Cool nicht wahr? 12 | + 13 | ~Womit soll{en wir| ich} weiter machen? 14 | ~Was möchtest du jetzt tun? 15 | 16 | ?1 Kann ich dir {|jetzt} noch helfen? 17 | ?2 Womit sollen wir weitermachen? 18 | [Angebote] [Rezepte] -------------------------------------------------------------------------------- /cli/src/test/konversation/alexa/de/help.kvs: -------------------------------------------------------------------------------- 1 | Help: 2 | !Hilf{e| mir| uns|e wie funktioniert die App} 3 | !Wie {funktioniert|benutze ich} die{|se} App 4 | -Du kannst mit dieser App 5 | -Mit dieser App kannst du 6 | + 7 | -Rezepte und Angebote 8 | -Angebote und Rezepte 9 | + 10 | -{anhören|vorlesen lassen}. 11 | ~Cool nicht wahr? 12 | + 13 | ~Womit soll{en wir| ich} weiter machen? 14 | ~Was möchtest du jetzt tun? 15 | 16 | ?1 Kann ich dir {|jetzt} noch helfen? 17 | ?2 Womit sollen wir weitermachen? 18 | [Angebote] [Rezepte] -------------------------------------------------------------------------------- /cli/src/test/resources/konversation/help.kvs: -------------------------------------------------------------------------------- 1 | Help: 2 | !Hilf{e| mir| uns|e wie funktioniert die App} 3 | !Wie {funktioniert|benutze ich} die{|se} App 4 | -Du kannst mit dieser App 5 | -Mit dieser App kannst du 6 | + 7 | -Rezepte und Angebote 8 | -Angebote und Rezepte 9 | + 10 | -{anhören|vorlesen lassen}. 11 | ~Cool nicht wahr? 12 | + 13 | ~Womit soll{en wir| ich} weiter machen? 14 | ~Was möchtest du jetzt tun? 15 | 16 | ?1 Kann ich dir {|jetzt} noch helfen? 17 | ?2 Womit sollen wir weitermachen? 18 | [Angebote] [Rezepte] -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-output/extras.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Output](index.md) / [extras](./extras.md) 2 | 3 | # extras 4 | 5 | `val extras: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` 6 | 7 | The strings for UI elements 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-konversation-js/-output-js/suggestions.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../../index.md) / [org.rewedigital.konversation](../../index.md) / [KonversationJs](../index.md) / [OutputJs](index.md) / [suggestions](./suggestions.md) 2 | 3 | # suggestions 4 | 5 | `val suggestions: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` 6 | 7 | The list of suggestions which should been displayed. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-math/index.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Math](./index.md) 2 | 3 | # Math 4 | 5 | `external class Math` 6 | 7 | ### Constructors 8 | 9 | | Name | Summary | 10 | |---|---| 11 | | [<init>](-init-.md) | `Math()` | 12 | 13 | ### Companion Object Functions 14 | 15 | | Name | Summary | 16 | |---|---| 17 | | [random](random.md) | `fun random(): `[`Double`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html) | 18 | -------------------------------------------------------------------------------- /cli/src/test/resources/konversation-alexa/help.kvs: -------------------------------------------------------------------------------- 1 | Help: 2 | !Hilf{e| mir| uns|e wie funktioniert dieser Skill} 3 | !Wie {funktioniert|benutze ich} die{|se} Skill 4 | -Du kannst mit dieser Skill 5 | -Mit dieser Skill kannst du 6 | + 7 | -Rezepte und Angebote 8 | -Angebote und Rezepte 9 | + 10 | -{anhören|vorlesen lassen}. 11 | ~Cool nicht wahr? 12 | + 13 | ~Womit soll{en wir| ich} weiter machen? 14 | ~Was möchtest du jetzt tun? 15 | 16 | ?1 Kann ich dir {|jetzt} noch helfen? 17 | ?2 Womit sollen wir weitermachen? 18 | [Angebote] [Rezepte] -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-environment/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Environment](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Environment(platform: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, locale: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` 6 | 7 | The environment holds data about the environment where is voice application is running. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-konversation/name.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Konversation](index.md) / [name](./name.md) 2 | 3 | # name 4 | 5 | `val name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) 6 | 7 | The conversation name you want to load. 8 | 9 | ### Property 10 | 11 | `name` - The conversation name you want to load. 12 | 13 | ### Parameters 14 | 15 | `environment` - The environment of the conversation to load. -------------------------------------------------------------------------------- /.travis/configure_js.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | VERSION=`git describe --tags|cut -d- -f 2-` 3 | 4 | echo Updating version numbers... 5 | sed -i -e "s/\"version\": \".*\"/\"version\": \"$VERSION\"/g" runtime-js/src/main/javascript/package.json 6 | git add runtime-js/src/main/javascript/package.json 7 | 8 | sed -i -E "s/JS runtime version is [0-9][^]\"]+/JS runtime version is $VERSION/g" docs/index.md 9 | git add docs/index.md 10 | 11 | sed -i -e "s/versions.runtime_js = '.*'/versions.runtime_js = '$VERSION'/g" build.gradle 12 | git add build.gradle -------------------------------------------------------------------------------- /cli/src/test/resources/konversation-alexa-de/help.kvs: -------------------------------------------------------------------------------- 1 | Help: 2 | !Hilf{e| mir| uns|e wie funktioniert dieser Skill} 3 | !Wie {funktioniert|benutze ich} die{|se} Skill 4 | -Du kannst mit dieser Skill 5 | -Mit dieser Skill kannst du 6 | + 7 | -Rezepte und Angebote 8 | -Angebote und Rezepte 9 | + 10 | -{anhören|vorlesen lassen}. 11 | ~Cool nicht wahr? 12 | + 13 | ~Womit soll{en wir| ich} weiter machen? 14 | ~Was möchtest du jetzt tun? 15 | 16 | ?1 Kann ich dir {|jetzt} noch helfen? 17 | ?2 Womit sollen wir weitermachen? 18 | [Angebote] [Rezepte] -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-part/variants.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Part](index.md) / [variants](./variants.md) 2 | 3 | # variants 4 | 5 | `abstract val variants: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` 6 | 7 | The variants for this part. Please make sure that there are no grammatical issues when you use another alternative. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-reader/load-reply.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reader](index.md) / [loadReply](./load-reply.md) 2 | 3 | # loadReply 4 | 5 | `actual fun loadReply(name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, environment: ): ` 6 | 7 | Loads a reply for a given environment. 8 | 9 | ### Parameters 10 | 11 | `name` - The name of the reply. 12 | 13 | `environment` - The environment of the reply. -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-reader/load-reply.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reader](index.md) / [loadReply](./load-reply.md) 2 | 3 | # loadReply 4 | 5 | `actual fun loadReply(name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, environment: ): ` 6 | 7 | Loads a reply for a given environment. 8 | 9 | ### Parameters 10 | 11 | `name` - The name of the reply. 12 | 13 | `environment` - The environment of the reply. -------------------------------------------------------------------------------- /runtime-jvm/src/test/resources/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "parts": [ 3 | { 4 | "option": [ 5 | "hallo", 6 | "hi", 7 | "hey" 8 | ], 9 | "type": "Text" 10 | }, 11 | { 12 | "option": [ 13 | "hier siehst du einen dynamischen Dialog.", 14 | "das ist ein zufälliger Dialog", 15 | "dynamische Texte sind cool" 16 | ], 17 | "type": "Text" 18 | } 19 | ], 20 | "suggestions": [ 21 | { 22 | "label": "Hallo", 23 | "data": "0123" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-random/next.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [Random](index.md) / [next](./next.md) 2 | 3 | # next 4 | 5 | `actual fun next(max: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`): `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) 6 | 7 | Returns a random number between 0 and [max](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-random/next/max.md). 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-random/next.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Random](index.md) / [next](./next.md) 2 | 3 | # next 4 | 5 | `fun next(max: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`): `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) 6 | 7 | Returns a random number between 0 and [max](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-random/next/max.md). 8 | 9 | -------------------------------------------------------------------------------- /runtime-jvm/src/main/kotlin/org/rewedigital/konversation/Random.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import java.util.Random 4 | 5 | /** 6 | * Java implementation for a random number generator. 7 | */ 8 | actual class Random actual constructor() { 9 | /** 10 | * Returns a random number between 0 and [max]. 11 | */ 12 | actual fun next(max: Int): Int = forcedValue ?: Random().nextInt(max) 13 | 14 | companion object { 15 | // Just for testing! 16 | internal var forcedValue: Int? = null 17 | } 18 | } -------------------------------------------------------------------------------- /runtime-js/start-browser.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Konversation 6 | 7 | 8 | 9 | 10 | 16 | 17 | -------------------------------------------------------------------------------- /shared/src/main/kotlin/org/rewedigital/konversation/Part.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * One part of the [Reply] for the user. There can be two types: Text and VoiceOnly. The runtime will contact the parts and add separators (spaces). 5 | */ 6 | interface Part { 7 | /** The variants for this part. Please make sure that there are no grammatical issues when you use another alternative. */ 8 | val variants: MutableList 9 | /** The type of this part can be Text and VoiceOnly. */ 10 | val type: PartType 11 | } -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-random/next.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Random](index.md) / [next](./next.md) 2 | 3 | # next 4 | 5 | `actual fun next(max: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`): `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) 6 | 7 | Returns a random number between 0 and [max](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-random/next/max.md). 8 | 9 | -------------------------------------------------------------------------------- /plugin-example/src/main/konversation/help.kvs: -------------------------------------------------------------------------------- 1 | Help: 2 | !Hilf{e| mir| uns|e wie funktioniert die App} 3 | !Wie {funktioniert|benutze ich} die{|se} App 4 | -Du kannst mit dieser App 5 | -Mit dieser App kannst du 6 | + 7 | -Rezepte und Angebote 8 | -Angebote und Rezepte 9 | + 10 | -{anhören|vorlesen lassen}. 11 | ~Cool nicht wahr? 12 | + 13 | ~Womit soll{en wir| ich} weiter machen? 14 | ~Was möchtest du jetzt tun? 15 | 16 | ?1 Kann ich dir {|jetzt} noch helfen? 17 | ?2 Womit sollen wir weitermachen? 18 | [Angebote] [Rezepte] 19 | 20 | Hello: 21 | -Läuft bei {dir|euch} -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-output/reprompts.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Output](index.md) / [reprompts](./reprompts.md) 2 | 3 | # reprompts 4 | 5 | `val reprompts: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` 6 | 7 | The reprompts which should the user hear when the user gives no input. 8 | 9 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-adapter-factory/create.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AdapterFactory](index.md) / [create](./create.md) 2 | 3 | # create 4 | 5 | `fun create(type: `[`Type`](http://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html)`?, annotations: `[`MutableSet`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)`?, moshi: ): >?` -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-answer-impl/reprompts.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AnswerImpl](index.md) / [reprompts](./reprompts.md) 2 | 3 | # reprompts 4 | 5 | `val reprompts: `[`MutableMap`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>>` -------------------------------------------------------------------------------- /cli/src/test/resources/help-expected-kson-result-minified.json: -------------------------------------------------------------------------------- 1 | {"parts":[{"type":"Text","variants":["Du kannst mit dieser App","Mit dieser App kannst du"]},{"type":"Text","variants":["Rezepte und Angebote","Angebote und Rezepte"]},{"type":"Text","variants":["anhören.","vorlesen lassen."]},{"type":"VoiceOnly","variants":["Cool nicht wahr?"]},{"type":"VoiceOnly","variants":["Womit sollen wir weiter machen?","Womit soll ich weiter machen?","Was möchtest du jetzt tun?"]}],"suggestions":["Angebote","Rezepte"],"reprompts":{"1":["Kann ich dir noch helfen?","Kann ich dir jetzt noch helfen?"],"2":["Womit sollen wir weitermachen?"]}} -------------------------------------------------------------------------------- /runtime-js/src/main/resources/test.kson: -------------------------------------------------------------------------------- 1 | { 2 | "parts": [ 3 | { 4 | "type": "Text", 5 | "variants": [ 6 | "Deine Liste ist leer.", 7 | "Du hast keine Einträge auf deiner Einkaufsliste.", 8 | "Auf deiner Einkaufsliste steht noch nichts." 9 | ] 10 | }, 11 | { 12 | "type": "VoiceOnly", 13 | "variants": [ 14 | "Du kannst aber Zutaten aus den Rezepten oder Angebote zur Einkaufsliste hinzufügen. Versuch's doch mal damit.", 15 | "Du kannst sie aber mit Rezeptzutaten oder Angeboten befüllen. Versuch's gleich mal." 16 | ] 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /runtime-jvm/src/test/resources/test.kson: -------------------------------------------------------------------------------- 1 | { 2 | "parts": [ 3 | { 4 | "type": "Text", 5 | "variants": [ 6 | "Deine Liste ist leer.", 7 | "Du hast keine Einträge auf deiner Einkaufsliste.", 8 | "Auf deiner Einkaufsliste steht noch nichts." 9 | ] 10 | }, 11 | { 12 | "type": "VoiceOnly", 13 | "variants": [ 14 | "Du kannst aber Zutaten aus den Rezepten oder Angebote zur Einkaufsliste hinzufügen. Versuch's doch mal damit.", 15 | "Du kannst sie aber mit Rezeptzutaten oder Angeboten befüllen. Versuch's gleich mal." 16 | ] 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-konversation/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Konversation](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Konversation(name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, environment: `[`Environment`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-environment/index.md)`)` 6 | 7 | Creates a new Konversation object with the given options. 8 | 9 | **Constructor** 10 | Creates a new Konversation object with the given options. 11 | 12 | -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-reply/reprompts.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reply](index.md) / [reprompts](./reprompts.md) 2 | 3 | # reprompts 4 | 5 | `open val reprompts: `[`MutableMap`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>>` 6 | 7 | The reprompts which are used in context of the runtime. 8 | 9 | -------------------------------------------------------------------------------- /runtime-js/src/main/kotlin/org/rewedigital/konversation/Random.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * JavaScript implementation for a random number generator. 5 | */ 6 | actual class Random { 7 | /** 8 | * Returns a random number between 0 and [max]. 9 | */ 10 | actual fun next(max: Int): Int = forcedValue ?: (Math.random() * max).toInt() 11 | 12 | companion object { 13 | // Just for testing! 14 | @JsName("forcedValue") 15 | internal var forcedValue: Int? = null 16 | } 17 | } 18 | 19 | internal external class Math { 20 | companion object { 21 | fun random(): Double 22 | } 23 | } -------------------------------------------------------------------------------- /cli/src/test/resources/help-expected-alexa-result.json: -------------------------------------------------------------------------------- 1 | { 2 | "interactionModel": { 3 | "languageModel": { 4 | "invocationName": "test", 5 | "intents": [ 6 | { 7 | "name": "Help", 8 | "slots": [], 9 | "samples": [ 10 | "Hilfe", 11 | "Hilf mir", 12 | "Hilf uns", 13 | "Hilfe wie funktioniert die App", 14 | "Wie funktioniert die App", 15 | "Wie funktioniert diese App", 16 | "Wie benutze ich die App", 17 | "Wie benutze ich diese App" 18 | ] 19 | } 20 | ], 21 | "types": [] 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-reader/load-reply.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reader](index.md) / [loadReply](./load-reply.md) 2 | 3 | # loadReply 4 | 5 | `fun loadReply(name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, environment: `[`Environment`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-environment/index.md)`): ` 6 | 7 | Loads a reply for a given environment. 8 | 9 | ### Parameters 10 | 11 | `name` - The name of the reply. 12 | 13 | `environment` - The environment of the reply. -------------------------------------------------------------------------------- /runtime-shared/src/main/kotlin/org/rewedigital/konversation/Formatter.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * Abstraction layer to format a string. This function just provides a platform specific `sprintf()` implementation. 5 | */ 6 | expect class Formatter() { 7 | /** 8 | * Uses the provided [format] as a format string and returns a string obtained by substituting the specified arguments, 9 | * using the locale of the environment. 10 | * 11 | * @param format The string to format 12 | * @param args The arguments you want to apply. 13 | */ 14 | fun format(locale: String, format: String, vararg args: Any?): String 15 | } -------------------------------------------------------------------------------- /shared/src/main/kotlin/org/rewedigital/konversation/Reply.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * Each Reply contains multiple [Part]s, suggestions and reprompts. The parts can be for the display or just for the audio output. 5 | */ 6 | open class Reply( 7 | /** The parts of the response which should be build. */ 8 | open val parts: MutableList = mutableListOf(), 9 | /** The suggestions which are used in context of the runtime. */ 10 | open val suggestions: MutableList = mutableListOf(), 11 | /** The reprompts which are used in context of the runtime. */ 12 | open val reprompts: MutableMap> = mutableMapOf()) -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/LoggerFacade.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | interface LoggerFacade { 4 | fun log(msg: String = "") 5 | fun debug(msg: String = "") 6 | fun info(msg: String = "") 7 | fun error(msg: String = "") 8 | fun warn(msg: String = "") 9 | } 10 | 11 | class DefaultLogger : LoggerFacade { 12 | override fun log(msg: String) = println(msg) 13 | 14 | override fun debug(msg: String) = println(msg) 15 | 16 | override fun info(msg: String) = println(msg) 17 | 18 | override fun error(msg: String) = System.err.println(msg) 19 | 20 | override fun warn(msg: String) = System.err.println("WARNING: $msg") 21 | } -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-reader/index.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reader](./index.md) 2 | 3 | # Reader 4 | 5 | `actual class Reader` 6 | 7 | Helper class to read files. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Reader()`
Helper class to read files. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [loadReply](load-reply.md) | `actual fun loadReply(name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, environment: ): `
Loads a reply for a given environment. | 20 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-reader/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reader](./index.md) 2 | 3 | # Reader 4 | 5 | `actual class Reader` 6 | 7 | Helper class to read files. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Reader()`
Helper class to read files. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [loadReply](load-reply.md) | `actual fun loadReply(name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, environment: ): `
Loads a reply for a given environment. | 20 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-konversation-js/-output-js/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../../index.md) / [org.rewedigital.konversation](../../index.md) / [KonversationJs](../index.md) / [OutputJs](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `OutputJs(output: )` 6 | `OutputJs(displayText: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, ssml: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, reprompts: dynamic, suggestions: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>, extras: dynamic)` -------------------------------------------------------------------------------- /runtime-jvm/src/main/kotlin/org/rewedigital/konversation/Answer.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import com.squareup.moshi.JsonClass 4 | 5 | @JsonClass(generateAdapter = true) 6 | internal class AnswerImpl( 7 | override val parts: MutableList = mutableListOf(), 8 | override val suggestions: MutableList = mutableListOf(), 9 | override val reprompts: MutableMap> = mutableMapOf()) : Reply(parts, suggestions, reprompts) 10 | 11 | @JsonClass(generateAdapter = true) 12 | // TODO find a trick to make it internal and visible for the parser 13 | data class PartImpl(override val variants: MutableList, 14 | override val type: PartType) : Part -------------------------------------------------------------------------------- /runtime-jvm/src/main/kotlin/org/rewedigital/konversation/AdapterFactory.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import com.squareup.moshi.JsonAdapter 4 | import com.squareup.moshi.JsonAdapter.Factory 5 | import com.squareup.moshi.Moshi 6 | import java.lang.reflect.Type 7 | 8 | /** 9 | * [Factory] for [Moshi] to create instances of [Reply] and [Part]. 10 | */ 11 | internal class AdapterFactory : Factory { 12 | override fun create(type: Type?, annotations: MutableSet?, moshi: Moshi): JsonAdapter<*>? = 13 | when (type) { 14 | Reply::class.java -> AnswerImplJsonAdapter(moshi) 15 | Part::class.java -> PartImplJsonAdapter(moshi) 16 | else -> null 17 | } 18 | } -------------------------------------------------------------------------------- /runtime-js/src/main/kotlin/org/rewedigital/konversation/Answer.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * The internal implementation of a concrete reply. 5 | */ 6 | internal class ReplyImpl(json: dynamic) : org.rewedigital.konversation.Reply((json.parts as Array).map { PartImpl(it) }.toMutableList()) 7 | 8 | /** 9 | * The internal implementation of a concrete part. 10 | */ 11 | internal data class PartImpl(override val variants: MutableList, 12 | override val type: PartType) : Part { 13 | // small hack since an array cannot be converted to a list automatically 14 | constructor(json: dynamic) : this((json.variants as Array).toMutableList(), PartType.valueOf(json.type as String)) 15 | } -------------------------------------------------------------------------------- /plugin-example/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.jetbrains.kotlin.jvm' version '1.3.31' 3 | id 'org.rewedigital.konversation' version '1.0-beta1' 4 | } 5 | 6 | apply plugin: 'kotlin' 7 | 8 | repositories { 9 | jcenter() 10 | } 11 | 12 | dependencies { 13 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 14 | compile "org.jetbrains.kotlin:kotlin-stdlib" 15 | compile project(':runtime-jvm') 16 | } 17 | 18 | sourceSets { 19 | main.java.srcDirs += 'src/main/kotlin/' 20 | test.java.srcDirs += 'src/test/kotlin/' 21 | } 22 | 23 | compileKotlin { 24 | kotlinOptions.jvmTarget = "1.8" 25 | } 26 | compileTestKotlin { 27 | kotlinOptions.jvmTarget = "1.8" 28 | } 29 | 30 | konversation { 31 | invocationName = "test" 32 | } -------------------------------------------------------------------------------- /runtime-jvm/src/main/kotlin/org/rewedigital/konversation/Formatter.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import java.util.* 4 | 5 | /** 6 | * Java implementation to format a string. This function just provides a platform specific `sprintf()` implementation. 7 | */ 8 | actual class Formatter { 9 | /** 10 | * Uses the provided [format] as a format string and returns a string obtained by substituting the specified arguments, 11 | * using the locale of the environment. 12 | * 13 | * @param format The string to format 14 | * @param args The arguments you want to apply. 15 | */ 16 | actual fun format(locale: String, format: String, vararg args: Any?) = String.format(Locale.forLanguageTag(locale), format, *args) 17 | } -------------------------------------------------------------------------------- /runtime-js/src/main/kotlin/org/rewedigital/konversation/FileChecker.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * Helper tool to verify if the given file exists. 5 | */ 6 | actual class FileChecker { 7 | /** Returns `true` if the file exists at the given path. */ 8 | actual fun exists(path: String): Boolean = try { 9 | val fs = require("fs") 10 | fs.existsSync("./$path") as Boolean 11 | } catch (e: Throwable) { 12 | if (e.message?.startsWith("ENOENT:") == false) { 13 | val request = XMLHttpRequest() 14 | request.open("HEAD", path, false) 15 | request.send(null) 16 | 17 | request.status != 200 18 | } else { 19 | false 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /shared/src/main/kotlin/org/rewedigital/konversation/PartType.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * The type of a part of the prompt. All parts will be concatenated by the runtime. For the display test the voice only parts will be stripped out. 5 | * This is very helpful if you need to describe some visual parts as lists which would be redundant on display devices. 6 | * Please note that the Text parts will be also added to the voice output. If you really need TextOnly please add a bug report. With an example why you need that. 7 | */ 8 | enum class PartType { 9 | /** A Text block which should be spoken and displayed. */ 10 | Text, 11 | /** A voice only block which should be just spoken and never displayed. */ 12 | VoiceOnly 13 | } -------------------------------------------------------------------------------- /.travis/prepare_deployment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TAG=`git describe --tags` 3 | MODULE=`echo ${TAG}|cut -d- -f 1` 4 | VERSION=`echo ${TAG}|cut -d- -f 2-` 5 | 6 | if [[ -f ".travis/prepare_${MODULE}_deployment.sh" ]]; then 7 | .travis/prepare_${MODULE}_deployment.sh 8 | fi 9 | 10 | echo Setup deployment keys... 11 | # prepare the key 12 | chmod 600 travis_rsa 13 | eval `ssh-agent -s` 14 | ssh-add travis_rsa 15 | 16 | echo Committing changes... 17 | git fetch 18 | git checkout master 19 | git commit -m "[skip ci] Publish $MODULE version $VERSION" 20 | git push 21 | git tag -fa ${TAG} -m "Release $MODULE $VERSION" 22 | git push origin master --tags -f 23 | 24 | ./gradlew dokka 25 | git add docs/* 26 | git commit -m "[skip ci] Update generated documentation" 27 | 28 | export TRAVIS_COMMIT=`git rev-parse HEAD` -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-file-checker/index.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [FileChecker](./index.md) 2 | 3 | # FileChecker 4 | 5 | `actual class FileChecker` 6 | 7 | Helper tool to verify if the given file exists. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `FileChecker()`
Helper tool to verify if the given file exists. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [exists](exists.md) | `actual fun exists(path: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)
Returns `true` if the file exists at the given path. | 20 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-file-checker/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [FileChecker](./index.md) 2 | 3 | # FileChecker 4 | 5 | `actual class FileChecker` 6 | 7 | Helper tool to verify if the given file exists. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `FileChecker()`
Helper tool to verify if the given file exists. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [exists](exists.md) | `actual fun exists(path: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)
Returns `true` if the file exists at the given path. | 20 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-file-checker/index.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [FileChecker](./index.md) 2 | 3 | # FileChecker 4 | 5 | `expect class FileChecker` 6 | 7 | Helper tool to verify if the given file exists. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `FileChecker()`
Helper tool to verify if the given file exists. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [exists](exists.md) | `fun exists(path: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)
Returns `true` if the file exists at the given path. | 20 | -------------------------------------------------------------------------------- /runtime-js/src/main/kotlin/org/rewedigital/konversation/Formatter.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * JavaScript implementation to format a string. This function just provides a platform specific `sprintf()` implementation. 5 | */ 6 | actual class Formatter { 7 | /** 8 | * Uses the provided [format] as a format string and returns a string obtained by substituting the specified arguments, 9 | * using the locale of the environment. 10 | * 11 | * @param format The string to format 12 | * @param args The arguments you want to apply. 13 | */ 14 | actual fun format(locale: String, format: String, vararg args: Any?): String { 15 | val sprintf = require("sprintf-js").sprintf 16 | return sprintf.format(format, args).toString() 17 | } 18 | } -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-reader/index.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reader](./index.md) 2 | 3 | # Reader 4 | 5 | `expect class Reader` 6 | 7 | Helper class to read files. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Reader()`
Helper class to read files. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [loadReply](load-reply.md) | `fun loadReply(name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, environment: `[`Environment`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-environment/index.md)`): `
Loads a reply for a given environment. | 20 | -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/parser/KonversationSyntaxError.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.parser 2 | 3 | import java.text.ParseException 4 | 5 | class KonversationSyntaxError( 6 | line: String, 7 | private val intent: String, 8 | private val lineNumber: Int, 9 | reason: String, 10 | private val file: String) : ParseException("Syntax error in line $lineNumber:\n$line\nCaused by: $reason", lineNumber) { 11 | override fun getStackTrace(): Array = 12 | (listOf(StackTraceElement( 13 | file.substringBefore('.'), 14 | intent, 15 | file, 16 | lineNumber 17 | )) + super.getStackTrace().toList()).toTypedArray() 18 | 19 | override fun toString() = "${javaClass.name}: Syntax error in line $lineNumber" 20 | } -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-konversation-js/create-java-script-output.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [KonversationJs](index.md) / [createJavaScriptOutput](./create-java-script-output.md) 2 | 3 | # createJavaScriptOutput 4 | 5 | `fun createJavaScriptOutput(data: dynamic = null): `[`OutputJs`](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-konversation-js/-output-js/index.md) 6 | 7 | Creates a static randomized output for your voice application. 8 | The [data](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-konversation-js/create-java-script-output/data.md) will be applied to the output so that you can customize the output with your values. 9 | 10 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-adapter-factory/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AdapterFactory](./index.md) 2 | 3 | # AdapterFactory 4 | 5 | `class AdapterFactory` 6 | 7 | ### Constructors 8 | 9 | | Name | Summary | 10 | |---|---| 11 | | [<init>](-init-.md) | `AdapterFactory()` | 12 | 13 | ### Functions 14 | 15 | | Name | Summary | 16 | |---|---| 17 | | [create](create.md) | `fun create(type: `[`Type`](http://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html)`?, annotations: `[`MutableSet`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)`?, moshi: ): >?` | 18 | -------------------------------------------------------------------------------- /cli/src/test/resources/huge-expected-alexa-result-limited.json: -------------------------------------------------------------------------------- 1 | { 2 | "interactionModel": { 3 | "languageModel": { 4 | "invocationName": "huge", 5 | "intents": [ 6 | { 7 | "name": "Test", 8 | "slots": [], 9 | "samples": [ 10 | "000", 11 | "001", 12 | "002", 13 | "003", 14 | "004", 15 | "005", 16 | "006", 17 | "007", 18 | "008", 19 | "009", 20 | "010", 21 | "011", 22 | "012", 23 | "013", 24 | "014", 25 | "015", 26 | "016", 27 | "017", 28 | "018", 29 | "019" 30 | ] 31 | } 32 | ], 33 | "types": [] 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /cli-integrations/chocolatey/legal/VERIFICATION.txt: -------------------------------------------------------------------------------- 1 | VERIFICATION 2 | Verification is intended to assist the Chocolatey moderators and community 3 | in verifying that this package's contents are trustworthy. 4 | 5 | Package can be verified like this: 6 | 7 | 1. Go to https://github.com/rewe-digital/Konversation/releases, search the latest released jar. 8 | 9 | jar: https://github.com/rewe-digital/Konversation/releases/download/cli-1.1.0/konversation-cli.jar 10 | 11 | 2. You can use one of the following methods to obtain the SHA256 checksum: 12 | - Use powershell function 'Get-FileHash' 13 | - Use Chocolatey utility 'checksum.exe' 14 | 15 | checksum: 582f71492d59fa5823dd16ff59c351e54f279ef5db96ea569183d4a4b3edcaa3 16 | 17 | File 'LICENSE.txt' obtained from: 18 | https://github.com/rewe-digital/Konversation/LICENSE.txt 19 | -------------------------------------------------------------------------------- /runtime-jvm/src/main/kotlin/org/rewedigital/konversation/Reader.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import com.squareup.moshi.Moshi 4 | 5 | /** 6 | * Helper class to read files. 7 | */ 8 | actual class Reader { 9 | /** 10 | * Loads a reply for a given environment. 11 | * @param name The name of the reply. 12 | * @param environment The environment of the reply. 13 | */ 14 | actual fun loadReply(name: String, environment: Environment) : Reply { 15 | val adapter = Moshi.Builder() 16 | .add(AdapterFactory()) 17 | .build() 18 | .adapter(AnswerImpl::class.java) 19 | return adapter.fromJson(javaClass.getResource("/" + locator.locate(name, environment)).readText())!! 20 | } 21 | 22 | companion object { 23 | private val locator = ResourceLocator() 24 | } 25 | } -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-konversation/create-output.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Konversation](index.md) / [createOutput](./create-output.md) 2 | 3 | # createOutput 4 | 5 | `fun createOutput(data: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> = emptyMap()): ` 6 | 7 | Creates a static randomized output for your voice application. 8 | The [data](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-konversation/create-output/data.md) will be applied to the output so that you can customize the output with your values. 9 | 10 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-random/index.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Random](./index.md) 2 | 3 | # Random 4 | 5 | `expect class Random` 6 | 7 | Abstraction layer for a random number generator. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Random()`
Abstraction layer for a random number generator. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [next](next.md) | `fun next(max: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`): `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)
Returns a random number between 0 and [max](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-random/next/max.md). | 20 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-random/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [Random](./index.md) 2 | 3 | # Random 4 | 5 | `actual class Random` 6 | 7 | Java implementation for a random number generator. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Random()`
Java implementation for a random number generator. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [next](next.md) | `actual fun next(max: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`): `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)
Returns a random number between 0 and [max](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-random/next/max.md). | 20 | -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/generator/Exporter.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator 2 | 3 | import org.rewedigital.konversation.Entities 4 | import org.rewedigital.konversation.Intent 5 | import java.io.OutputStream 6 | 7 | typealias Printer = (output: String) -> Unit 8 | 9 | interface Exporter { 10 | fun prettyPrinted(printer: Printer, intents: List, entities: List?) 11 | fun minified(printer: Printer, intents: List, entities: List?) 12 | } 13 | 14 | interface StreamExporter { 15 | fun prettyPrinted(outputStream: OutputStream, intents: List, entities: List?) 16 | fun minified(outputStream: OutputStream, intents: List, entities: List?) 17 | } 18 | 19 | interface NodeExporter { 20 | fun prettyPrinted(printer: Printer) 21 | fun minified(printer: Printer) 22 | } -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-part-type/index.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartType](./index.md) 2 | 3 | # PartType 4 | 5 | `enum class PartType` 6 | 7 | The type of a part of the prompt. All parts will be concatenated by the runtime. For the display test the voice only parts will be stripped out. 8 | This is very helpful if you need to describe some visual parts as lists which would be redundant on display devices. 9 | Please note that the Text parts will be also added to the voice output. If you really need TextOnly please add a bug report. With an example why you need that. 10 | 11 | ### Enum Values 12 | 13 | | Name | Summary | 14 | |---|---| 15 | | [Text](-text.md) | A Text block which should be spoken and displayed. | 16 | | [VoiceOnly](-voice-only.md) | A voice only block which should be just spoken and never displayed. | 17 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-random/index.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Random](./index.md) 2 | 3 | # Random 4 | 5 | `actual class Random` 6 | 7 | JavaScript implementation for a random number generator. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Random()`
JavaScript implementation for a random number generator. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [next](next.md) | `actual fun next(max: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`): `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)
Returns a random number between 0 and [max](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-random/next/max.md). | 20 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../index.md) / [org.rewedigital.konversation](./index.md) 2 | 3 | ## Package org.rewedigital.konversation 4 | 5 | ### Types 6 | 7 | | Name | Summary | 8 | |---|---| 9 | | [FileChecker](-file-checker/index.md) | `actual class FileChecker`
Helper tool to verify if the given file exists. | 10 | | [Formatter](-formatter/index.md) | `actual class Formatter`
Java implementation to format a string. This function just provides a platform specific `sprintf()` implementation. | 11 | | [PartImpl](-part-impl/index.md) | `data class PartImpl` | 12 | | [PartImplJsonAdapter](-part-impl-json-adapter/index.md) | `class PartImplJsonAdapter` | 13 | | [Random](-random/index.md) | `actual class Random`
Java implementation for a random number generator. | 14 | | [Reader](-reader/index.md) | `actual class Reader`
Helper class to read files. | 15 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-part-impl/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartImpl](./index.md) 2 | 3 | # PartImpl 4 | 5 | `data class PartImpl` 6 | 7 | ### Constructors 8 | 9 | | Name | Summary | 10 | |---|---| 11 | | [<init>](-init-.md) | `PartImpl(variants: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>, type: )` | 12 | 13 | ### Properties 14 | 15 | | Name | Summary | 16 | |---|---| 17 | | [type](type.md) | `val type: ` | 18 | | [variants](variants.md) | `val variants: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` | 19 | -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-formatter/format.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [Formatter](index.md) / [format](./format.md) 2 | 3 | # format 4 | 5 | `actual fun format(locale: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, format: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, vararg args: `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`?): ` 6 | 7 | Uses the provided [format](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-formatter/format/format.md) as a format string and returns a string obtained by substituting the specified arguments, 8 | using the locale of the environment. 9 | 10 | ### Parameters 11 | 12 | `format` - The string to format 13 | 14 | `args` - The arguments you want to apply. -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-part/index.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Part](./index.md) 2 | 3 | # Part 4 | 5 | `interface Part` 6 | 7 | One part of the [Reply](../-reply/index.md) for the user. There can be two types: Text and VoiceOnly. The runtime will contact the parts and add separators (spaces). 8 | 9 | ### Properties 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [type](type.md) | `abstract val type: `[`PartType`](../-part-type/index.md)
The type of this part can be Text and VoiceOnly. | 14 | | [variants](variants.md) | `abstract val variants: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>`
The variants for this part. Please make sure that there are no grammatical issues when you use another alternative. | 15 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | resolutionStrategy { 3 | eachPlugin { 4 | if (requested.id.id == "kotlin-platform-common") { 5 | useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31") 6 | } 7 | 8 | if (requested.id.id == "kotlin-platform-jvm") { 9 | useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31") 10 | } 11 | 12 | if (requested.id.id == "kotlin-platform-js") { 13 | useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31") 14 | } 15 | } 16 | } 17 | 18 | repositories { 19 | mavenLocal() // just for plugin development 20 | jcenter() 21 | maven { url "https://plugins.gradle.org/m2/" } 22 | } 23 | } 24 | rootProject.name = 'konversation' 25 | 26 | include 'runtime-shared', 'runtime-jvm', 'runtime-js', 'cli', 'shared', 'gradle-plugin', 'plugin-example' -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/index.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../index.md) / [org.rewedigital.konversation](./index.md) 2 | 3 | ## Package org.rewedigital.konversation 4 | 5 | ### Types 6 | 7 | | Name | Summary | 8 | |---|---| 9 | | [FileChecker](-file-checker/index.md) | `actual class FileChecker`
Helper tool to verify if the given file exists. | 10 | | [Formatter](-formatter/index.md) | `actual class Formatter`
JavaScript implementation to format a string. This function just provides a platform specific `sprintf()` implementation. | 11 | | [KonversationJs](-konversation-js/index.md) | `class KonversationJs`
This class is the interop layer to use just primitiv values. Lists will be converted to Arrays and Maps to simple objects. | 12 | | [Random](-random/index.md) | `actual class Random`
JavaScript implementation for a random number generator. | 13 | | [Reader](-reader/index.md) | `actual class Reader`
Helper class to read files. | 14 | -------------------------------------------------------------------------------- /.travis/configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TAG=`git describe --tags` 3 | MODULE=`echo ${TAG}|cut -d- -f 1` 4 | VERSION=`echo ${TAG}|cut -d- -f 2-` 5 | 6 | mkdir -p publish 7 | echo "bintray.user=$bintry_user">>~/.gradle/gradle.properties 8 | echo "bintray.key=$bintry_key">>~/.gradle/gradle.properties 9 | echo "gradle.publish.key=$gradle_key">>~/.gradle/gradle.properties 10 | echo "gradle.publish.secret=$gradle_secret">>~/.gradle/gradle.properties 11 | echo "//registry.npmjs.org/:_authToken=$npm_token">~/.npmrc 12 | 13 | echo "Configuring $MODULE for release $VERSION..." 14 | # Hide the mail address from spam bots 15 | git config --local user.email "`echo "Ym90QHJla2kucmU=" | base64 -d`" 16 | git config --local user.name "Travis CI" 17 | git remote set-url origin git@github.com:${TRAVIS_REPO_SLUG}.git 18 | git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" 19 | 20 | if [[ -f ".travis/configure_${MODULE}.sh" ]]; then 21 | .travis/configure_${MODULE}.sh 22 | fi -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/generator/dialogflow/EntityMetaData.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.dialogflow 2 | 3 | import org.rewedigital.konversation.generator.NodeExporter 4 | import org.rewedigital.konversation.generator.Printer 5 | import java.util.* 6 | 7 | data class EntityMetaData( 8 | val automatedExpansion: Boolean, 9 | val id: UUID, 10 | val isEnum: Boolean, 11 | val isOverridable: Boolean, 12 | val name: String) : NodeExporter { 13 | override fun prettyPrinted(printer: Printer) { 14 | printer("""{ 15 | "id": "$id", 16 | "name": "$name", 17 | "isOverridable": $isOverridable, 18 | "isEnum": $isEnum, 19 | "automatedExpansion": $automatedExpansion 20 | }""") 21 | } 22 | 23 | override fun minified(printer: Printer) { 24 | printer("""{"id":"$id","name":"$name","isOverridable":$isOverridable,"isEnum":$isEnum,"automatedExpansion":$automatedExpansion}""") 25 | } 26 | } -------------------------------------------------------------------------------- /docs/runtime-jvm/alltypes/index.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### All Types 4 | 5 | | Name | Summary | 6 | |---|---| 7 | | [org.rewedigital.konversation.FileChecker](../org.rewedigital.konversation/-file-checker/index.md) | Helper tool to verify if the given file exists. | 8 | | [org.rewedigital.konversation.Formatter](../org.rewedigital.konversation/-formatter/index.md) | Java implementation to format a string. This function just provides a platform specific `sprintf()` implementation. | 9 | | [org.rewedigital.konversation.PartImpl](../org.rewedigital.konversation/-part-impl/index.md) | | 10 | | [org.rewedigital.konversation.PartImplJsonAdapter](../org.rewedigital.konversation/-part-impl-json-adapter/index.md) | | 11 | | [org.rewedigital.konversation.Random](../org.rewedigital.konversation/-random/index.md) | Java implementation for a random number generator. | 12 | | [org.rewedigital.konversation.Reader](../org.rewedigital.konversation/-reader/index.md) | Helper class to read files. | 13 | -------------------------------------------------------------------------------- /docs/runtime-js/alltypes/index.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### All Types 4 | 5 | | Name | Summary | 6 | |---|---| 7 | | [org.rewedigital.konversation.FileChecker](../org.rewedigital.konversation/-file-checker/index.md) | Helper tool to verify if the given file exists. | 8 | | [org.rewedigital.konversation.Formatter](../org.rewedigital.konversation/-formatter/index.md) | JavaScript implementation to format a string. This function just provides a platform specific `sprintf()` implementation. | 9 | | [org.rewedigital.konversation.KonversationJs](../org.rewedigital.konversation/-konversation-js/index.md) | This class is the interop layer to use just primitiv values. Lists will be converted to Arrays and Maps to simple objects. | 10 | | [org.rewedigital.konversation.Random](../org.rewedigital.konversation/-random/index.md) | JavaScript implementation for a random number generator. | 11 | | [org.rewedigital.konversation.Reader](../org.rewedigital.konversation/-reader/index.md) | Helper class to read files. | 12 | -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/generator/dialogflow/Entity.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.dialogflow 2 | 3 | import org.rewedigital.konversation.generator.NodeExporter 4 | import org.rewedigital.konversation.generator.Printer 5 | 6 | data class Entity( 7 | val key: String?, 8 | val value: String, 9 | val synonyms: List) : NodeExporter { 10 | 11 | override fun prettyPrinted(printer: Printer) { 12 | printer(" {\n") 13 | printer(" \"value\": \"${key ?: value}\",\n") 14 | printer(" \"synonyms\": [\n") 15 | printer((listOf(value) + synonyms).joinToString(separator = ",\n", postfix = "\n ]") { " \"$it\"" }) 16 | printer("\n }") 17 | } 18 | 19 | override fun minified(printer: Printer) { 20 | printer("{\"value\":\"${key ?: value}\",\"synonyms\":[") 21 | printer((listOf(value) + synonyms).joinToString(separator = ",", postfix = "]}") { "\"$it\"" }) 22 | } 23 | } -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-answer-impl/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AnswerImpl](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `AnswerImpl(parts: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<> = mutableListOf(), suggestions: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = mutableListOf(), reprompts: `[`MutableMap`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>> = mutableMapOf())` -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-formatter/format.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Formatter](index.md) / [format](./format.md) 2 | 3 | # format 4 | 5 | `fun format(locale: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, format: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, vararg args: `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`?): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) 6 | 7 | Uses the provided [format](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-formatter/format/format.md) as a format string and returns a string obtained by substituting the specified arguments, 8 | using the locale of the environment. 9 | 10 | ### Parameters 11 | 12 | `format` - The string to format 13 | 14 | `args` - The arguments you want to apply. -------------------------------------------------------------------------------- /runtime-js/src/main/javascript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@rewe-digital/konversation", 3 | "version": "1.0.3", 4 | "description": "Konversation is a tool to generate rich and diversified responses to the user of a voice application.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "René Kilczan", 10 | "license": "MIT", 11 | "dependencies": { 12 | "kotlin": "^1.3.31", 13 | "sprintf-js": "^1.1.2" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/rewe-digital/Konversation.git" 18 | }, 19 | "keywords": [ 20 | "konversation", 21 | "google home", 22 | "actions on google", 23 | "alexa" 24 | ], 25 | "bugs": { 26 | "url": "https://github.com/rewe-digital/Konversation/issues/?labels=npm" 27 | }, 28 | "homepage": "https://github.com/rewe-digital/Konversation#readme", 29 | "publishConfig": { 30 | "access": "public" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-formatter/format.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Formatter](index.md) / [format](./format.md) 2 | 3 | # format 4 | 5 | `actual fun format(locale: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, format: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, vararg args: `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`?): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) 6 | 7 | Uses the provided [format](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-formatter/format/format.md) as a format string and returns a string obtained by substituting the specified arguments, 8 | using the locale of the environment. 9 | 10 | ### Parameters 11 | 12 | `format` - The string to format 13 | 14 | `args` - The arguments you want to apply. -------------------------------------------------------------------------------- /runtime-shared/src/main/kotlin/org/rewedigital/konversation/Output.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * Holds a static output of a reply. 5 | */ 6 | data class Output( 7 | /** The display test. */ 8 | val displayText: String, 9 | /** The Speech Synthesis Markup Language, the spoken output. */ 10 | val ssml: String, 11 | /** The reprompts which should the user hear when the user gives no input. */ 12 | val reprompts: Map, 13 | /** The list of suggestions which should been displayed. */ 14 | val suggestions: List, 15 | /** The strings for UI elements */ 16 | val extras: Map) { 17 | operator fun plus(output: Output) = Output( 18 | displayText = displayText + "\n" + output.displayText, 19 | ssml = ssml.removeSuffix("") + "\n" + output.ssml.removePrefix(""), 20 | extras = extras + output.extras, 21 | reprompts = reprompts + output.reprompts, 22 | suggestions = suggestions + output.suggestions) 23 | } -------------------------------------------------------------------------------- /runtime-js/src/test/javascript/simpleTest.js: -------------------------------------------------------------------------------- 1 | const runtime = require("../../../build/out/index"); 2 | const Konversation = runtime.Konversation; 3 | const Environment = runtime.Environment; 4 | 5 | runtime.Random.Companion.forcedValue = 0; 6 | 7 | const k1 = new Konversation("test", {platform:"Foo", locale:"de"}); 8 | const k2 = new Konversation("test", new Environment("Foo", "")); 9 | const o1 = k1.createOutput(); 10 | const o2 = k1.createOutput({a:"a", b:"2"}); 11 | const o3 = k2.createOutput(); 12 | const o4 = k2.createOutput({a:"a", b:"2"}); 13 | if(!o1 || !o2 || !o3 || !o4) throw Error("Output was empty!"); 14 | const expected = '{"displayText":"Deine Liste ist leer.","ssml":"Deine Liste ist leer. Du kannst aber Zutaten aus den Rezepten oder Angebote zur Einkaufsliste hinzuf\u00fcgen. Versuch's doch mal damit.","reprompts":{},"suggestions":[],"extras":{}}'; 15 | if(JSON.stringify(o2) !== expected) throw Error("Unexpected output.\nExpected: " + expected + "\nActual: " + JSON.stringify(o2)); 16 | console.log(JSON.stringify(o2, null, 2)); 17 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/kotlin.collections.-iterable/for-each-iterator.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [kotlin.collections.Iterable](index.md) / [forEachIterator](./for-each-iterator.md) 2 | 3 | # forEachIterator 4 | 5 | `fun `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`T`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/for-each-iterator/-t/index.md)`>.forEachIterator(block: `[`Iterator`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterator/index.html)`<`[`T`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/for-each-iterator/-t/index.md)`>.(element: `[`T`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/for-each-iterator/-t/index.md)`) -> `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-part-impl-json-adapter/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [PartImplJsonAdapter](./index.md) 2 | 3 | # PartImplJsonAdapter 4 | 5 | `class PartImplJsonAdapter` 6 | 7 | ### Constructors 8 | 9 | | Name | Summary | 10 | |---|---| 11 | | [<init>](-init-.md) | `PartImplJsonAdapter(moshi: )` | 12 | 13 | ### Functions 14 | 15 | | Name | Summary | 16 | |---|---| 17 | | [fromJson](from-json.md) | `fun fromJson(reader: ): `[`PartImpl`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-part-impl/index.md) | 18 | | [toJson](to-json.md) | `fun toJson(writer: , value: `[`PartImpl`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-part-impl/index.md)`?): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | 19 | | [toString](to-string.md) | `fun toString(): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | 20 | -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/index.md: -------------------------------------------------------------------------------- 1 | [shared](../index.md) / [org.rewedigital.konversation](./index.md) 2 | 3 | ## Package org.rewedigital.konversation 4 | 5 | ### Types 6 | 7 | | Name | Summary | 8 | |---|---| 9 | | [Part](-part/index.md) | `interface Part`
One part of the [Reply](-reply/index.md) for the user. There can be two types: Text and VoiceOnly. The runtime will contact the parts and add separators (spaces). | 10 | | [PartType](-part-type/index.md) | `enum class PartType`
The type of a part of the prompt. All parts will be concatenated by the runtime. For the display test the voice only parts will be stripped out. This is very helpful if you need to describe some visual parts as lists which would be redundant on display devices. Please note that the Text parts will be also added to the voice output. If you really need TextOnly please add a bug report. With an example why you need that. | 11 | | [Reply](-reply/index.md) | `open class Reply`
Each Reply contains multiple [Part](-part/index.md)s, suggestions and reprompts. The parts can be for the display or just for the audio output. | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT license (MIT) 2 | 3 | Copyright (c) 2018 REWE Digital GmbH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 6 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 7 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 8 | persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 11 | Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 14 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 15 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 16 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-answer-impl-json-adapter/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AnswerImplJsonAdapter](./index.md) 2 | 3 | # AnswerImplJsonAdapter 4 | 5 | `class AnswerImplJsonAdapter` 6 | 7 | ### Constructors 8 | 9 | | Name | Summary | 10 | |---|---| 11 | | [<init>](-init-.md) | `AnswerImplJsonAdapter(moshi: )` | 12 | 13 | ### Functions 14 | 15 | | Name | Summary | 16 | |---|---| 17 | | [fromJson](from-json.md) | `fun fromJson(reader: ): `[`AnswerImpl`](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-answer-impl/index.md) | 18 | | [toJson](to-json.md) | `fun toJson(writer: , value: `[`AnswerImpl`](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-answer-impl/index.md)`?): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | 19 | | [toString](to-string.md) | `fun toString(): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | 20 | -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-environment/index.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Environment](./index.md) 2 | 3 | # Environment 4 | 5 | `data class Environment` 6 | 7 | The environment holds data about the environment where is voice application is running. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Environment(platform: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, locale: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)`
The environment holds data about the environment where is voice application is running. | 14 | 15 | ### Properties 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [locale](locale.md) | `val locale: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
The locale the for the output. | 20 | | [platform](platform.md) | `val platform: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
The platform for the reply should be optimized. | 21 | -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/generator/dialogflow/Message.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.dialogflow 2 | 3 | import org.rewedigital.konversation.generator.NodeExporter 4 | import org.rewedigital.konversation.generator.Printer 5 | 6 | data class Message( 7 | val lang: String, 8 | val speech: List 9 | ) : NodeExporter { 10 | override fun prettyPrinted(printer: Printer) { 11 | printer(""" 12 | { 13 | "type": 0, 14 | "lang": "$lang", 15 | "speech": [""") 16 | printer(speech.joinToString(separator = ",", postfix = "\n") { "\n \"${it.escape()}\"" }) 17 | printer(" ]\n }") 18 | } 19 | 20 | override fun minified(printer: Printer) { 21 | printer("""{"type":0,"lang":"$lang","speech":[""") 22 | printer(speech.joinToString(separator = ",", postfix = "]}") { "\"${it.escape()}\"" }) 23 | } 24 | 25 | private fun String.escape() = 26 | replace("\\", "\\\\") 27 | .replace("\r", "\\r") 28 | .replace("\n", "\\n") 29 | .replace("\"", "\\") 30 | } -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-reply/-init-.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reply](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Reply(parts: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`Part`](../-part/index.md)`> = mutableListOf(), suggestions: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = mutableListOf(), reprompts: `[`MutableMap`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>> = mutableMapOf())` 6 | 7 | Each Reply contains multiple [Part](../-part/index.md)s, suggestions and reprompts. The parts can be for the display or just for the audio output. 8 | 9 | -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/generator/dialogflow/QuickReply.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.dialogflow 2 | 3 | import org.rewedigital.konversation.generator.NodeExporter 4 | import org.rewedigital.konversation.generator.Printer 5 | 6 | data class QuickReply( 7 | val lang: String, 8 | val replies: List 9 | ) : NodeExporter { 10 | override fun prettyPrinted(printer: Printer) { 11 | printer(""" 12 | { 13 | "type": 2, 14 | "lang": "$lang", 15 | "replies": [""") 16 | printer(replies.joinToString(separator = ",", postfix = "\n") { "\n \"${it.escape()}\"" }) 17 | printer(" ]\n }") 18 | } 19 | 20 | override fun minified(printer: Printer) { 21 | printer("""{"type":2,"lang":"$lang","replies":[""") 22 | printer(replies.joinToString(separator = ",", postfix = "]}") { "\"${it.escape()}\"" }) 23 | } 24 | 25 | private fun String.escape() = 26 | replace("\\", "\\\\") 27 | .replace("\r", "\\r") 28 | .replace("\n", "\\n") 29 | .replace("\"", "\\") 30 | } -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/kotlin.collections.-iterable/index.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [kotlin.collections.Iterable](./index.md) 2 | 3 | ### Extensions for kotlin.collections.Iterable 4 | 5 | | Name | Summary | 6 | |---|---| 7 | | [forEachIterator](for-each-iterator.md) | `fun `[`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)`<`[`T`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/for-each-iterator/-t/index.md)`>.forEachIterator(block: `[`Iterator`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterator/index.html)`<`[`T`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/for-each-iterator/-t/index.md)`>.(element: `[`T`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/for-each-iterator/-t/index.md)`) -> `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | 8 | -------------------------------------------------------------------------------- /docs/shared/alltypes/index.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### All Types 4 | 5 | | Name | Summary | 6 | |---|---| 7 | | [org.rewedigital.konversation.Part](../org.rewedigital.konversation/-part/index.md) | One part of the [Reply](../org.rewedigital.konversation/-reply/index.md) for the user. There can be two types: Text and VoiceOnly. The runtime will contact the parts and add separators (spaces). | 8 | | [org.rewedigital.konversation.PartType](../org.rewedigital.konversation/-part-type/index.md) | The type of a part of the prompt. All parts will be concatenated by the runtime. For the display test the voice only parts will be stripped out. This is very helpful if you need to describe some visual parts as lists which would be redundant on display devices. Please note that the Text parts will be also added to the voice output. If you really need TextOnly please add a bug report. With an example why you need that. | 9 | | [org.rewedigital.konversation.Reply](../org.rewedigital.konversation/-reply/index.md) | Each Reply contains multiple [Part](../org.rewedigital.konversation/-part/index.md)s, suggestions and reprompts. The parts can be for the display or just for the audio output. | 10 | -------------------------------------------------------------------------------- /dialogflowDemo/Demo.kvs: -------------------------------------------------------------------------------- 1 | WelcomeIntent: 2 | !{Hi|Hey|Hello} 3 | -{Hi|Hey|Hello} 4 | + 5 | -and welcome to 6 | + 7 | -my example project 8 | -{this|a} {demonstration|extended demo} 9 | + 10 | -how to prototype with Konversation. 11 | - 12 | - What's your name (please answer with a full sentence)? 13 | [My name is John Doe] [Tell me a joke] 14 | 15 | NameIntent: 16 | !My name is {{name:any}} 17 | !I'm {|called} {{name:any}} 18 | !You can call me {{name:any}} 19 | -{Nice|I'm glad} to meet you $name! 20 | -What a cool name. 21 | - 22 | -Do you like to hear a {|funny|fantastic} joke $name? 23 | -Are you interested in a {|great} joke? 24 | - 25 | ~Please say yes! 26 | [yes] [no] 27 | 28 | JokeIntent: 29 | !Yes {|of cause|for sure} 30 | !{|Yes} tell me a {|funny|fantastic|great} joke {|please} 31 | !Yet another 32 | !Eh no But tell me a joke 33 | -What does a snail say when he finds himself on a turtle’s back? Wheeee!!! 34 | -What is the best season to jump on a trampoline? Spring time. 35 | -Why did the physics teacher break up with the biology teacher? There was no chemistry. 36 | [Yet another] [bye] 37 | 38 | ByeIntent: 39 | !bye 40 | -See you soon -------------------------------------------------------------------------------- /cli/src/test/resources/help-expected-kson-result.json: -------------------------------------------------------------------------------- 1 | { 2 | "parts": [ 3 | { 4 | "type": "Text", 5 | "variants": [ 6 | "Du kannst mit dieser App", 7 | "Mit dieser App kannst du" 8 | ] 9 | }, 10 | { 11 | "type": "Text", 12 | "variants": [ 13 | "Rezepte und Angebote", 14 | "Angebote und Rezepte" 15 | ] 16 | }, 17 | { 18 | "type": "Text", 19 | "variants": [ 20 | "anhören.", 21 | "vorlesen lassen." 22 | ] 23 | }, 24 | { 25 | "type": "VoiceOnly", 26 | "variants": [ 27 | "Cool nicht wahr?" 28 | ] 29 | }, 30 | { 31 | "type": "VoiceOnly", 32 | "variants": [ 33 | "Womit sollen wir weiter machen?", 34 | "Womit soll ich weiter machen?", 35 | "Was möchtest du jetzt tun?" 36 | ] 37 | } 38 | ], 39 | "suggestions": [ 40 | "Angebote", 41 | "Rezepte" 42 | ], 43 | "reprompts": { 44 | "1": [ 45 | "Kann ich dir noch helfen?", 46 | "Kann ich dir jetzt noch helfen?" 47 | ], 48 | "2": [ 49 | "Womit sollen wir weitermachen?" 50 | ] 51 | } 52 | } -------------------------------------------------------------------------------- /runtime-jvm/src/test/resources/konversation/help.kson: -------------------------------------------------------------------------------- 1 | { 2 | "parts": [ 3 | { 4 | "type": "Text", 5 | "variants": [ 6 | "Du kannst mit dieser App", 7 | "Mit dieser App kannst du" 8 | ] 9 | }, 10 | { 11 | "type": "Text", 12 | "variants": [ 13 | "Rezepte und Angebote", 14 | "Angebote und Rezepte" 15 | ] 16 | }, 17 | { 18 | "type": "Text", 19 | "variants": [ 20 | "anhören.", 21 | "vorlesen lassen." 22 | ] 23 | }, 24 | { 25 | "type": "VoiceOnly", 26 | "variants": [ 27 | "Cool nicht wahr?" 28 | ] 29 | }, 30 | { 31 | "type": "VoiceOnly", 32 | "variants": [ 33 | "Womit sollen wir weiter machen?", 34 | "Womit soll ich weiter machen?", 35 | "Was möchtest du jetzt tun?" 36 | ] 37 | } 38 | ], 39 | "suggestions": [ 40 | "Angebote", 41 | "Rezept" 42 | ], 43 | "reprompts": { 44 | "1": [ 45 | "Kann ich dir noch helfen?", 46 | "Kann ich dir jetzt noch helfen?" 47 | ], 48 | "2": [ 49 | "Womit sollen wir weitermachen?" 50 | ] 51 | } 52 | } -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-output/-init-.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Output](index.md) / [<init>](./-init-.md) 2 | 3 | # <init> 4 | 5 | `Output(displayText: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, ssml: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, reprompts: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>, suggestions: `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>, extras: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>)` 6 | 7 | Holds a static output of a reply. 8 | 9 | -------------------------------------------------------------------------------- /.travis/configure_cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TAG=`git describe --tags` 3 | MODULE=`echo ${TAG}|cut -d- -f 1` 4 | VERSION=`echo ${TAG}|cut -d- -f 2-` 5 | 6 | echo Updating version numbers... 7 | sed -i -E "s/^version '[^']+'$/version '$VERSION'/g" cli/build.gradle 8 | git add cli/build.gradle 9 | 10 | sed -i -E "s/version is [0-9][^]\"]+/version is $VERSION/g" cli/readme.md 11 | sed -i -E "s/cli-[0-9][^ ]+-blue/cli-`echo ${VERSION}|sed -e "s/-/--/g"`-blue/g" cli/readme.md 12 | git add cli/readme.md 13 | 14 | sed -i -E "s/(brew|chocolaty) version is [0-9][^]\"]+/\1 version is $VERSION/g" docs/index.md 15 | sed -i -E "s/(brew|chocolaty)-[0-9][^ ]+-blue/\1-`echo ${VERSION}|sed -e "s/-/--/g"`-blue/g" docs/index.md 16 | git add docs/index.md 17 | 18 | sed -i -e "s/const val version = \".*\"/const val version = \"$VERSION\"/g" cli/src/main/kotlin/org/rewedigital/konversation/Cli.kt 19 | git add cli/src/main/kotlin/org/rewedigital/konversation/Cli.kt 20 | 21 | sed -i -e "s/versions.cli = '.*'/versions.cli = '$VERSION'/g" build.gradle 22 | git add build.gradle 23 | 24 | echo Prepairing artifacts... 25 | # Add link to the not yet created artifact 26 | ln -s ../cli/build/libs/konversation.jar publish/konversation-cli.jar -------------------------------------------------------------------------------- /cli-integrations/chocolatey/legal/LICENSE.txt: -------------------------------------------------------------------------------- 1 | From: https://github.com/rewe-digital/Konversation/LICENSE.txt 2 | 3 | LICENSE 4 | 5 | The MIT license (MIT) 6 | 7 | Copyright (c) 2018 REWE Digital GmbH 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 10 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 11 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 12 | persons to whom the Software is furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 15 | Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-formatter/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [Formatter](./index.md) 2 | 3 | # Formatter 4 | 5 | `actual class Formatter` 6 | 7 | Java implementation to format a string. This function just provides a platform specific `sprintf()` implementation. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Formatter()`
Java implementation to format a string. This function just provides a platform specific `sprintf()` implementation. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [format](format.md) | `actual fun format(locale: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, format: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, vararg args: `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`?): `
Uses the provided [format](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-formatter/format/format.md) as a format string and returns a string obtained by substituting the specified arguments, using the locale of the environment. | 20 | -------------------------------------------------------------------------------- /shared/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'kotlin-platform-common' 3 | } 4 | 5 | repositories { 6 | jcenter() 7 | maven { url "http://dl.bintray.com/kotlin/kotlin-eap" } 8 | } 9 | 10 | dependencies { 11 | compile "org.jetbrains.kotlin:kotlin-stdlib-common:${rootProject.ext.versions.kotlin}" 12 | compile "org.jetbrains.kotlin:kotlin-reflect" 13 | testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:${rootProject.ext.versions.kotlin}" 14 | testCompile "org.jetbrains.kotlin:kotlin-test-common:${rootProject.ext.versions.kotlin}" 15 | //compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.30.2' 16 | } 17 | 18 | sourceSets { 19 | main.java.srcDirs += 'src/main/kotlin/' 20 | test.java.srcDirs += 'src/test/kotlin/' 21 | } 22 | 23 | apply from: '../docu.gradle' 24 | dokka { 25 | impliedPlatforms = ["COMMON"] // This will force platform tags for all non-common sources e.g. "JVM" 26 | kotlinTasks { 27 | // dokka fails to retrieve sources from MPP-tasks so they must be set empty to avoid exception 28 | // use sourceRoot instead (see below) 29 | [] 30 | } 31 | sourceRoot { 32 | // assuming there is only a single source dir... 33 | path = kotlin.sourceSets.main.kotlin.srcDirs[0] 34 | platforms = ["COMMON"] 35 | } 36 | } -------------------------------------------------------------------------------- /.travis/prepare_cli_deployment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TAG=`git describe --tags` 3 | MODULE=`echo ${TAG}|cut -d- -f 1` 4 | VERSION=`echo ${TAG}|cut -d- -f 2-` 5 | 6 | echo "Patching Chocolatey..." 7 | jarUrl="https://github.com/rewe-digital/Konversation/releases/download/$TAG/konversation-cli.jar" 8 | sha256=`sha256sum publish/konversation-cli.jar | cut -d " " -f 1` 9 | sed -e "s#jar: .*#jar: $jarUrl#g" -e "s/checksum: .*/checksum: $sha256/g" -i cli-integrations/chocolatey/legal/VERIFICATION.txt 10 | sed -e "s#.*#$VERSION#g" -i cli-integrations/chocolatey/konversation.nuspec 11 | git add cli-integrations/chocolatey/legal/VERIFICATION.txt cli-integrations/chocolatey/konversation.nuspec 12 | 13 | # TODO checkout and patch brew repo. 14 | # echo "Clone homebrew tap..." 15 | # cd build 16 | # rm -rf "homebrew-packages" | true 17 | # git clone --depth=1 git@github.com:rekire/homebrew-packages.git 18 | # 19 | # echo "Patching Formula..." 20 | # sed -e "s#url .*#url \"$jarUrl\"#g" -e "s/sha256 .*/sha256 \"$sha256\"/g" -i homebrew-packages/Formula/konversation.rb 21 | # 22 | # echo "Committing changes..." 23 | # git add homebrew-packages/Formula/konversation.rb 24 | # git commit -m "Update homebrew to version $VERSION" 25 | # git tag -a "v$VERSION" -m "v$VERSION" 26 | # git push 27 | # git push origin --tags -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-formatter/index.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Formatter](./index.md) 2 | 3 | # Formatter 4 | 5 | `expect class Formatter` 6 | 7 | Abstraction layer to format a string. This function just provides a platform specific `sprintf()` implementation. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Formatter()`
Abstraction layer to format a string. This function just provides a platform specific `sprintf()` implementation. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [format](format.md) | `fun format(locale: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, format: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, vararg args: `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`?): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
Uses the provided [format](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-formatter/format/format.md) as a format string and returns a string obtained by substituting the specified arguments, using the locale of the environment. | 20 | -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-formatter/index.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [Formatter](./index.md) 2 | 3 | # Formatter 4 | 5 | `actual class Formatter` 6 | 7 | JavaScript implementation to format a string. This function just provides a platform specific `sprintf()` implementation. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Formatter()`
JavaScript implementation to format a string. This function just provides a platform specific `sprintf()` implementation. | 14 | 15 | ### Functions 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [format](format.md) | `actual fun format(locale: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, format: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, vararg args: `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`?): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
Uses the provided [format](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-formatter/format/format.md) as a format string and returns a string obtained by substituting the specified arguments, using the locale of the environment. | 20 | -------------------------------------------------------------------------------- /runtime-shared/build.gradle: -------------------------------------------------------------------------------- 1 | import java.nio.file.Paths 2 | 3 | plugins { 4 | id 'kotlin-platform-common' 5 | } 6 | apply from: '../docu.gradle' 7 | repositories { 8 | jcenter() 9 | maven { url "https://plugins.gradle.org/m2/" } 10 | maven { url "http://dl.bintray.com/kotlin/kotlin-eap" } 11 | } 12 | 13 | dependencies { 14 | compile "org.jetbrains.kotlin:kotlin-stdlib-common" 15 | compile "org.jetbrains.kotlin:kotlin-reflect" 16 | testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common" 17 | testCompile "org.jetbrains.kotlin:kotlin-test-common" 18 | compile project(":shared") 19 | } 20 | 21 | apply from: '../docu.gradle' 22 | dokka { 23 | impliedPlatforms = ["COMMON"] // This will force platform tags for all non-common sources e.g. "JVM" 24 | kotlinTasks { 25 | // dokka fails to retrieve sources from MPP-tasks so they must be set empty to avoid exception 26 | // use sourceRoot instead (see below) 27 | [] 28 | } 29 | sourceRoot { 30 | // assuming there is only a single source dir... 31 | path = kotlin.sourceSets.main.kotlin.srcDirs[0] 32 | platforms = ["COMMON"] 33 | } 34 | externalDocumentationLink { 35 | url = new URL("https://github.com/rewe-digital/${rootProject.name}/blob/master/docs/shared/") 36 | packageListUrl = Paths.get("$rootDir/docs/shared/package-list").toUri().toURL() 37 | } 38 | } -------------------------------------------------------------------------------- /cli/src/test/kotlin/org/rewedigital/konversation/generator/kson/KsonExporterTest.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.kson 2 | 3 | import org.junit.Test 4 | import org.rewedigital.konversation.assertEqualsIgnoringLineBreaks 5 | import org.rewedigital.konversation.parser.Parser 6 | import java.io.File 7 | import kotlin.test.assertEquals 8 | 9 | class KsonExporterTest { 10 | @Test 11 | fun prettyKvsResult() { 12 | val help = Parser("$pathPrefix/help.kvs").intents 13 | val sb = StringBuilder() 14 | val exporter = KsonExporter("Help") 15 | exporter.prettyPrinted({ line -> sb.append(line) }, help, null) 16 | assertEqualsIgnoringLineBreaks(expectedResult, sb.toString()) 17 | } 18 | 19 | @Test 20 | fun minifiedKvsResult() { 21 | val help = Parser("$pathPrefix/help.kvs").intents 22 | val sb = StringBuilder() 23 | val exporter = KsonExporter("Help") 24 | exporter.minified({ line -> sb.append(line) }, help, null) 25 | assertEquals(expectedMinifiedResult, sb.toString()) 26 | } 27 | 28 | companion object { 29 | val pathPrefix = (if (File("").absolutePath.endsWith("cli")) "" else "cli/") + "src/test/resources" 30 | val expectedResult = File("$pathPrefix/help-expected-kson-result.json").absoluteFile.readText() 31 | val expectedMinifiedResult = File("$pathPrefix/help-expected-kson-result-minified.json").absoluteFile.readText() 32 | } 33 | } -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-konversation-js/index.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../index.md) / [org.rewedigital.konversation](../index.md) / [KonversationJs](./index.md) 2 | 3 | # KonversationJs 4 | 5 | `class KonversationJs` 6 | 7 | This class is the interop layer to use just primitiv values. Lists will be converted to Arrays and Maps to simple objects. 8 | 9 | ### Types 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [OutputJs](-output-js/index.md) | `class OutputJs` | 14 | 15 | ### Constructors 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [<init>](-init-.md) | `KonversationJs(name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, environment: dynamic)`
This class is the interop layer to use just primitiv values. Lists will be converted to Arrays and Maps to simple objects. | 20 | 21 | ### Functions 22 | 23 | | Name | Summary | 24 | |---|---| 25 | | [createJavaScriptOutput](create-java-script-output.md) | `fun createJavaScriptOutput(data: dynamic = null): `[`OutputJs`](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-konversation-js/-output-js/index.md)
Creates a static randomized output for your voice application. The [data](https://github.com/rewe-digital-incubator/konversation/blob/master/docs/shared/org.rewedigital.konversation/-konversation-js/create-java-script-output/data.md) will be applied to the output so that you can customize the output with your values. | 26 | -------------------------------------------------------------------------------- /docs/runtime-shared/alltypes/index.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### All Types 4 | 5 | | Name | Summary | 6 | |---|---| 7 | | [org.rewedigital.konversation.Environment](../org.rewedigital.konversation/-environment/index.md) | The environment holds data about the environment where is voice application is running. | 8 | | [org.rewedigital.konversation.FileChecker](../org.rewedigital.konversation/-file-checker/index.md) | Helper tool to verify if the given file exists. | 9 | | [org.rewedigital.konversation.Formatter](../org.rewedigital.konversation/-formatter/index.md) | Abstraction layer to format a string. This function just provides a platform specific `sprintf()` implementation. | 10 | | [kotlin.collections.Iterable](../org.rewedigital.konversation/kotlin.collections.-iterable/index.md) (extensions in package org.rewedigital.konversation) | | 11 | | [kotlin.collections.Iterable](../org.rewedigital.konversation/kotlin.collections.-iterable.md) (extensions in package org.rewedigital.konversation) | | 12 | | [org.rewedigital.konversation.Konversation](../org.rewedigital.konversation/-konversation/index.md) | The interface for accessing Konversation. | 13 | | [org.rewedigital.konversation.Output](../org.rewedigital.konversation/-output/index.md) | Holds a static output of a reply. | 14 | | [org.rewedigital.konversation.Random](../org.rewedigital.konversation/-random/index.md) | Abstraction layer for a random number generator. | 15 | | [org.rewedigital.konversation.Reader](../org.rewedigital.konversation/-reader/index.md) | Helper class to read files. | 16 | -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/Intent.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import org.rewedigital.konversation.parser.Utterance 4 | 5 | typealias Prompt = MutableList 6 | 7 | /** 8 | * The intent of the user, holding the utterances, prompts and so on. 9 | */ 10 | data class Intent( 11 | /** The name of this intent. Typically the generated kson file will have this file name. */ 12 | val name: String, 13 | /** The utterances of this intent. That are the sentences the user can say to invoke this intent. */ 14 | val utterances: MutableList = mutableListOf(), 15 | /** The prompt of this intent. That are the outputs what the voice application will say or show the user. */ 16 | val prompt: Prompt = mutableListOf(), 17 | /** The reprompt which is said when the user gives no input. */ 18 | val reprompt: MutableMap = mutableMapOf(), 19 | /** The input context, for future usage. */ 20 | var inContext: MutableList = mutableListOf(), 21 | /** The output context, for future usage. */ 22 | var outContext: MutableList = mutableListOf(), 23 | /** All annotations related to the intent. */ 24 | val annotations: MutableMap> = mutableMapOf(), 25 | /** The suggestions what the user can say next when using this intent. */ 26 | val suggestions: MutableList = mutableListOf(), 27 | /** The extras e.g. for UI Elements, for future usage. */ 28 | val extras: MutableMap = mutableMapOf()) -------------------------------------------------------------------------------- /runtime-js/src/main/kotlin/org/rewedigital/konversation/Reader.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | internal external fun require(module: String): dynamic 4 | 5 | /** 6 | * Helper class to read files. 7 | */ 8 | actual class Reader { 9 | /** 10 | * Loads a reply for a given environment. 11 | * @param name The name of the reply. 12 | * @param environment The environment of the reply. 13 | */ 14 | actual fun loadReply(name: String, environment: Environment): Reply { 15 | val json = try { 16 | val fs = require("fs") 17 | val content = fs.readFileSync("./$name.kson", "utf8") as String 18 | JSON.parse(content) as dynamic 19 | } catch (e: Throwable) { 20 | if (e.message?.startsWith("ENOENT:") == false) { 21 | val request = XMLHttpRequest() 22 | request.open("GET", "$name.kson", false) 23 | request.send(null) 24 | 25 | if (request.status == 200) { 26 | JSON.parse(request.responseText) 27 | } else { 28 | throw Error("HTTP-Error: " + request.status) 29 | } 30 | } else { 31 | throw e 32 | } 33 | } 34 | return ReplyImpl(json) 35 | } 36 | } 37 | 38 | internal external class XMLHttpRequest { 39 | fun open(method: String, file: String, async: Boolean) 40 | fun send(payload: String?) 41 | 42 | val status: Int 43 | val responseText: String 44 | } -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-konversation/index.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Konversation](./index.md) 2 | 3 | # Konversation 4 | 5 | `open class Konversation` 6 | 7 | The interface for accessing Konversation. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Konversation(name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, environment: `[`Environment`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-environment/index.md)`)`
Creates a new Konversation object with the given options. | 14 | 15 | ### Properties 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [name](name.md) | `val name: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
The conversation name you want to load. | 20 | 21 | ### Functions 22 | 23 | | Name | Summary | 24 | |---|---| 25 | | [createOutput](create-output.md) | `fun createOutput(data: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> = emptyMap()): `
Creates a static randomized output for your voice application. The [data](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-konversation/create-output/data.md) will be applied to the output so that you can customize the output with your values. | 26 | -------------------------------------------------------------------------------- /cli/src/test/kotlin/org/rewedigital/konversation/parser/PermutatorTest.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.parser 2 | 3 | import org.junit.Test 4 | import kotlin.test.assertEquals 5 | 6 | class PermutatorTest { 7 | @Test 8 | fun `verify generation of 1 permutations`() { 9 | verifyPermutations("{a}", "a") 10 | } 11 | 12 | @Test 13 | fun `verify generation of 2 permutations`() { 14 | verifyPermutations("{a|b}", "a", "b") 15 | } 16 | 17 | @Test 18 | fun `verify generation of 3 permutations`() { 19 | verifyPermutations("{a|b|c}", "a", "b", "c") 20 | } 21 | 22 | @Test 23 | fun `verify that masking works`() { 24 | verifyPermutations("\\{a|b\\}", "\\{a|b\\}") 25 | } 26 | 27 | @Test 28 | fun `verify processing of variables`() { 29 | verifyPermutations("\${a.b}", "\${a.b}") 30 | } 31 | 32 | @Test 33 | fun `verify mixed input`() { 34 | verifyPermutations("\${a.b} {c|d} \\{e|f\\} {g}", "\${a.b} c \\{e|f\\} g", "\${a.b} d \\{e|f\\} g") 35 | } 36 | 37 | private fun verifyPermutations(input: String, vararg expected: String) { 38 | val actual = Permutator.generate(input) 39 | assertEquals(expected.size, actual.size, "Unexpected count of permutations") 40 | for (i in 0 until expected.size) { 41 | assertEquals(expected[i], actual[i], "${i.asOrdinal()} permutation has unexpected value") 42 | } 43 | } 44 | 45 | private fun Int.asOrdinal(): String = when (this) { 46 | 0 -> "First" 47 | 1 -> "Second" 48 | 2 -> "Third" 49 | 3 -> "Fourth" 50 | else -> "${this + 1}." 51 | } 52 | } -------------------------------------------------------------------------------- /docs/runtime-js/org.rewedigital.konversation/-konversation-js/-output-js/index.md: -------------------------------------------------------------------------------- 1 | [runtime-js](../../../index.md) / [org.rewedigital.konversation](../../index.md) / [KonversationJs](../index.md) / [OutputJs](./index.md) 2 | 3 | # OutputJs 4 | 5 | `class OutputJs` 6 | 7 | ### Constructors 8 | 9 | | Name | Summary | 10 | |---|---| 11 | | [<init>](-init-.md) | `OutputJs(output: )`
`OutputJs(displayText: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, ssml: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, reprompts: dynamic, suggestions: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>, extras: dynamic)` | 12 | 13 | ### Properties 14 | 15 | | Name | Summary | 16 | |---|---| 17 | | [displayText](display-text.md) | `val displayText: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
The display test. | 18 | | [extras](extras.md) | `val extras: dynamic`
The strings for UI elements | 19 | | [reprompts](reprompts.md) | `val reprompts: dynamic`
The reprompts which should the user hear when the user gives no input. | 20 | | [ssml](ssml.md) | `val ssml: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
The Speech Synthesis Markup Language, the spoken output. | 21 | | [suggestions](suggestions.md) | `val suggestions: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>`
The list of suggestions which should been displayed. | 22 | -------------------------------------------------------------------------------- /cli/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'kotlin-platform-jvm' 3 | id 'application' 4 | id 'org.rewedigital.konversation' version '1.0.0' 5 | id 'jacoco' 6 | } 7 | 8 | apply plugin: 'application' 9 | apply plugin: 'kotlin' 10 | 11 | group 'org.rewedigital.voice' 12 | version '1.1.0' 13 | 14 | repositories { 15 | maven { url "http://dl.bintray.com/kotlin/kotlin-eap" } 16 | maven { url "https://plugins.gradle.org/m2/" } 17 | jcenter() 18 | mavenCentral() 19 | } 20 | 21 | dependencies { 22 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 23 | compile "org.jetbrains.kotlin:kotlin-stdlib" 24 | compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1' 25 | compile project(':shared') 26 | testCompile project(':shared') 27 | compile project(':runtime-jvm') 28 | testCompile "junit:junit:4.12" 29 | testCompile "org.jetbrains.kotlin:kotlin-test" 30 | testCompile "org.jetbrains.kotlin:kotlin-test-junit" 31 | } 32 | 33 | sourceSets { 34 | main.java.srcDirs += 'src/main/kotlin/' 35 | test.java.srcDirs += 'src/test/kotlin/' 36 | } 37 | 38 | compileKotlin { 39 | kotlinOptions.jvmTarget = "1.8" 40 | } 41 | compileTestKotlin { 42 | kotlinOptions.jvmTarget = "1.8" 43 | } 44 | 45 | task fatJar(type: Jar) { 46 | manifest.attributes 'Main-Class': 'org.rewedigital.konversation.Cli' 47 | archiveName "konversation.jar" 48 | baseName = project.name 49 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } 50 | with jar 51 | } 52 | mainClassName = 'org.rewedigital.konversation.Cli' 53 | run.main = 'org.rewedigital.konversation.Cli' 54 | 55 | jacocoTestReport.reports { 56 | xml.enabled true 57 | html.enabled true 58 | } -------------------------------------------------------------------------------- /runtime-shared/src/main/kotlin/org/rewedigital/konversation/ResourceLocator.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * Internal helper for choosing the right resources. 5 | */ 6 | internal open class ResourceLocator { 7 | /** 8 | * Loads a resource by name and its specific environment. 9 | */ 10 | fun locate(konversation: String, environment: Environment): String { 11 | val prefix = "konversation" 12 | val locale = environment.locale.toLowerCase().replace('-', '_') 13 | val lang = locale.split('_').first() 14 | return returnIfExists("$prefix-${environment.platform}-$locale/$konversation.kson") 15 | .orIfExists("$prefix-${environment.platform}-$lang/$konversation.kson") 16 | .orIfExists("$prefix-$locale/$konversation.kson") 17 | .orIfExists("$prefix-$lang/$konversation.kson") 18 | .orIfExists("$prefix-${environment.platform}/$konversation.kson") 19 | .orIfExists("$prefix/$konversation.kson") 20 | .orThrow("Konversation with the name \"$konversation\" not found") 21 | } 22 | 23 | /** 24 | * @hide internal method just open for testing 25 | */ 26 | open fun checkPath(path: String): Boolean = FileChecker().exists(path) 27 | 28 | private fun returnIfExists(path: String): String? = 29 | if (checkPath(path)) { 30 | path 31 | } else { 32 | null 33 | } 34 | 35 | private fun String?.orIfExists(path: String): String? = 36 | this ?: if (checkPath(path)) { 37 | path 38 | } else { 39 | null 40 | } 41 | 42 | private fun String?.orThrow(error: String): String = 43 | this ?: throw RuntimeException(error) 44 | } -------------------------------------------------------------------------------- /gradle-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'kotlin-platform-jvm' 3 | id 'maven-publish' 4 | id 'java-gradle-plugin' 5 | id 'com.gradle.plugin-publish' version '0.10.0' 6 | } 7 | 8 | apply plugin: 'kotlin' 9 | 10 | group 'org.rewedigital.konversation' 11 | version rootProject.ext.versions.gradle_plugin 12 | 13 | configurations { 14 | embed 15 | } 16 | 17 | dependencies { 18 | implementation(gradleApi()) 19 | implementation(localGroovy()) 20 | compileOnly project(":cli") 21 | embed project(':cli') 22 | compile "org.jetbrains.kotlin:kotlin-stdlib" 23 | } 24 | 25 | pluginBundle { 26 | website = 'https://rewe-digital.github.io/Konversation' 27 | vcsUrl = 'https://github.com/rewe-digital/Konversation' 28 | 29 | plugins { 30 | konversation { 31 | displayName = 'Konversation compiler' 32 | description = 'Konversation is a tool to generate rich and diversified responses to the user of voice applications. This gradle plugin will compile your ksv files to kson files and add it to your resource for the runtime library.' 33 | tags = ['konversation', 'voice', 'alexa', 'google assistant'] 34 | } 35 | } 36 | } 37 | 38 | gradlePlugin { 39 | plugins { 40 | konversation { 41 | id = 'org.rewedigital.konversation' 42 | description = 'Konversation is a tool to generate rich and diversified responses to the user of voice applications. This gradle plugin will compile your ksv files to kson files and add it to your resource for the runtime library.' 43 | implementationClass = 'org.rewedigital.konversation.KonversationPlugin' 44 | } 45 | } 46 | } 47 | 48 | repositories { 49 | jcenter() 50 | mavenLocal() 51 | } 52 | 53 | sourceSets { 54 | main.java.srcDirs += 'src/main/kotlin/' 55 | } 56 | 57 | jar { 58 | dependsOn configurations.embed 59 | from { configurations.embed.collect { zipTree(it) } } 60 | } -------------------------------------------------------------------------------- /cli-integrations/chocolatey/konversation.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | konversation 5 | 1.1.0 6 | https://github.com/rewe-digital/Konversation/tree/master/cli-integrations/chocolatey 7 | René Kilczan 8 | Konversation 9 | René Kilczan 10 | https://github.com/rewe-digital/Konversation/ 11 | 2019 REWE Digital GmbH 12 | https://github.com/rewe-digital/Konversation/blob/master/LICENSE 13 | false 14 | https://github.com/rewe-digital/Konversation/ 15 | https://github.com/rewe-digital/Konversation/ 16 | konversation ssml google-home alexa cli 17 | Konversation is a tool to generate rich and diversified responses to the user of a voice application. 18 | 22 | https://github.com/rewe-digital/Konversation/releases 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/generator/dialogflow/Response.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.dialogflow 2 | 3 | import org.rewedigital.konversation.forEachBreakable 4 | import org.rewedigital.konversation.generator.NodeExporter 5 | import org.rewedigital.konversation.generator.Printer 6 | 7 | data class Response( 8 | val action: String, 9 | val messages: List, 10 | val parameters: List, 11 | val resetContexts: Boolean = false 12 | ) : NodeExporter { 13 | override fun prettyPrinted(printer: Printer) { 14 | printer(""" { 15 | "resetContexts": $resetContexts, 16 | "action": "$action", 17 | "affectedContexts": [], 18 | "parameters": [""") 19 | if(parameters.isNotEmpty()) { 20 | printer("\n") 21 | parameters.forEachBreakable { 22 | it.prettyPrinted(printer) 23 | if (hasNext()) printer(",") 24 | printer("\n") 25 | } 26 | printer(" ") 27 | } 28 | printer("""], 29 | "messages": [""") 30 | messages.forEachBreakable { 31 | it.prettyPrinted(printer) 32 | if (hasNext()) printer(",") 33 | printer("\n") 34 | } 35 | printer(""" ], 36 | "defaultResponsePlatforms": {}, 37 | "speech": [] 38 | }""") 39 | } 40 | 41 | override fun minified(printer: Printer) { 42 | printer("""{"resetContexts":$resetContexts,"action":"$action","affectedContexts":[],"parameters":[""") 43 | parameters.forEachBreakable { 44 | it.minified(printer) 45 | if (hasNext()) printer(",") 46 | } 47 | printer("""],"messages":[""") 48 | messages.forEachBreakable { 49 | it.minified(printer) 50 | if (hasNext()) printer(",") 51 | } 52 | printer("""],"defaultResponsePlatforms":{},"speech":[]}""") 53 | } 54 | } -------------------------------------------------------------------------------- /docs/runtime-jvm/org.rewedigital.konversation/-answer-impl/index.md: -------------------------------------------------------------------------------- 1 | [runtime-jvm](../../index.md) / [org.rewedigital.konversation](../index.md) / [AnswerImpl](./index.md) 2 | 3 | # AnswerImpl 4 | 5 | `class AnswerImpl` 6 | 7 | ### Constructors 8 | 9 | | Name | Summary | 10 | |---|---| 11 | | [<init>](-init-.md) | `AnswerImpl(parts: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<> = mutableListOf(), suggestions: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = mutableListOf(), reprompts: `[`MutableMap`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>> = mutableMapOf())` | 12 | 13 | ### Properties 14 | 15 | | Name | Summary | 16 | |---|---| 17 | | [parts](parts.md) | `val parts: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<>` | 18 | | [reprompts](reprompts.md) | `val reprompts: `[`MutableMap`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>>` | 19 | | [suggestions](suggestions.md) | `val suggestions: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` | 20 | -------------------------------------------------------------------------------- /file-formats.md: -------------------------------------------------------------------------------- 1 | # File Formats 2 | 3 | Currently are two file formats supported `ksv` and `grammar` files. For defining slot-values or entities you 4 | can use the syntax of `value` files. 5 | 6 | ## ksv files 7 | The syntax of ksv files are an invention of [René Kilczan](https://github.com/rekire) and [Melanie Weitz]. 8 | 9 | ## grammar files 10 | 11 | The syntax of grammar files is invented by [Kay Lerch](https://github.com/KayLerch) for his 12 | [Alexa Skill Utterance and Schema Generator](https://github.com/KayLerch/alexa-utterance-generator). 13 | 14 | The restriction of grammar files is that you cannot define your prompts, reprompts and suggestions. Why you 15 | should my still prefer this tool instead of the Utterance Generator, is that each generated utterance is cached. 16 | That makes the generation of the Alexa Schema much faster. You could even generate millions of utterances within 17 | an acceptable time frame. Even if you plan to migrate you can use just your grammar files for the beginning. 18 | 19 | The best thing is we have a cli which is a faster and has a lower memory footprint. 20 | 21 | Check also the guide for [migrate your grammar files](./grammar-file-migration.md) and full specification of the 22 | [grammar file format](https://github.com/KayLerch/alexa-utterance-generator#31-grammar-syntax-for-sample-utterance-definitions). 23 | 24 | 25 | ### Restrictions 26 | Please note that for right now the intent names have to be in its independed line, that inline syntax is 27 | currently not supported. Also the slot value inline format is current not supported. The workaround is 28 | to copy that blocks to own files. E.g. you have 29 | 30 | {Ingredient}: Egg, Suggar, Floor, Water 31 | 32 | You need to store those values in a file called `values/Ingredient.values` with the content: 33 | 34 | Egg 35 | Suggar 36 | Floor 37 | Water 38 | 39 | Extending system slots like in this example is not supported too: 40 | 41 | {AMAZON.US_CITY}: new york, big apple 42 | 43 | ## value files 44 | -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/generator/dialogflow/ResponseParameter.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.dialogflow 2 | 3 | import org.rewedigital.konversation.generator.NodeExporter 4 | import org.rewedigital.konversation.generator.Printer 5 | import java.util.* 6 | 7 | data class ResponseParameter( 8 | val id: UUID, 9 | val dataType: String, 10 | val name: String, 11 | val value: String, 12 | val isList: Boolean 13 | ) : NodeExporter { 14 | constructor(slot: String, isList: Boolean) : this( 15 | id = UUID.nameUUIDFromBytes(slot.toByteArray()), 16 | dataType = "@${slot.slotType}", 17 | name = slot.slotName, 18 | value = "$${slot.slotName}", 19 | isList = isList 20 | ) 21 | 22 | override fun prettyPrinted(printer: Printer) = 23 | printer(""" { 24 | "id": "$id", 25 | "dataType": "$dataType", 26 | "name": "$name", 27 | "value": "$value", 28 | "isList": $isList 29 | }""") 30 | 31 | override fun minified(printer: Printer) = 32 | printer("""{"id":"$id","dataType":"$dataType","name":"$name","value":"$value","isList":$isList}""") 33 | } 34 | 35 | private val String.slotType: String 36 | get() = if (contains(':')) { 37 | substringAfter(':') 38 | } else { 39 | this 40 | }.removePrefix("AMAZON.") 41 | .asSystemType() 42 | 43 | private val String.slotName: String 44 | get() = if (contains(':')) { 45 | substringBefore(':') 46 | } else { 47 | this 48 | } 49 | 50 | private fun String.asSystemType() = 51 | when (this) { 52 | "any" -> "sys.any" 53 | "number" -> "sys.number" 54 | "ordinal" -> "sys.ordinal" 55 | "color" -> "sys.color" 56 | "de-city" -> "sys.geo-city" 57 | "at-city" -> "sys.geo-city" 58 | "eu-city" -> "sys.geo-city" 59 | "us-city" -> "sys.geo-city" 60 | "gb-city" -> "sys.geo-city" 61 | else -> this 62 | } -------------------------------------------------------------------------------- /konversation.json: -------------------------------------------------------------------------------- 1 | { 2 | "auth": { 3 | "alexaRefreshToken": "Atzr|IwEBIBIPqFJZXury7-x6DfbCXIH8pcZoqhcloj06hPZvB9s76PH2hSkNN7ufRYaKwdvx9tWlW97Fe_-BVERDDn_uhxllX2VmIj-mYDvKOSDIdogNrc33nJl9wjQ8QkOt8RSt3oIUAr05Wl2X_4aRWnjyJU6kmA1n-fQtPQNZedx-dANcU9yS-a0sAWNEkipt86-j58mnSLyhRqorBk68BQ2hm1H7fllfe-qzyOQmLRictRGKJvm0yByMPL-jqB5EdWKnlliO6jVQjmxiCxpkx4RVYXnebg6WT5eD6GZOpGLt1zS9EK_Yq9m-QIkPmpepmbBgY3siAZxdXuHMJX_dguLfdZTC7xtTdiSMyRl78JI2N5uN-Fq3DeT6cLD05N7a9OhRKZEM274sQ9yDnxHcpBEkYZANO4pzA-riB44I57bnrYXpM5YroEln1-34EVscLwbQgjYpDNc7kzRsXnghtl31L5FggxKD86vdIxldlHJ485cSPdUXlYHktm6iL9w40MT3-n_I5UCgXNQqi0Jhesnm-XqMJ6zoKHA97wOZ9x4wMM33ebIa5S4bNhz9oD5S3jurcw7VysDKHbbNUqM_99uUqvEH", 4 | "dialogflowServiceAccount": { 5 | "path": "C:\\Users\\rene.kilczan\\Programmierung\\REWE-Voice\\ServiceAccount-Provisionierung-91bc75aef8a5.json" 6 | } 7 | }, 8 | "projects": { 9 | "test": { 10 | "alexa": { 11 | "skillId": "amzn1.ask.skill.example" 12 | }, 13 | "dialogflow": { 14 | "projectId": "example-project" 15 | }, 16 | "invocations": { 17 | "de": "test" 18 | } 19 | }, 20 | "rewe markt": { 21 | "alexa": { 22 | "skillId": "amzn1.ask.skill.c2b9788d-7a97-419d-9236-e440daad0599" 23 | }, 24 | "dialogflow": { 25 | "projectId": "rewedigital-assistent-prd-v001" 26 | }, 27 | "invocations": { 28 | "de": "rewe" 29 | } 30 | }, 31 | "rewe markt demo": { 32 | "alexa": { 33 | "skillId": "amzn1.ask.skill.b5295b79-d3d1-4839-a71a-946c47fd9be6" 34 | }, 35 | "dialogflow": { 36 | "projectId": "rewedigital-assistent-pre-v001" 37 | }, 38 | "invocations": { 39 | "de": "rewe demo" 40 | } 41 | }, 42 | "rewe rezepte demo": { 43 | "alexa": { 44 | "skillId": "amzn1.ask.skill.b5295b79-d3d1-4839-a71a-946c47fd9be6" 45 | }, 46 | "dialogflow": { 47 | "projectId": "rd-bigdata-voicerdk-pre" 48 | }, 49 | "invocations": { 50 | "de": "rewe rezepte demo" 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /runtime-js/src/main/kotlin/org/rewedigital/konversation/InterOp.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | /** 4 | * This class is the interop layer to use just primitiv values. Lists will be converted to Arrays and Maps to simple objects. 5 | */ 6 | @JsName("Konversation") 7 | class KonversationJs(name: String, environment: dynamic) : Konversation(name, convertToEnvironment(environment)) { 8 | /** 9 | * Creates a static randomized output for your voice application. 10 | * The [data] will be applied to the output so that you can customize the output with your values. 11 | */ 12 | @JsName("createOutput") 13 | fun createJavaScriptOutput(data: dynamic = null): OutputJs { 14 | val map = js("Object").keys(js("data||{}")).map { key -> 15 | (key as String) to (data[key] as Any) 16 | } as Array> 17 | return OutputJs(createOutput(map.toMap())) 18 | } 19 | 20 | @JsName("Output") 21 | class OutputJs( 22 | /** The display test. */ 23 | val displayText: String, 24 | /** The Speech Synthesis Markup Language, the spoken output. */ 25 | val ssml: String, 26 | /** The reprompts which should the user hear when the user gives no input. */ 27 | val reprompts: dynamic, 28 | /** The list of suggestions which should been displayed. */ 29 | val suggestions: Array, 30 | /** The strings for UI elements */ 31 | val extras: dynamic) { 32 | constructor(output: Output) : this( 33 | output.displayText, 34 | output.ssml, 35 | output.reprompts.toDynamic(), 36 | output.suggestions.toTypedArray(), 37 | output.extras.toDynamic()) 38 | } 39 | } 40 | 41 | @Suppress("UNUSED_PARAMETER") // env is used by the js() method 42 | private fun convertToEnvironment(env: dynamic) : Environment { 43 | val nonNullEnv = js("env || {platform:'', locale:''}") 44 | return Environment(nonNullEnv["platform"] as String, nonNullEnv["locale"] as String) 45 | } 46 | 47 | private fun Map.toDynamic(): dynamic { 48 | val output = js("{}") 49 | entries.forEach { (k, v) -> 50 | output[k] = v 51 | } 52 | return output 53 | } -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/generator/dialogflow/DialogflowIntent.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.dialogflow 2 | 3 | import org.rewedigital.konversation.forEachBreakable 4 | import org.rewedigital.konversation.generator.NodeExporter 5 | import org.rewedigital.konversation.generator.Printer 6 | import java.util.* 7 | 8 | data class DialogflowIntent( 9 | val auto: Boolean = true, 10 | val contexts: List = emptyList(), 11 | val events: List = emptyList(), 12 | val fallbackIntent: Boolean = false, 13 | val id: UUID, 14 | val lastUpdate: Long, 15 | val name: String, 16 | val priority: Int = 500000, 17 | val responses: List = emptyList(), 18 | val webhookForSlotFilling: Boolean = false, 19 | val webhookUsed: Boolean = true 20 | ) : NodeExporter { 21 | override fun prettyPrinted(printer: Printer) { 22 | printer("""{ 23 | "id": "$id", 24 | "name": "$name", 25 | "auto": $auto, 26 | "contexts": [], 27 | "responses": [""") 28 | responses.forEachBreakable { 29 | printer("\n") 30 | it.prettyPrinted(printer) 31 | if (hasNext()) printer(",") 32 | } 33 | if (responses.isNotEmpty()) printer("\n ") 34 | printer("""], 35 | "priority": $priority, 36 | "webhookUsed": $webhookUsed, 37 | "webhookForSlotFilling": $webhookForSlotFilling, 38 | "lastUpdate": $lastUpdate, 39 | "fallbackIntent": $fallbackIntent, 40 | "events": [""") 41 | printer(events.joinToString(separator = ",") { "\n \"$it\"" }) 42 | if (events.isNotEmpty()) printer("\n ") 43 | printer("]\n}") 44 | } 45 | 46 | override fun minified(printer: Printer) { 47 | printer("""{"id":"$id","name":"$name","auto":$auto,"contexts":[],"responses":[""") 48 | responses.forEachBreakable { 49 | it.minified(printer) 50 | if (hasNext()) printer(",") 51 | } 52 | printer("""],"priority":$priority,"webhookUsed":$webhookUsed,"webhookForSlotFilling":$webhookForSlotFilling,"lastUpdate":$lastUpdate,"fallbackIntent":$fallbackIntent,"events":[""") 53 | printer(events.joinToString(separator = ",") { "\"$it\"" }) 54 | printer("]}") 55 | } 56 | } -------------------------------------------------------------------------------- /cli/src/test/kotlin/org/rewedigital/konversation/generator/dialogflow/EntityTest.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.dialogflow 2 | 3 | import org.junit.Test 4 | import org.rewedigital.konversation.assertEqualsIgnoringLineBreaks 5 | 6 | class EntityTest { 7 | @Test 8 | fun exportZeroSynonyms() { 9 | val sut = Entity(null, "master", listOf()) 10 | val sb = StringBuilder() 11 | sut.prettyPrinted { str -> sb.append(str) } 12 | assertEqualsIgnoringLineBreaks(zeroSynonyms.prettyPrinted, sb.toString()) 13 | sb.clear() 14 | sut.minified { str -> sb.append(str) } 15 | assertEqualsIgnoringLineBreaks(zeroSynonyms.minified, sb.toString()) 16 | } 17 | 18 | @Test 19 | fun exportOneSynonym() { 20 | val sut = Entity(null, "master", listOf("synonym1")) 21 | val sb = StringBuilder() 22 | sut.prettyPrinted { str -> sb.append(str) } 23 | assertEqualsIgnoringLineBreaks(oneSynonym.prettyPrinted, sb.toString()) 24 | sb.clear() 25 | sut.minified { str -> sb.append(str) } 26 | assertEqualsIgnoringLineBreaks(oneSynonym.minified, sb.toString()) 27 | } 28 | 29 | @Test 30 | fun exportTwoSynonyms() { 31 | val sut = Entity(null, "master", listOf("synonym1", "synonym2")) 32 | val sb = StringBuilder() 33 | sut.prettyPrinted { str -> sb.append(str) } 34 | assertEqualsIgnoringLineBreaks(twoSynonyms.prettyPrinted, sb.toString()) 35 | sb.clear() 36 | sut.minified { str -> sb.append(str) } 37 | assertEqualsIgnoringLineBreaks(twoSynonyms.minified, sb.toString()) 38 | } 39 | 40 | data class Result(val minified: String, val prettyPrinted: String) 41 | 42 | companion object { 43 | val zeroSynonyms = Result("{\"value\":\"master\",\"synonyms\":[\"master\"]}", """ { 44 | "value": "master", 45 | "synonyms": [ 46 | "master" 47 | ] 48 | }""") 49 | val oneSynonym = Result("{\"value\":\"master\",\"synonyms\":[\"master\",\"synonym1\"]}", """ { 50 | "value": "master", 51 | "synonyms": [ 52 | "master", 53 | "synonym1" 54 | ] 55 | }""") 56 | val twoSynonyms = Result("{\"value\":\"master\",\"synonyms\":[\"master\",\"synonym1\",\"synonym2\"]}", """ { 57 | "value": "master", 58 | "synonyms": [ 59 | "master", 60 | "synonym1", 61 | "synonym2" 62 | ] 63 | }""") 64 | } 65 | } -------------------------------------------------------------------------------- /docs/shared/org.rewedigital.konversation/-reply/index.md: -------------------------------------------------------------------------------- 1 | [shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Reply](./index.md) 2 | 3 | # Reply 4 | 5 | `open class Reply` 6 | 7 | Each Reply contains multiple [Part](../-part/index.md)s, suggestions and reprompts. The parts can be for the display or just for the audio output. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Reply(parts: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`Part`](../-part/index.md)`> = mutableListOf(), suggestions: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = mutableListOf(), reprompts: `[`MutableMap`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>> = mutableMapOf())`
Each Reply contains multiple [Part](../-part/index.md)s, suggestions and reprompts. The parts can be for the display or just for the audio output. | 14 | 15 | ### Properties 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [parts](parts.md) | `open val parts: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`Part`](../-part/index.md)`>`
The parts of the response which should be build. | 20 | | [reprompts](reprompts.md) | `open val reprompts: `[`MutableMap`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>>`
The reprompts which are used in context of the runtime. | 21 | | [suggestions](suggestions.md) | `open val suggestions: `[`MutableList`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>`
The suggestions which are used in context of the runtime. | 22 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /runtime-jvm/build/generated/source/kaptKotlin/main/org/rewedigital/konversation/PartImplJsonAdapter.kt: -------------------------------------------------------------------------------- 1 | // Code generated by moshi-kotlin-codegen. Do not edit. 2 | package org.rewedigital.konversation 3 | 4 | import com.squareup.moshi.* 5 | import kotlin.String 6 | 7 | class PartImplJsonAdapter(moshi: Moshi) : JsonAdapter() { 8 | private val options: JsonReader.Options = JsonReader.Options.of("variants", "type") 9 | 10 | private val mutableListOfStringAdapter: JsonAdapter> = 11 | moshi.adapter>(Types.newParameterizedType(MutableList::class.java, String::class.java), kotlin.collections.emptySet(), "variants") 12 | 13 | private val partTypeAdapter: JsonAdapter = 14 | moshi.adapter(PartType::class.java, kotlin.collections.emptySet(), "type") 15 | 16 | override fun toString(): String = "GeneratedJsonAdapter(PartImpl)" 17 | 18 | override fun fromJson(reader: JsonReader): PartImpl { 19 | var variants: MutableList? = null 20 | var type: PartType? = null 21 | reader.beginObject() 22 | while (reader.hasNext()) { 23 | when (reader.selectName(options)) { 24 | 0 -> variants = mutableListOfStringAdapter.fromJson(reader) ?: throw JsonDataException("Non-null value 'variants' was null at ${reader.path}") 25 | 1 -> type = partTypeAdapter.fromJson(reader) ?: throw JsonDataException("Non-null value 'type' was null at ${reader.path}") 26 | -1 -> { 27 | // Unknown name, skip it. 28 | reader.skipName() 29 | reader.skipValue() 30 | } 31 | } 32 | } 33 | reader.endObject() 34 | var result = PartImpl( 35 | variants = variants ?: throw JsonDataException("Required property 'variants' missing at ${reader.path}"), 36 | type = type ?: throw JsonDataException("Required property 'type' missing at ${reader.path}")) 37 | return result 38 | } 39 | 40 | override fun toJson(writer: JsonWriter, value: PartImpl?) { 41 | if (value == null) { 42 | throw NullPointerException("value was null! Wrap in .nullSafe() to write nullable values.") 43 | } 44 | writer.beginObject() 45 | writer.name("variants") 46 | mutableListOfStringAdapter.toJson(writer, value.variants) 47 | writer.name("type") 48 | partTypeAdapter.toJson(writer, value.type) 49 | writer.endObject() 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /upload-cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | repo="rewe-digital/Konversation" 4 | artifact="konversation-cli.jar" 5 | artifactMineType="application/jar" 6 | source="cli/build/libs/konversation.jar" 7 | version=$1 8 | token=$3 9 | 10 | if [[ $# -ne 3 ]]; then 11 | echo "Missing args!" 12 | echo "$0 " 13 | exit 14 | fi 15 | 16 | if [[ ! -f ${source} ]]; then 17 | echo "Creating jar..." 18 | ./gradlew :cli:fJ 19 | fi 20 | 21 | echo "Create release $version..." 22 | 23 | json=`curl -X POST "https://api.github.com/repos/$repo/releases" -H "Authorization: token $token" -H "Content-Type: application/json" \ 24 | -d "{\"tag_name\": \"v$version\",\"target_commitish\": \"master\",\"name\": \"v$version\",\"body\": \"Release of $version\",\"draft\": false,\"prerelease\": $2}" -s` 25 | url=`node -e "console.log($json.upload_url.replace('{?name,label}',''))"` 26 | 27 | echo "Uploading assert to $url..." 28 | response=`curl "$url?name=$artifact" -X "POST" -H "Authorization: token $token" -H "Content-Type: $artifactMineType" -d "@$source" -s` 29 | jarUrl=`node -e "console.log($response.browser_download_url)"` 30 | echo "Published at $jarUrl" 31 | 32 | echo "Calculating hash..." 33 | sha256=`sha256sum ${source} | cut -d " " -f 1` 34 | 35 | echo "Clone homebrew tap..." 36 | cd build 37 | rm -rf "homebrew-packages" | true 38 | git clone --depth=1 git@github.com:rekire/homebrew-packages.git 39 | cd homebrew-packages/Formula 40 | 41 | 42 | echo "Patching Formula..." 43 | sed -e "s#url .*#url \"$jarUrl\"#g" -e "s/sha256 .*/sha256 \"$sha256\"/g" -i konversation.rb 44 | 45 | echo "Committing changes..." 46 | git add konversation.rb 47 | git commit -m "Update homebrew to version $version" 48 | git tag -a "v$version" -m "v$version" 49 | git push 50 | git push origin --tags 51 | 52 | echo "Patching Chocolatey..." 53 | cd ../../../cli-integrations/chocolatey 54 | sed -e "s#jar: .*#jar: $jarUrl#g" -e "s/checksum: .*/checksum: $sha256/g" -i legal/VERIFICATION.txt 55 | sed -e "s#.*#$version#g" -i konversation.nuspec 56 | git add legal/VERIFICATION.txt konversation.nuspec 57 | # update artifact 58 | rm "tools/konversation.jar" | true 59 | cp "../../$source" "tools/konversation.jar" 60 | git commit -m "Update Chocolatey to version $version" 61 | git tag -a "cli-$version" -m "cli-$version" 62 | git push origin --tags 63 | 64 | echo "Please also update chocolatey with:" 65 | echo "cd cli-integrations/chocolatey" 66 | echo "choco pack" 67 | echo "choco push konversation.$version.nupkg -s https://push.chocolatey.org/" -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | notifications: 4 | email: false 5 | 6 | services: 7 | - docker 8 | 9 | before_script: 10 | - openssl aes-256-cbc -K $encrypted_703101643d9d_key -iv $encrypted_703101643d9d_iv -in travis_rsa.enc -out travis_rsa -d 11 | - ./.travis/configure.sh 12 | 13 | script: 14 | - ./gradlew test build cli:fJ 15 | 16 | before_cache: 17 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 18 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 19 | 20 | cache: 21 | directories: 22 | - $HOME/.gradle/caches/5.1.1 23 | - $HOME/.gradle/caches/jars-1 24 | - $HOME/.gradle/daemon 25 | - $HOME/.gradle/native 26 | - $HOME/.gradle/wrapper 27 | - $HOME/runtime-js/.gradle/nodejs 28 | 29 | jdk: 30 | - openjdk8 31 | 32 | before_deploy: 33 | - .travis/prepare_deployment.sh 34 | 35 | deploy: 36 | - provider: releases 37 | api_key: 38 | secure: Akty5JoTylVDZpKnvL/+uZaBVakrbmNbIQ4Dfp/PSR4zyZdphTbjVQPmrj9L823zScY6D4qocpGBHVRZoiaNpPQc0B7sWs6QxH7J+vW8glvy2rG416Flr1UZBp6r0IyPuUfZ37wHzd5jYfFIheVrbHoGHbtX4NYSZ323o3NvC48KpT3R68KUHISAbfOh26T81XGpWD3CpwNqHc9y5SAaE2aIHkCia2ySvxAEc7FW4g1iU2bt7sSA0JXRcFB1LWshZBxTNo3YzZLwPH7+oM4yKzS5M+poraOdrCffSMKJjCv2ACFie482iYy+3J4EHAx/rbSb4ru9D7UqQHTYIiByalYAVMahUifNDNlBPUyjcrLFJM0KxylGEvumpsABzqWjluOPxOjyZJ+rcqjQzC4Z7ifIRTpVJRq5Bv87H4JhIF8wqYxSeAHWUbQIwsOhr1WOOGYkCselV+sILLHupduWM892Wk+igwYCuVerNiIR1FNJ1yBIr5d9SNj660XMVHPEQ/hZqVCTTEPNcblS9vSHC5+LaQn5SAmOmgLgzSJHjlMTYczALdz8IeadAQgdq01RXbRjf6ni/l/T0m7cbxMzEtK9hLLAhRNg5lik99BI/hAXN9MvcFi1yEVHo0iFMeI0k8k86PVv4vPatmjz9zzXskD+hDy46cP663cm3pGw3sI= 39 | file_glob: true 40 | file: publish/** 41 | skip_cleanup: true 42 | on: 43 | branch: master 44 | repo: rewe-digital/Konversation 45 | tags: true 46 | condition: $TRAVIS_TAG =~ ^cli- 47 | - provider: script 48 | script: .travis/deploy_chocolaty.sh 49 | on: 50 | branch: master 51 | repo: rewe-digital/Konversation 52 | tags: true 53 | condition: $TRAVIS_TAG =~ ^cli- 54 | - provider: script 55 | script: ./gradlew runtime-js:publishNpmPackage 56 | on: 57 | branch: master 58 | repo: rewe-digital/Konversation 59 | tags: true 60 | condition: $TRAVIS_TAG =~ ^js- 61 | - provider: script 62 | script: ./gradlew runtime-jvm:bintrayUpload 63 | on: 64 | branch: master 65 | repo: rewe-digital/Konversation 66 | tags: true 67 | condition: $TRAVIS_TAG =~ ^jvm- 68 | - provider: script 69 | script: ./gradlew gradle-plugin:publishPlugins 70 | on: 71 | branch: master 72 | repo: rewe-digital/Konversation 73 | tags: true 74 | condition: $TRAVIS_TAG =~ ^gradle- -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/generator/dialogflow/DialogflowUtterance.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.dialogflow 2 | 3 | import org.rewedigital.konversation.forEachIterator 4 | import org.rewedigital.konversation.generator.NodeExporter 5 | import org.rewedigital.konversation.generator.Printer 6 | import java.util.* 7 | 8 | data class DialogflowUtterance( 9 | val count: Int, 10 | val `data`: List, 11 | val id: UUID, 12 | val isTemplate: Boolean, 13 | val updated: Long) : NodeExporter { 14 | 15 | override fun prettyPrinted(printer: Printer) { 16 | printer(" {\n") 17 | printer(" \"id\": \"$id\",\n") 18 | printer(" \"data\": [") 19 | if (`data`.isNotEmpty()) { 20 | printer("\n") 21 | data.forEachIterator { 22 | it.prettyPrinted(printer) 23 | if (hasNext()) { 24 | printer(",") 25 | } 26 | printer("\n") 27 | } 28 | printer(" ") 29 | } 30 | printer("],\n") 31 | printer(" \"isTemplate\": $isTemplate,\n") 32 | //printer(" \"updated\": $updated\n") 33 | printer(" \"count\": $count\n") 34 | printer(" }") 35 | } 36 | 37 | override fun minified(printer: Printer) { 38 | printer("""{"id":"$id","data":[""") 39 | data.forEachIterator { 40 | it.minified(printer) 41 | if (hasNext()) { 42 | printer(",") 43 | } 44 | } 45 | printer("""],"isTemplate":$isTemplate,"count":$count}""") 46 | } 47 | 48 | data class UtterancePart( 49 | val text: String, 50 | val alias: String? = null, 51 | val meta: String? = null, 52 | val userDefined: Boolean) : NodeExporter { 53 | 54 | override fun prettyPrinted(printer: Printer) { 55 | printer(" {\n") 56 | printer(" \"text\": \"$text\",\n") 57 | alias?.let { 58 | printer(" \"alias\": \"$alias\",\n") 59 | } 60 | meta?.let { 61 | printer(" \"meta\": \"$meta\",\n") 62 | } 63 | printer(" \"userDefined\": $userDefined\n") 64 | printer(" }") 65 | } 66 | 67 | override fun minified(printer: Printer) { 68 | printer("{\"text\":\"$text\"") 69 | alias?.let { 70 | printer(",\"alias\":\"$alias\"") 71 | } 72 | meta?.let { 73 | printer(",\"meta\":\"$meta\"") 74 | } 75 | printer(",\"userDefined\":$userDefined}") 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /runtime-shared/src/test/kotlin/org/rewedigital/konversation/ResourceLocatorTest.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import kotlin.test.Test 4 | import kotlin.test.assertEquals 5 | import kotlin.test.assertFailsWith 6 | 7 | open class ResourceLocatorTest { 8 | @Test 9 | fun localeTest() { 10 | val sut = ResourceLocatorMock("konversation/test.kson", 11 | "konversation-de_de/test.kson", 12 | "konversation-de_at/test.kson", 13 | "konversation-fr/test.kson", 14 | "konversation-en/test.kson", 15 | "konversation-en_us/test.kson", 16 | "konversation-en_gb/test.kson", 17 | "konversation-alexa/test.kson", 18 | "konversation-alexa-de_de/test.kson", 19 | "konversation-alexa-de_at/test.kson", 20 | "konversation-alexa-en/test.kson", 21 | "konversation-alexa-en_us/test.kson", 22 | "konversation-alexa-en_gb/test.kson", 23 | "konversation-google/test.kson", 24 | "konversation-google-de_de/test.kson", 25 | "konversation-google-de_at/test.kson", 26 | "konversation-google-en/test.kson", 27 | "konversation-google-en_us/test.kson", 28 | "konversation-google-en_gb/test.kson") 29 | assertEquals("konversation/test.kson", sut.locate("test", Environment("magenta", "es")), "Should fallback to generic konversation.") 30 | assertEquals("konversation-de_de/test.kson", sut.locate("test", Environment("magenta", "de_DE")), "Should provide correct locale.") 31 | assertEquals("konversation-de_de/test.kson", sut.locate("test", Environment("magenta", "De_dE")), "Should provide correct locale with nonsense cases.") 32 | assertEquals("konversation-google-de_de/test.kson", sut.locate("test", Environment("google", "de_de")), "Should provide correct locale and platform.") 33 | assertEquals("konversation-fr/test.kson", sut.locate("test", Environment("magenta", "fr_FR")), "Should fallback to generic locale.") 34 | assertEquals("konversation-alexa/test.kson", sut.locate("test", Environment("alexa", "es")), "Should fallback to generic platform.") 35 | assertFailsWith(RuntimeException::class, message = "Should throw exception when the conversation is not found.") {sut.locate("404", Environment("alexa", "es"))} 36 | } 37 | } 38 | 39 | private class ResourceLocatorMock(private vararg val validPath: String) : ResourceLocator() { 40 | override fun checkPath(path: String) = validPath.contains(path) 41 | } -------------------------------------------------------------------------------- /Update-Guide.md: -------------------------------------------------------------------------------- 1 | # Steps to update the Konversation artifacts 2 | At first make sure that every thing still works, by running all the tests. 3 | ## Java Artifact 4 | ### Bintray 5 | 1. Make sure that in your global gradle configuration (located in `~/.gradle/gradle.properties`) are the keys `bintray.user` and `bintray.apikey`. The username is that one you use to login onto bintray.com, the *API Key* is located in [your profile](https://bintray.com/profile/edit) in the *API Key* section. 6 | 2. Update the version numbers of the artifacts in `/build.gradle` and update if required the dependency in the example project. 7 | 3. Execute `./gradlew runtime-jvm:bintrayUpload` 8 | 4. Verify that you see the artifact on [jcenter](https://jcenter.bintray.com/org/rewedigital/voice/konversation/). 9 | ### Maven Central 10 | 1. Execute the steps for Bintray, then open the [Artifact on Bintray](https://bintray.com/rewe-digital/Konversation/Konversation) and click on the `Maven Central` tab. Then click on the green button "sync". After a view minutes there should be the output "Successfully synced and closed repo." 11 | 2. After a view hours you should be able to see the artifact on [Maven Central](https://search.maven.org/search?q=g:org.rewedigital.voice%20AND%20a:konversation). 12 | ## JavaScript Artifact 13 | ### NPM 14 | 1. Make sure that you are logged in the npm cli. 15 | 2. Execute `./gradlew runtime-js:publishNpmPackage`. 16 | 3. Verify the results on [`npm`](https://www.npmjs.com/package/@rewe-digital/konversation). 17 | ## Gradle Plugin 18 | 1. Make sure that 19 | 2. Execute `./gradlew gradle-plugin:publishPlugins`. 20 | 3. Verify that the update is visible on the [Gradle](https://plugins.gradle.org/plugin/org.rewedigital.konversation). 21 | ## CLI 22 | There are two ways. At first the manual way: 23 | 1. Create the fat jar by executing `./gradlew cli:fatJar` 24 | 2. Create a new release at GitHub. 25 | 3. Upload the created konversation.jar at the release page named as `konversation-cli.jar`. 26 | ### Homebrew 27 | 1. Check out the tap currently at https://github.com/rekire/homebrew-packages 28 | 2. Update the sha256 hash and the (download) url in `konversation/Formular/konversation.rb` 29 | 3. Commit the changes and tag it 30 | ### Chocolaty 31 | 1. Copy the konversation.jar into `cli-integrations/chocolaty/tools` 32 | 2. Update the sha256 hash and the download url in `cli-integrations/chocolaty/tools/legal/VERIFICATION.txt` 33 | 3. Run in cmd or powershell `cli-integrations/chocolaty`: `choco pack && choco push konversation.nupkg -s https://chocolatey.org/` 34 | 35 | Or the more automated way: 36 | 1. Create a token in [GitHub](https://github.com/settings/tokens) with repo permission. 37 | 2. Open a shell e.g. bash 38 | 3. Execute `./upload-cli.sh `. This might take a while since it does the manual steps and creates 2 commits in two repositories and two tags. 39 | 4. Open cmd or powershell (on Windows) 40 | 5. Execute in `cli-integrations/chocolaty`: `choco pack && choco push konversation.nupkg -s https://chocolatey.org/` -------------------------------------------------------------------------------- /docs/runtime-shared/org.rewedigital.konversation/-output/index.md: -------------------------------------------------------------------------------- 1 | [runtime-shared](../../index.md) / [org.rewedigital.konversation](../index.md) / [Output](./index.md) 2 | 3 | # Output 4 | 5 | `data class Output` 6 | 7 | Holds a static output of a reply. 8 | 9 | ### Constructors 10 | 11 | | Name | Summary | 12 | |---|---| 13 | | [<init>](-init-.md) | `Output(displayText: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, ssml: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, reprompts: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>, suggestions: `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>, extras: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>)`
Holds a static output of a reply. | 14 | 15 | ### Properties 16 | 17 | | Name | Summary | 18 | |---|---| 19 | | [displayText](display-text.md) | `val displayText: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
The display test. | 20 | | [extras](extras.md) | `val extras: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>`
The strings for UI elements | 21 | | [reprompts](reprompts.md) | `val reprompts: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>`
The reprompts which should the user hear when the user gives no input. | 22 | | [ssml](ssml.md) | `val ssml: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
The Speech Synthesis Markup Language, the spoken output. | 23 | | [suggestions](suggestions.md) | `val suggestions: `[`List`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>`
The list of suggestions which should been displayed. | 24 | 25 | ### Functions 26 | 27 | | Name | Summary | 28 | |---|---| 29 | | [plus](plus.md) | `operator fun plus(output: `[`Output`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-output/index.md)`): `[`Output`](https://github.com/rewe-digital/konversation/blob/master/docs/shared/org.rewedigital.konversation/-output/index.md) | 30 | -------------------------------------------------------------------------------- /runtime-js/readme.md: -------------------------------------------------------------------------------- 1 | # Konversation (JS-Runtime) [![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][npm-url] [![License: MIT][mit-image]][mit-url] [![Stars][star-img]][star-url] 2 | 3 | This is the runtime library of [Konversation][github-url]. Konversation is a tool to generate rich and 4 | diversified responses to the user of a voice application. 5 | 6 | ## Usage 7 | 8 | At first install the dependency "@rewe-digital/konversation" with the command: 9 | 10 | npm install @rewe-digital/konversation 11 | 12 | Then you can use this example code: 13 | 14 | const Konversation = require("@rewe-digital/konversation").Konversation; 15 | const test = Konversation("test"); 16 | const output = test.createOutput(); // created one randomized response 17 | const ssml = output.ssml; 18 | const displayText = output.displayText; 19 | 20 | The example above requires that you have a `test.kson` file in the same directory as the script itself. 21 | If you want to know how to create the kson files, please check the documentation of the 22 | [konversation cli][cli-readme-url]. 23 | 24 | ## License 25 | 26 | The MIT license (MIT) 27 | 28 | Copyright (c) 2018 REWE Digital GmbH 29 | 30 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 31 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 32 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 33 | persons to whom the Software is furnished to do so, subject to the following conditions: 34 | 35 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 36 | Software. 37 | 38 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 39 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 40 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 41 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 42 | 43 | [travis-image]: https://travis-ci.com/rewe-digital/Konversation.svg?branch=master 44 | [travis-url]: https://travis-ci.com/rewe-digital/Konversation 45 | [npm-image]: https://img.shields.io/npm/v/@rewe-digital/konversation.svg 46 | [npm-url]: https://npmjs.org/package/@rewe-digital/konversation 47 | [downloads-image]: https://img.shields.io/npm/dm/@rewe-digital/konversation.svg 48 | [mit-image]: https://img.shields.io/badge/License-MIT-yellow.svg 49 | [mit-url]: https://opensource.org/licenses/MIT 50 | [github-url]: https://github.com/rewe-digital/Konversation 51 | [cli-readme-url]: https://github.com/rewe-digital/Konversation/blob/master/cli/readme.md 52 | [star-img]: https://img.shields.io/github/stars/rewe-digital/Konversation.svg?style=social&label=Star&maxAge=3600 53 | [star-url]: https://github.com/rewe-digital/Konversation/stargazers -------------------------------------------------------------------------------- /runtime-shared/src/main/kotlin/org/rewedigital/konversation/Konversation.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import kotlin.js.JsName 4 | 5 | /** 6 | * The interface for accessing Konversation. 7 | * 8 | * @property name The conversation name you want to load. 9 | * @param environment The environment of the conversation to load. 10 | * @constructor Creates a new Konversation object with the given options. 11 | */ 12 | @JsName("KonversationKt") 13 | open class Konversation(val name: String, private val environment: Environment) { 14 | private val answer = Reader().loadReply(name, environment) 15 | 16 | private data class OutputHolder(val ssml: String, val text: String) 17 | 18 | private fun buildOutput(): OutputHolder { 19 | val text = StringBuilder() 20 | val ssml = StringBuilder("") 21 | answer.parts 22 | .forEachIterator { part -> 23 | val randomPart = part.variants[random.next(part.variants.size)] 24 | if (part.type == PartType.Text) { 25 | text.append(randomPart) 26 | if (hasNext()) 27 | text.append(" ") 28 | } 29 | ssml.append(randomPart) 30 | if (hasNext()) 31 | ssml.append(" ") 32 | } 33 | ssml.append("") 34 | return OutputHolder(ssml.toString(), text.toString().trimEnd()) 35 | } 36 | 37 | internal fun String.applyVariables(data: Map) = 38 | regex.replace(this) { matchResult -> 39 | val needle = matchResult.groups.first()?.value 40 | val fieldName = matchResult.groups.filterNotNull().last().value 41 | if (needle?.startsWith("%") == true) { 42 | Formatter().format(environment.locale, needle.substring(0, needle.indexOf('$')), data[fieldName]) 43 | } else { 44 | data[fieldName].toString() 45 | } 46 | } 47 | 48 | /** 49 | * Creates a static randomized output for your voice application. 50 | * The [data] will be applied to the output so that you can customize the output with your values. 51 | */ 52 | fun createOutput(data: Map = emptyMap()) = buildOutput().run { 53 | Output(displayText = text.applyVariables(data), 54 | ssml = ssml.applyVariables(data).escapeForXml(), 55 | reprompts = answer.reprompts.map { it.key.toInt() to it.value[random.next(it.value.size)].applyVariables(data).escapeForXml() }.toMap(), 56 | suggestions = answer.suggestions.map { it.applyVariables(data) }, 57 | extras = emptyMap()) 58 | } 59 | 60 | companion object { 61 | /** The randomness implementation which can be modified for testing. */ 62 | private val random = Random() 63 | /** A regular expression to apply the actual values. */ 64 | internal val regex = "(\\$([a-zA-Z_][_a-zA-Z0-9]*)|\\$\\{([a-zA-Z_][a-zA-Z0-9._]+[a-zA-Z_])}|%(\\d+\\.?\\d*)?[bBhHsScCdoxXeEfgGaAtTn]\\$([a-zA-Z_][A-zA-z0-9._]+[a-zA-Z_]|[a-zA-Z_]))".toRegex() 65 | 66 | private fun String.escapeForXml() = this.replace("&(?!\\w+;)".toRegex(), "&").replace("'", "'") 67 | } 68 | } -------------------------------------------------------------------------------- /cli/src/test/kotlin/org/rewedigital/konversation/generator/alexa/AlexaExporterTest.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.generator.alexa 2 | 3 | import org.junit.Test 4 | import org.rewedigital.konversation.assertEqualsIgnoringLineBreaks 5 | import org.rewedigital.konversation.parser.Parser 6 | import java.io.File 7 | 8 | class AlexaExporterTest { 9 | @Test 10 | fun `Validate pretty printed kvs file result`() { 11 | val help = Parser("$pathPrefix/help.kvs").intents 12 | val sb = StringBuilder() 13 | val exporter = AlexaExporter("test", File(".").absoluteFile.parentFile, Int.MAX_VALUE) 14 | exporter.prettyPrinted({ line -> sb.append(line) }, help, null) 15 | assertEqualsIgnoringLineBreaks(expectedResult, sb.toString()) 16 | } 17 | 18 | @Test 19 | fun `Validate minified kvs file result`() { 20 | val help = Parser("$pathPrefix/help.kvs").intents 21 | val sb = StringBuilder() 22 | val exporter = AlexaExporter("test", File(".").absoluteFile.parentFile, Int.MAX_VALUE) 23 | exporter.minified({ line -> sb.append(line) }, help, null) 24 | assertEqualsIgnoringLineBreaks(expectedMinifiedResult, sb.toString()) 25 | } 26 | 27 | @Test 28 | fun `Validate pretty printed grammar file result`() { 29 | val help = Parser("$pathPrefix/help.grammar").intents 30 | val sb = StringBuilder() 31 | val exporter = AlexaExporter("test", File(".").absoluteFile.parentFile, Int.MAX_VALUE) 32 | exporter.prettyPrinted({ line -> sb.append(line) }, help, null) 33 | assertEqualsIgnoringLineBreaks(expectedResult, sb.toString()) 34 | } 35 | 36 | @Test 37 | fun `Validate minified grammar file result`() { 38 | val help = Parser("$pathPrefix/help.grammar").intents 39 | val sb = StringBuilder() 40 | val exporter = AlexaExporter("test", File(".").absoluteFile.parentFile, Int.MAX_VALUE) 41 | exporter.minified({ line -> sb.append(line) }, help, null) 42 | assertEqualsIgnoringLineBreaks(expectedMinifiedResult, sb.toString()) 43 | } 44 | 45 | @Test 46 | fun `Check that there are no duplicated utterances (case insentitive)`() { 47 | val help = Parser("$pathPrefix/dub.kvs").intents 48 | val sb = StringBuilder() 49 | val exporter = AlexaExporter("test", File(".").absoluteFile.parentFile, Int.MAX_VALUE) 50 | exporter.prettyPrinted({ line -> sb.append(line) }, help, null) 51 | assertEqualsIgnoringLineBreaks("""{ 52 | "interactionModel": { 53 | "languageModel": { 54 | "invocationName": "test", 55 | "intents": [ 56 | { 57 | "name": "Copy", 58 | "slots": [], 59 | "samples": [ 60 | "I am a copy" 61 | ] 62 | } 63 | ], 64 | "types": [] 65 | } 66 | } 67 | }""", sb.toString()) 68 | } 69 | 70 | companion object { 71 | val pathPrefix = (if (File("").absolutePath.endsWith("cli")) "" else "cli/") + "src/test/resources" 72 | val expectedResult = File("$pathPrefix/help-expected-alexa-result.json").absoluteFile.readText() 73 | val expectedMinifiedResult = File("$pathPrefix/help-expected-alexa-result-minified.json").absoluteFile.readText() 74 | } 75 | } -------------------------------------------------------------------------------- /runtime-jvm/src/test/kotlin/org/rewedigital/konversation/KonversationTest.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation 2 | 3 | import kotlin.test.Test 4 | import kotlin.test.assertEquals 5 | import kotlin.test.assertNull 6 | import kotlin.test.assertTrue 7 | 8 | class KonversationTest { 9 | @Test 10 | fun `Check display and ssml responses`() { 11 | Random.forcedValue = 0 12 | val sut = Konversation("help", environment).createOutput() 13 | assertEquals("Du kannst mit dieser App Rezepte und Angebote anhören.", sut.displayText) 14 | assertEquals("Du kannst mit dieser App Rezepte und Angebote anhören. Cool nicht wahr? Womit sollen wir weiter machen?", sut.ssml) 15 | } 16 | 17 | @Test 18 | fun `Check varity of responses`() { 19 | Random.forcedValue = null 20 | val sut = Konversation("help", environment) 21 | val displayTexts = mutableListOf() 22 | val ssml = mutableListOf() 23 | for (i in 0..50) { 24 | val output = sut.createOutput() 25 | displayTexts += output.displayText 26 | ssml += output.ssml 27 | } 28 | assertTrue(displayTexts.distinct().size > 1) 29 | assertTrue(ssml.distinct().size > 1) 30 | } 31 | 32 | @Test 33 | fun `Check suggestions`() { 34 | Random.forcedValue = 0 35 | val sut = Konversation("help", environment).createOutput() 36 | assertEquals(listOf("Angebote", "Rezept"), sut.suggestions) 37 | } 38 | 39 | @Test 40 | fun `Check reprompts`() { 41 | Random.forcedValue = 0 42 | val sut = Konversation("help", environment).createOutput() 43 | assertNull(sut.reprompts[0]) 44 | assertEquals("Kann ich dir noch helfen?", sut.reprompts[1]) 45 | assertEquals("Womit sollen wir weitermachen?", sut.reprompts[2]) 46 | assertNull(sut.reprompts[3]) 47 | } 48 | 49 | @Test 50 | fun `Check if applying variables work`() { 51 | val data = mapOf("planet" to "Welt", "user.name" to "René", "age" to 12.34) 52 | 53 | val result = Konversation("ApplyVariableTest", Environment("google", "de-DE")).createOutput(data) 54 | 55 | val expectedText = "Hallo Welt. You are René!" 56 | val expectedSsml = "Hallo Welt. You are René! And I know this age: 12,34" 57 | val expectedSuggestions = listOf("Tell me more about Welt", "Tell me more about René") 58 | assertEquals(expectedText, result.displayText) 59 | assertEquals(expectedSsml, result.ssml) 60 | assertEquals(2, result.suggestions.size, "Expect two suggestions") 61 | assertEquals(expectedSuggestions[0], result.suggestions[0]) 62 | assertEquals(expectedSuggestions[1], result.suggestions[1]) 63 | } 64 | 65 | @Test 66 | fun `Check if different locale work`() { 67 | val data = mapOf("planet" to "Welt", "user.name" to "René", "age" to 12.34) 68 | 69 | val result = Konversation("ApplyVariableTest", Environment("google", "en-US")).createOutput(data) 70 | 71 | val expectedText = "Hallo Welt. You are René!" 72 | val expectedSsml = "Hallo Welt. You are René! And I know this age: 12.34" 73 | assertEquals(expectedText, result.displayText) 74 | assertEquals(expectedSsml, result.ssml) 75 | } 76 | 77 | companion object { 78 | val environment = Environment("google", "de-DE") 79 | } 80 | } -------------------------------------------------------------------------------- /cli/src/main/kotlin/org/rewedigital/konversation/parser/Permutator.kt: -------------------------------------------------------------------------------- 1 | package org.rewedigital.konversation.parser 2 | 3 | import java.text.ParseException 4 | import java.util.* 5 | 6 | object Permutator { 7 | fun generate(line: String): MutableList { 8 | val variants = validate(line) 9 | val result = mutableListOf() 10 | insertPermutations(line, variants, 0, result) 11 | return result 12 | } 13 | 14 | private fun validate(line: String): MutableList { 15 | // Parse the line to make sure that there is no syntax error. Regex would not work for cases like {{Foo}|{Bar}} 16 | var start = 0 17 | var counter = 0 18 | val slots = mutableListOf() 19 | var lastWasMasked = false 20 | var dontProcess = false 21 | line.forEachIndexed { i, c -> 22 | when (c) { 23 | '\\' -> lastWasMasked = true 24 | '{' -> { 25 | if (!lastWasMasked) { 26 | when (counter) { 27 | 0 -> start = i + 1 28 | 1 -> { 29 | // we found a slot type, that is fine 30 | } 31 | else -> throw ParseException("This line has a syntax error: $line", i) 32 | } 33 | counter++ 34 | } 35 | lastWasMasked = false 36 | } 37 | '}' -> { 38 | if (!lastWasMasked) { 39 | when (counter) { 40 | 1 -> { 41 | // we found the end of the slot 42 | if (!dontProcess) { 43 | slots.add(line.substring(start, i)) 44 | } 45 | } 46 | //2 -> { 47 | // // we found the end of a slot type, that is fine 48 | //} 49 | else -> throw ParseException("This line has a syntax error: $line", i) 50 | } 51 | counter-- 52 | } 53 | lastWasMasked = false 54 | dontProcess = false 55 | } 56 | '$' -> dontProcess = true 57 | //'%'-> { 58 | 59 | //} 60 | else -> lastWasMasked = false 61 | } 62 | } 63 | if (counter != 0) throw ParseException("This line has a syntax error: $line", line.length) 64 | 65 | return slots 66 | } 67 | 68 | private fun insertPermutations(line: String, slots: MutableList, offset: Int, storage: MutableList) { 69 | if (slots.size == offset) { 70 | //val count = Utterance.counter.incrementAndGet() 71 | //if ((count % 100000) == 0) println(count) 72 | 73 | storage.add(line.trim().replace(" +".toRegex(), " ")) 74 | return 75 | } 76 | val placeholder = UUID.randomUUID().toString() // could be replaced by something faster 77 | val replacement = line.replaceFirst(slots[offset], placeholder) 78 | slots[offset].split("|").map { 79 | insertPermutations(replacement.replace("{$placeholder}", it), slots, offset + 1, storage) 80 | } 81 | } 82 | } 83 | --------------------------------------------------------------------------------