Skip to content
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci chore(ci): added circle ci config May 22, 2019
examples added reply api Jul 3, 2019
gradle/wrapper added reply api Jul 3, 2019
src/main added reply api Jul 3, 2019
.gitignore feat(bots): media/document sent Sep 20, 2018
.whitesource Initial WhiteSource configuration file Mar 4, 2019
LICENSE docs: add LICENSE Sep 11, 2018
README.md Update README.md Apr 12, 2019
build.gradle chore(ci): fixed gradle build May 22, 2019
gradle.properties
gradlew feat(bots): initial functionality Jul 23, 2018
gradlew.bat implementing light bot api Jul 31, 2018
settings.gradle share bot to includes Nov 15, 2018

README.md

Java Bot SDK

Dialog Java Bot SDK.

Documentation

API Reference

Example

Community chat

How to use the SDK with maven/gradle?

  1. Add repository

Gradle:

repositories {
    maven { url "http://dialog.bintray.com/maven" }
}
  1. Add BOT dependency
dependencies {
    compile 'im.dlg:bot-sdk:1.3'
}
  1. Create bot and subscribe on updates
public class Main {
    public static void main(String[] args) throws InterruptedException, ExecutionException {

        BotConfig botConfig = BotConfig.Builder.aBotConfig()
                .withHost("your-server-host")
                .withPort(443)
                .withToken("your-bot-token")
                .build();

        Bot bot = Bot.start(botConfig).get();

        bot.messaging().onMessage(message ->
                bot.users().get(message.getSender()).thenAccept(userOpt -> userOpt.ifPresent(user -> {
                            System.out.println("Got a message: " + message.getText() + " from user: " + user.getName());
                        })
                ).thenCompose(aVoid -> {
                            return bot.messaging().sendText(message.getPeer(), "pong");
                        }
                ).exceptionally(ex -> {
                    ex.printStackTrace();
                    return null;
                }).thenAccept(uuid ->
                        System.out.println("Sent a message with UUID: " + uuid)));

        bot.await();
    }
}
You can’t perform that action at this time.