rasa-java-client-library
A Java SDK for Rasa Open Source
The rasa-java-client-library wraps the Rasa OpenSource HTTP API and enables you to build your Rasa assistant application with Java.
- Use the comfortable RasaClientto connect to the Rasa Server and talk to or train your Rasa assistant
- Use the flexible ModelApi,DomainApiandTrackerApito implement additional advanced features, e.g. interactive learning
Version
current version: 0.2.0 (unstable)
Requirements
- java 11 and higher
Installation
Attention!
- This is a GitHub package. You need to authenticate to GitHub Packages first.
- Currently available version 0.2.0is unstable!
Maven
<dependency>
  <groupId>io.github.arturkorb</groupId>
  <artifactId>rasa-java-client-library</artifactId>
  <version>0.2.0</version>
</dependency>
Gradle
dependencies {
  implementation 'io.github.arturkorb:rasa-java-client-library:0.2.0'
}
Compatibility with Rasa
| rasa-java-client-library version | compatible Rasa version | 
|---|---|
| 0.2.0 | >=2.2.0 | 
Use Case
Use the rasa-java-client-library if you consider building your Rasa assistant application with Java. A typical architecture of such a Rasa assistant application could look like this:

The picture shows in which components the rasa-java-client-library can be used.
- Used in the communication component for talking with the bot and retrieving context (NLU parse results, etc.)
- Used in the maintenance/development component for training and configuration
- Used in Action Service for building response and event objects when executing action
Usage
Examples:
        /*RasaClient usage example*/
        RasaClient rasaClient = new RasaClient().withBasePath("http://<rasa server url>:5005");
        
        //build your request from your training data
        YAMLTrainingRequest yamlTrainingRequest = new YAMLTrainingRequest();
        yamlTrainingRequest
                .config("<content of 'config.yml' as String>")
                .domain("<content of 'domain.yml' as String>")
                .nlu("<content of 'nlu.yml' as String>")
                .stories("<content of 'stories.yml' as String>")
                .rules("<content of 'rules.yml' as String>");
        
        //training
        rasaClient.trainModel(yamlTrainingRequest);
                
        //talking
        BotAnswer botAnswer = rasaClient.sendMessage("hi", "<user id>");
                
        //context
        Context context = rasaClient.sendMessageWithContextRetrieval("hi", "<user id");
        ParseResult result = context.getParseResult();
        Intent intent = result.getIntent();        
        /*ServerInformationApi usage example*/
        ServerInformationApi serverInformationApi = new ServerInformationApi();
        InlineResponse200 version = serverInformationApi.getVersion();
        /*DomainApi usage example*/
        DomainApi domainApi = new DomainApi();
        Domain domain = domainApi.getDomain();
        DomainConfig config = domain.getConfig();
        /*TrackerApi usage example*/
        TrackerApi trackerApi = new TrackerApi();
        Tracker conversationTracker = trackerApi.getConversationTracker("<conversation_ID>", "ALL", null);
        /*ModelApi usage example*/
        ModelApi modelApi = new ModelApi();
        ModelRequest modelRequest = new ModelRequest();
        modelRequest = modelRequest.modelFile("/app/models/" + "<your model file name>");
        modelApi.replaceModel(modelRequest);