Skip to content

A template repository to quickly get started with your bot

Notifications You must be signed in to change notification settings

xatkit-bot-platform/xatkit-bot-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xatkit Bot Template

This repository contains a template project pre-configured with the required dependencies to help you get started with your new bot.

What's included in this template?

The maven project in this template embeds the following dependencies:

  • Xatkit Core (com.xatkit.core): the Xatkit SDK, this dependency contains the DSL to create Xatkit bots, as well as the runtime engine to execute them.
  • Xatkit Chat Platform (com.xatkit.chat-platform-runtime): a generic platform representing a chat
  • Xatkit React Platform (com.xatkit.react-platform-runtime): a platform able to connect with the Xatkit chat widget
  • Lombok (org.projectlombok.lombok): a library to ease the development of Java applications (more information here) We also configured a few testing dependencies we regularly use in our bots:
  • JUnit 4.12
  • AssertJ 3.14
  • Mockito 3.3.3

Finally, we put an example GreetingsBot in this template to help you find the API method you need to create, configure, and run your bot. You can find more information on the API in our wiki.

Note: you can remove the Xatkit Chat Platform and Xatkit React Platform dependencies if you don't need them, but they are required to run the GreetingsBot example.

In addition, this template also includes a Dockerfile you can customize to deploy your bot as a Docker container.

How to use the template?

Click on the button below to create a new repository from this template and follow the instructions. Use this template

Packaging

Run the following command to package your bot

mvn package

This creates a self-contained jar greetings-bot-jar-with-dependencies.jar in the target directory. You can run you bot with the following command

java -jar greetings-bot-jar-with-dependencies.jar

You can now navigate to http://localhost:5000 and start chatting with your bot!

📚 You need to edit the bot's pom.xml file to change the name of the produced jar or the main class used to start the bot, see the example below

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>${maven-assembly-plugin.version}</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <archive>
            <manifest>
                <!-- 💡 Change here the main class used to start the bot !-->
                <mainClass>com.xatkit.example.GreetingsBot</mainClass>
            </manifest>
        </archive>
            <!-- 💡 Change here the name of your bot -->
            <!-- The resulting jar will be named <your bot name>-jar-with-dependency.jar -->
            <finalName>greetings-bot</finalName>
        </configuration>
</plugin>

Docker

This template provides a Dockerfile to build a Docker image from your packaged bot. Run the following commands to build the image and start your bot as a container

docker build --tag myorg/greetingsbot:1.0 .
docker run -p5000:5000 -p5001:5001 -d --name greetingsBot myorg/greetingsbot:1.0

You can now navigate to http://localhost:5000 and start chatting with your bot!

📚 You need to edit the bot's Dockerfile to change the name of the copied bot jar based on your pom.xml configuration, see the example below

FROM openjdk:8
# Update this line with the name of jar created with mvn package
COPY target/greetings-bot-jar-with-dependencies.jar /bot.jar
WORKDIR /
# You can configure Xatkit properties from the command line, e.g.
# -Dxatkit.server.port=5010 will set Xatkit's server port to 5010
CMD java -jar bot.jar

Troubleshooting

  • IntelliJ error: java: incompatible types: com.xatkit.dsl.intent.IntentOptionalTrainingSentenceStep cannot be converted to lombok.val ➡ You need to enable annotation processing in your project (see image below). Enable annotation processing in IntelliJ And if you still get issues, you can also try to indicate LATEST as the lombok version to import in the pom file.

About

A template repository to quickly get started with your bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages