DEV Community 👩‍💻👨‍💻

Andrii Maliuta
Andrii Maliuta

Posted on

WebEx bot with webex-java-sdk and Spring. Part 1

To use the Webex chat you need to register for a Webex Account at

Create WebEx app that will server as your bot

Go to and create the app that will be acting as your bot:

Image description

Create Spring Java App

It is not mandatory to use Spring - any way of creating Web App with Java framework can do. Also, a serverless apps or lambdas can be used to host the code.

We will use Spring Boot app:

  1. Groovy
  2. Gradle
  3. Spring Web
  4. Gson (parse JSON)
  5. Jsoup (parse HTML messages)

Gradle dependencies code:

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'  
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'javax.json:javax.json-api:1.1.4'
    implementation 'org.glassfish:javax.json:1.1'
    implementation ''
    implementation 'org.codehaus.groovy:groovy'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
Enter fullscreen mode Exit fullscreen mode

Install Spark SDK

Not to create models and services to interact with Webex and use HTTP calls, we can use the WebEx Java SDK ( (Spark Java SDK)).
It can be installed via Gradle - use gradle install to locate the code locally in maven repos.

App code

We will create RoomService that will interact with WebEx Room that exist in WebEx of our account.


import com.anma.wbb.webexbotbsg.Room

interface RoomService {

    List<Room> getRooms(teamId, type, sortBy, max);
    public Room getRoom(String id);

Enter fullscreen mode Exit fullscreen mode

RoomServiceImpl class that implements RoomService interface

import com.anma.wbb.webexbotbsg.Room
import com.anma.wbb.webexbotbsg.Spark
import org.springframework.stereotype.Service

class RoomServiceImpl implements RoomService {

    String testBot = System.getenv("WEBEX_TEST_BOT");
    String myToken = System.getenv("WEBEX_MY_TOKEN");

    Spark spark = Spark.builder()

    public Room getRoom(String id) {
        Room room = spark.rooms().path("/${id}").get()
        return room

    List<Room> getRooms(teamId, type, sortBy, max) {

        List<Room> rooms = new ArrayList<>()
                .forEachRemaining(room -> {
//                    System.out.println(room.getTitle() + ", created " + room.getCreated() + ": " + room.getId());

        return rooms
Enter fullscreen mode Exit fullscreen mode

So, now we have the service that gets rooms and its implementation. We can also add the services that will interact with messages that are present in rooms.

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.