Awesome Open Source
Awesome Open Source

WatBot - An Android ChatBot powered by IBM Watson

Build Status

WatBot is an IBM Watson powered ChatBot running on Android and using Watson Assistant service on IBM Cloud (an open standards, cloud platform for building, running, and managing apps and services).

Note: This app uses Watson Assistant V1 API

Coding the app on Android Studio

Android Studio is the Official IDE for Android. Android Studio provides the fastest tools for building apps on every type of Android device.

Clone the repo and import the code in Android Studio,

git clone

Creation of Watson Assistant service; Adding intents & entities ; Building your dialog

Check this blog post for step-by-step and up-to-date instructions.

Configure the App

To configure the App you need to get the Watson Assistant service's Password, URL and Workspace ID

  • In the MainActivity class locate the method named sendMessage(). On the Manage tab of the Assistant service you created, click Launch tool > Skills > Click the three vertical dots next to the Skill > View API Details > You can find the Workspace ID, Username and password. If you wish to use API Key directly read the TODO, uncomment the code and replace the Placeholder with the API Key value.

    You can find the API Key and URL on the Manage tab or under service credentials.

        Assistant assistantservice = new Assistant("2018-02-16");
         //If you like to use USERNAME AND PASSWORD
         //Your Username: "apikey", password: "<APIKEY_VALUE>"
         assistantservice.setUsernameAndPassword("apikey", "<API_KEY_VALUE>");
         //TODO: Uncomment this line if you want to use API KEY
         //Set endpoint which is the URL. Default value:
         InputData input = new InputData.Builder(inputmessage).build();
         //WORKSPACES are now SKILLS
         MessageOptions options = new MessageOptions.Builder().workspaceId("<WORKSPACE_ID>").input(input).context(context).build();
         MessageResponse response = assistantservice.message(options).execute();
Add the `password` in the following code,
    assistantservice.setUsernameAndPassword("apikey", "<ASSISTANT_PASSWORD>");
  • Next is to get the Workspace ID.

Get the Workspace ID: and add it in the below code,

   MessageOptions options = new MessageOptions.Builder("<Workspace_ID>").input(input).context(context).build();

Gradle Entry

compile ''
  • Build and Run your app.

Enable Text to Speech

  • Create a Watson Text to Speech(TTS) service on IBM Cloud
  • Navigate to Service Credentials tab and click on "View Credentials".

On Line 95 of, replace the password and URL placeholders with the TTS service credentials

    textService.setUsernameAndPassword("apikey", "<TEXT_TO_SPEECH_APIKEY>");
  • Build and Run your app.

Now when you TAP on any message, the text will be heard via a Voice (Voice.EN_US_LISAVOICE). You can change the voice formats in the code (Line 120 0f

Note: The required gradle entries for TTS is already included in the build.gradle file

  compile ''
  compile ''

Enable Speech to Text

  • Create a Watson Speech-To-Text (STT) service on IBM Cloud
  • Navigate to Service Credentials tab and click on "View Credentials".
  • Update lines 274-276 with the credentials.
  • Build and Run your app.

Note: The required gradle entries for STT is already included in the build.gradle file

     compile ''
     compile ''

Chat with your own WatBot

If you have followed all the above instructions, you should be happily chatting with your Wat(son)Bot.

** Remember your bot will be talking to your Watson Assistant service (Intents, Entities and Dialog).**


Speaker labels

Note: The speaker labels feature is beta functionality that is available for US English, Japanese, and Spanish.

Speaker labels identify which individuals spoke which words in a multi-participant exchange. (Labeling who spoke and when is sometimes referred to as speaker diarization.) You can use the information to develop a person-by-person transcript of an audio stream, such as contact to a call center. Or you can use it to animate an exchange with a conversational robot or avatar. For best performance, use audio that is at least a minute long.

To enable, Click TODO on the bottom tab of Android Studio or search for TODO in file and uncomment the lines. You should see the output in the logcat as shown below

      "confidence": 0.5,
      "final": false,
      "from": 1.59,
      "speaker": 0,
      "to": 1.82

Don't stop here!!! Keep coding and using IBM Cloud

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
java (31,347
android (6,290
chatbot (297
dialog (198
android-studio (139
speech (104
text-to-speech (97
speech-to-text (93
assistant (55
entity (50
conversation (35
workspace (26
intent (26
speaker-recognition (25
ibm-cloud (21
cognitive-services (19
watson (17
speaker-diarization (15