Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Build a Watson-Powered Mobile Chatbot

DZone's Guide to

Build a Watson-Powered Mobile Chatbot

Learn to build a Watson-powered speech synthesizer mobile chatbot using Mobile Services, Watson Conversation, and Text to Speech in IBM Bluemix.

· Mobile Zone
Free Resource

Launching an app doesn’t need to be daunting. Whether you’re just getting started or need a refresher on mobile app testing best practices, this guide is your resource! Brought to you in partnership with Perfecto

Before building the chatbot, let us first understand the technology that is powering this chatbot.

IBM Bluemix is a Platform As A Service cloud offering from IBM. It enables developers to quickly create, deploy, and manage applications on the cloud by abstracting other layers.

Watson is a cognitive system that can understand all forms of data, interact naturally with people, and learn and derive insights out of it, at scale. Watson is available as a set of open APIs and SaaS products.

Watson Conversation can help you create an application that can understand the intent behind natural language input and simulate a conversation between humans.

Text to Speech converts written text into natural sounding audio in a variety of languages and voices, which also has an expressive element that lets you indicate a speaking style of good news, apology, or bad news.  

To build this chat bot, you will have to configure Watson Conversation Service and Text to Speech in IBM Bluemix and export starter code from IBM Bluemix to Android Studio.

Configure Watson Conversation Service

Log in to www.bluemix.net and click on "catalog" to create and configure Watson Conversation Service:

Image title

Enter a service name (or leave it as the default) and then click on "create." Please note that I have left it as "unbound." You can either leave it as "unbound" or bind it to an app that you have created on Bluemix.

Image title

Click on "Launch tool" to open the Watson Conversation Service Tool:

Image title

In Workspaces, click on "create" to create a new workspace:

Image title

Enter a name and click on "create."

Image title

Check the video below to create workspace, intents, entities, and dialogues:


Configure Text-to-Speech Service

Click on "catalog" to create and configure Text to Speech service:

Image title

Enter a service name (or leave it as default) and then click on "create."

Image title

Configure Mobile Services

Step 1: Go to this URL: https://console.ng.bluemix.net/developer/getting-started/  and click on "create project" to get starter code.

Step 2: Click on "mobile app" and click on "next."

Step 3: Filter by Android and then click on Watson Conversation and click on "next."

Step 4: Enter a Project Name and select platform as Android and click on "create."

Step 5: Click on "Get the Code."

Step 6: Click on "Generate Code."

Step 7: Download the generated code.

Step 8: Unzip the generated code and then Import it into Android Studio (any latest version of Android Studio).

Step 9: In the build.gradle(app), insert dependency:

compile 'com.ibm.watson.developer_cloud:android-sdk:0.2.3'

Step 10: In res>values>watson_credentials.xml, enter the Watson Conversation password, Username, Workspace ID, and insert last the two lines with Text to Speech Username & Password. Go to Bluemix Dashboard and open Watson Conversation Service & Text to Speech Service to get the username and password! (as shown below)

Image title

Image title

Image title

Image title

<resources> 
  <string name="watson_conversation_password">XXXXXXXXX</string> 
  <string name="watson_conversation_username">XXXXXXXXXXXXXxxxxxxxxxxxxxxxx</string> 
  <string name="watson_conversation_workspace_id">XXXXXXXXXXXXXXXXXXXXXXXXXXX</string> 
  <string name="watson_tts_username"xxxxxxXXXXXXXXxxxXXXXXXXXXXXX</string> 
  <string name="watson_tts_password">xxxxXXXXXXXXxxxxxxx</string> 
  </resources>

Step 11: Copy and paste the entire code in MainActivity.java (Android Studio) from here (with Text to Speech Integration). 

This is the code that will invoke Text to Speech API:

TextToSpeech tts = initTextToSpeechService();
StreamPlayer sp = new StreamPlayer();
sp.playStream(tts.synthesize(texttoSpeech[0], Voice.EN_MICHAEL).execute());

After completing all the steps, run the app in Android Studio to hear Watson speaking!

Keep up with the latest DevTest Jargon with the latest Mobile DevTest Dictionary. Brought to you in partnership with Perfecto.

Topics:
chatbots ,chatbot development ,mobile app ,mobile ,app development ,watson

Published at DZone with permission of Riya Roy. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}