com.botscrew:bot-framework-nlp-spring-boot-starter

Module for work with nlp providers

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

com.botscrew
ArtifactId

ArtifactId

bot-framework-nlp-spring-boot-starter
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

com.botscrew:bot-framework-nlp-spring-boot-starter
Module for work with nlp providers
Project URL

Project URL

https://github.com/botscrew/bot-framework-nlp
Source Code Management

Source Code Management

https://github.com/botscrew/bot-framework-nlp

Download bot-framework-nlp-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/com.botscrew/bot-framework-nlp-spring-boot-starter/ -->
<dependency>
    <groupId>com.botscrew</groupId>
    <artifactId>bot-framework-nlp-spring-boot-starter</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.botscrew/bot-framework-nlp-spring-boot-starter/
implementation 'com.botscrew:bot-framework-nlp-spring-boot-starter:1.2.0'
// https://jarcasting.com/artifacts/com.botscrew/bot-framework-nlp-spring-boot-starter/
implementation ("com.botscrew:bot-framework-nlp-spring-boot-starter:1.2.0")
'com.botscrew:bot-framework-nlp-spring-boot-starter:jar:1.2.0'
<dependency org="com.botscrew" name="bot-framework-nlp-spring-boot-starter" rev="1.2.0">
  <artifact name="bot-framework-nlp-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.botscrew', module='bot-framework-nlp-spring-boot-starter', version='1.2.0')
)
libraryDependencies += "com.botscrew" % "bot-framework-nlp-spring-boot-starter" % "1.2.0"
[com.botscrew/bot-framework-nlp-spring-boot-starter "1.2.0"]

Dependencies

compile (2)

Group / Artifact Type Version
ai.api : libai jar 1.6.12
com.botscrew : bot-framework-core-spring-boot-starter jar 1.0.3

provided (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-web jar
org.springframework.boot : spring-boot-configuration-processor Optional jar
org.projectlombok : lombok jar

test (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar

Project Modules

There are no modules declared in this project.

NLP Client Spring Boot Starter

NLP Client project provides integration with various nlp clients (only dialog-flow for now). It is based on Bot Framework. It uses IntentContainer from Bot Framework. To read more about it, check the link below:

https://github.com/botscrew-projects/bot-framework-core

Getting Started

  • Add NLP Client dependency
<dependency>
    <groupId>com.botscrew</groupId>
    <artifactId>bot-framework-nlp-spring-boot-starter</artifactId>
    <version>1.1.2</version>
</dependency>

NLP Client already depends on the Bot Framework so you don't need to add it to project by yourself.

Usage

To send query to the nlp provider you need to autowire NlpClient and call NlpClient#query() method

public class TextHandler {
    @Autowired
    private NlpClient nlpClient;
    
    @Text
    public void handleText(User user, @Text String text) {
        nlpClient.query(user, text);
    }
}

You will be able to get an answer in your Intent handling method:

@Intent
public void handleIntent(User user, @Text String originalQuery) {
    // ...
}

You can get entities from the nlp provider as parameters in your handling method:

@Intent("name")
public void handleNameIntent(User user, @Param("name") String name) {
    // ...
}

If you need to get any complex objects you can define your own model and get them as parameters:

public class Age {
    private String unit;
    private Integer amount;
}

// ...

@Intent("age")
public void handleAgeIntent(@Param("age") Age age) {}

IntentContainer supports user states so, you will be able to define different intent handlers for different user states:

@Intent(value = "PHONE_NUMBER", states = {"DEFAULT"})
public void handlePhoneNumberIntent(User user, @Param("number") String number) {
    // ...
}

@Intent(value = "PHONE_NUMBER", states = {"ONBOARDING"})
public void handlePhoneNumberInOnboarding(User user, @Param("number") String number) {
    // ...
}

Providers

  • DialogFlow APIv1

To work with DialogFlow API you need define the following properties: nlp.provider.dialog-flow.v1.client-token

If you need get some specific data from the original DialogFlow response, you can get it by using the @NlpResponse annotation:

@Intent
public void intent(@NlpResponse AiResponse aiResponse) {
    // ...
}

Versions

Version
1.2.0
1.1.2
1.1.1
1.1.0