View on GitHub

rasa-java-client-library

A Java SDK for Rasa Conversational AI

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.

Version

current version: 0.2.0 (unstable)

Requirements

Installation

Attention!

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:

Rasa assistant application architecture

The picture shows in which components the rasa-java-client-library can be used.

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);