GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - BotMill/viber-bot-java: The Viber bot Java library provides just what you need to develop intelligent bots that interact naturally with your Viber users.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

40 Commits
40 Commits

Folders and files

NameName
Last commit message
Last commit date
docs
docs
 
 
gradle/wrapper
gradle/wrapper
 
 
nano-httpd-sample
nano-httpd-sample
 
 
spring-boot-sample
spring-boot-sample
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Viber Java Bot API

Use this library to develop a bot for Viber platform. The library is available on GitHub as well as maven central.

License

This library is released under the terms of the Apache 2.0 license. See License for more information.

Library Prerequisites

  • Java >= 8
  • Get your Viber Public Account authentication token. Your token is generated and provided to you during the Public Account creation process. As a Public Account admin, you can always find the account token in the "edit info" page.
  • SSL Certification - You'll need a trusted (ca.pem) certificate, not self-signed. You can find one at Let's Encrypt or buy one.

Installation

This library is released on maven central.

Gradle

compile group: 'com.viber', name: 'viber-bot', version: '1.0.11'

Maven

<dependency>
    <groupId>com.viber</groupId>
    <artifactId>viber-bot</artifactId>
    <version>1.0.11</version>
</dependency>

Documentation

JavaDocs

All public APIs are documented with JavaDocs which can be found in the GitHub repository.

Sample projects

We've created two sample projects to help you get started:

  • Spring-Boot Sample using spring-boot-starter-web package.
  • NanoHTTPd Sample with a tiny embedded HTTP server, called NanoHTTPd.

A simple overview

public void botExample() {
    ViberBot bot = new ViberBot(new BotProfile("SampleBot", "http://viber.com/avatar.jpg"), "YOUR_AUTH_TOKEN_HERE");
    bot.onMessageReceived((event, message, response) -> response.send(message));

    // somewhere else in your web server of choice:
    bot.incoming(Request.fromJsonString("..."));
}

You can chose to use any web server or framework you like. All you need to do is call the API with -

bot.incoming(Request.fromJsonString("...")); // or
bot.incoming(Request.fromInputStream(inputStream));

Should I be concerned with synchronizing my web server threads? Is this library thread-safe?

The Viber bot library is thread-safe and highly concurrent. You do not have to worry about synchronizing anything.

All calls to ViberBot#incoming() go through a BlockingQueue, and ordering is retained. All I/O calls are directly executed on the same thread they were initially called on.

Can I make I/O calls asynchronous and still retain thread-safety for my bot?

Yes. You can pass a system property to control the I/O thread pool:

com.viber.bot.executor.strategy=[DIRECT|THREAD] (default is DIRECT)

com.viber.bot.executor.threads=N (default is getRuntime().availableProcessors())

  • Note: This will not change the way you use the library. You still don't have to synchronize anything.

Do you supply a basic router for text messages?

Well funny you ask. Yes we do. But a word of warning - messages sent to your router callback will also be emitted to the ViberBot#onMessageReceived event.

public void botTextRouterExample() {
    bot.onTextMessage("(hi|hello)", (event, message, response) -> response.send("Hi " + event.getSender().getName()));
}

Community

Join the conversation on Gitter.

About

The Viber bot Java library provides just what you need to develop intelligent bots that interact naturally with your Viber users.

developers.viber.com/

Resources

Readme
License
Activity
Custom properties

Stars

0 stars

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.