Applications
Note: Furhat applications were previously referred to as Skills
Kotlin language
Applications on the Furhat platform are built in our domain-specific-language (DSL) in the Kotlin programming language. To learn the fundamentals of Kotlin, we recommend the excellent documentation on kotlinlang.org. You don't need to be a Kotlin expert, or even an experienced developer, to build Furhat applications and will be able to pick up much along the way. General software engineering experience, both object-oriented and functional, is recommended for more advanced use-cases. For more information, see recommended competences
One of the great things about Kotlin is that you can use it interchangeably with Java, allowing you to import Java libraries and use preexisting Java code as you see fit.
Setting up IntelliJ IDEA
- Make sure you have JDK 1.8.x installed
- Make sure the Kotlin JVM version is used (File > Settings > Build, Execution, Deployment > Compiler > Kotlin Compiler and set to
1.8
) - Set the default Working directory for Kotlin run configurations (Run -> Edit configurations -> Defaults -> Kotlin and set to
$MODULE_DIR$
)
Building blocks
A Furhat application consists of the following building blocks:
- Flow or Dialog flow (See Flow) consisting of states with event handlers
- Intents and Entities (See Natural language understanding)
Creating an application
Follow the below steps to create your application.
Go to your SDK directory and run gradlew run
to start the server.
Access the web interface on localhost:8080
.
Go to the applications list in the web interface
Create an application and give it a name (for example FruitSeller).
Note: The application will by default be created in the skills directory of your SDK directory
- Import the application into IntelliJ as a Kotlin project and wait for it to build.
- The application boilerplate contains the following files:
- main.kt is the starting point for your app. In this example, it only needs to initiate the flow.
- flow.kt is the dialog flow) file.
- nlu.kt is where you define your intents (and supporting entities) used in the parsing of speech NLU
- assets is a folder where you for example can put a graphical interface
Running an application locally
You can run an application locally in two ways, from your IDE - IntelliJ IDEA or from the web interface. The benefit of running it from IntelliJ is that you can set breakpoints and use your console for debugging efficiently.
Running the application locally from IntelliJ IDEA
- Run the application by going into the main.kt file and pressing the gradle icon to the left of the
fun main() {
- Go to the web interface's dashboard page and notice that the skill is running
- For consecutive runs you can just press the play button in IntelliJ or create your own run-configuration
Note: If your skill crashes due to "not able to read skill.properties" then ensure that the working directory of your skill is set to the root folder of the skill. E.g
C:/<PATH-TO-SDK>/skill/HelloWorld
. To fix this for all future skills, go to Edit configurations -> Defaults -> Kotlin and change Working Directory to$MODULE_DIR$
Running an application from web interface
You can also run applications from the web interface. Note, the compilation will be done separately (i.e not through IntelliJ IDEA) so you will have to compile it for every change made.
Running an application remotely on a robot
You can run an application remotely on a robot in two ways, through IntelliJ IDEA or from the robot's hosted web interface (the application is then deployed to the robot).
Running an application on a robot from IntelliJ IDEA
- Create a run-configuration for your application (similar to "Running the application locally from IntelliJ IDEAR)
- Add the JVM argument
-Dfurhatos.skills.brokeraddress=<YOUR-IP-ADDRESS>
with the IP of your robot. The port does not need to be specified.
Deploying an application to a robot
- To upload a skill to a furhat, zip the contents of the root folder of the skill. NOTE: Often if you zip the root folder itself you will get an incorrect.
- Import the zipped file. Your skill will now appear on the page.