1

This project is for:

  • building chat-bots in Java/Kotlin using Spring / Spring Boot
  • using a familiar, Spring-annotation-driven way to configure bots.
  • having access to the Java & Spring ecosystems for complex bot use-cases

Although there are many low-code and no-code ways to put a chat-bot together now, for advanced use-cases and situations where you want to integrate with existing systems, Java will be the way to go.

Platform Bindings

Spring Bot is designed to be an abstraction layer on top of other Java bot libraries. i.e it handles the concerns above, and leaves the connectivity and API logic to lower-level libraries.

This means that you can build bots in Spring Bot that will work concurrently on different chat-platforms.

Currently we have just have bindings for Symphony and Microsoft Teams.

One Quick Example

Here is an excerpt from the To-Do Tutorial, with screenshots from Symphony and Microsoft Teams.

Let’s say I have a simple POJO called ToDoItem (containing fields like Description, Creator etc.) and a further POJO called ToDoList which looks like this.

@Work
public class ToDoList {

  private List<ToDoItem> items = 
       new ArrayList<ToDoItem>();

  // setters/getters omitted for brevity
  
}

We can create a Spring Controller like so:

@Controller
public class ToDoController {

  @ChatRequest(value="new", 
     description = "Create new item list")
  public ToDoList init() {
    return new ToDoList();
  }

This creates a new command for the bot. When I type /help, the bot responds with…

Help Page on Symphony

Help Page on Teams

When I type /new the bot responds with an empty To-Do list like so.

Empty To-Do list

This is the same code running on Microsoft Teams mobile.

Empty To-Do list Teams

I can put an add button on the To-Do list like this:

@Controller
public class ToDoController {
  
 // Other methods
  
 @ChatButton(value = ToDoList.class, 
   buttonText = "Add")
 @ChatResponseBody(
   workMode = WorkMode.EDIT)
 public NewItemDetails add(User author) {
  NewItemDetails out = 
    new NewItemDetails();
  out.assignTo = author;     
  return out;
 }
}

This button will then appear on my To-Do List.

Add Button

Pressing that button gives me a form to fill in, containing the NewItemDetails fields.

This is Microsoft Teams Mobile again.

Add Button

… and so on. Tutorial continues here.

Model

  • Build stateless bots: store all working state as data within the chat platform.
  • Create POJOs for your data model, persisting data into chat rooms and retrieving it using the History API.
  • Spring Bot will handles serialization / deserialization via Jackson.

View

  • Spring Bot can auto-generate default views of your models.
  • It provides functionality for using alternate views, and customizing views for each platform.

Controller

  • Mapping of methods() on your @Controllers to messages sent to the bot.
  • Resolving method parameters like User, Word, HashTag

Source

See Github

Tools

To see how this toolkit works in action, check out some source code here:

Reminder Bot

Creates reminders in chat rooms when you start talking about time. Uses Stanford NLP Time package.

RSS (News) Bot

Allows you to configure news feeds into chat rooms.

Poll Bot

Allows you to poll the members of a room, providing a question and a list of answers to vote on.