Skip to content

botscrew-projects/bot-framework-nlp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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) {
    // ...
}

About

Module for connecting with nlp providers

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages