{"id":18487631,"url":"https://github.com/VidyasagarMSC/WatBot-Kotlin","last_synced_at":"2025-04-08T20:31:39.946Z","repository":{"id":90487308,"uuid":"92799920","full_name":"VidyasagarMSC/WatBot-Kotlin","owner":"VidyasagarMSC","description":" An Android ChatBot written in Kotlin and powered by IBM Watson","archived":false,"fork":false,"pushed_at":"2017-08-21T10:45:20.000Z","size":1128,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T19:34:32.378Z","etag":null,"topics":["android","android-studio","bluemix","cognitive","cognitive-services","conversation","conversation-service","dialog","entity","intent","kotlin","kotlin-android","watson-conversation","watson-speech-sdk"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VidyasagarMSC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-30T05:05:37.000Z","updated_at":"2025-02-03T06:53:58.000Z","dependencies_parsed_at":"2024-01-09T23:45:11.372Z","dependency_job_id":null,"html_url":"https://github.com/VidyasagarMSC/WatBot-Kotlin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VidyasagarMSC%2FWatBot-Kotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VidyasagarMSC%2FWatBot-Kotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VidyasagarMSC%2FWatBot-Kotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VidyasagarMSC%2FWatBot-Kotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VidyasagarMSC","download_url":"https://codeload.github.com/VidyasagarMSC/WatBot-Kotlin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247923044,"owners_count":21018917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-studio","bluemix","cognitive","cognitive-services","conversation","conversation-service","dialog","entity","intent","kotlin","kotlin-android","watson-conversation","watson-speech-sdk"],"created_at":"2024-11-06T12:50:35.576Z","updated_at":"2025-04-08T20:31:39.933Z","avatar_url":"https://github.com/VidyasagarMSC.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# WatBot-Kotlin is an Android ChatBot written in Kotlin and powered by IBM Watson\n\n[![Build Status](https://travis-ci.org/VidyasagarMSC/WatBot-Kotlin.svg?branch=master)](https://travis-ci.org/VidyasagarMSC/WatBot-Kotlin)\n\nConverted to Kotlin from the Java version of the [WatBot](https://github.com/VidyasagarMSC/WatBot)\n\n*BUILT USING Android Studio 3.0 Canary 3*\n\nWatBot is an IBM Watson powered ChatBot running on \u003ca href=\"http://vidyasagarmsc.com/tag/android/\" target=\"_blank\"\u003eAndroid\u003c/a\u003e and using Conversation Service on IBM \u003ca href=\"http://vidyasagarmsc.com/category/cloud/\" target=\"_blank\"\u003eBluemix\u003c/a\u003e (an open standards, cloud platform for building, running, and managing apps and services).\n\u003cp align=\"center\"\u003e\u003cimg src=\"images/WatBot_5X.png\" width=\"350\" /\u003e\u003c/p\u003e\n\nCheck this [blog post](http://vidyasagarmsc.com/an-android-chatbot-powered-by-ibm-watson/) for step-by-step instructions and also to see it in action.\n\n\u003ch2\u003eCoding the app on Android Studio\u003c/h2\u003e\nAndroid Studio is the Official IDE for Android. Android Studio provides the fastest tools for building apps on every type of Android device.\n\nClone the repo and import the code in Android Studio,\n\n```\ngit clone https://github.com/VidyasagarMSC/WatBot-Kotlin.git\n```\n\n## Creation of Conversation Service\n\nWatson Conversation combines a number of cognitive techniques to help you build and train a bot - defining intents and entities and crafting dialog to simulate conversation.\n\n![Watson Conversation Service Overview](https://github.com/VidyasagarMSC/WatBot/blob/initial/Images/Watson_Conversation_Service.png)\n\n\u003ch3\u003eGetting started\u003c/h3\u003e\nBefore you can start using the Conversation service, log in to IBM® Bluemix® and create a service instance.\n\u003col\u003e\n \t\u003cli\u003eLog in to Bluemix and navigate to the Conversation service:\n\u003cul\u003e\n \t\u003cli\u003eDon’t have Bluemix account? \u003ca title=\"(Opens in a new tab or window)\" href=\"https://console.ng.bluemix.net/registration/?target=/catalog/services/conversation/\" target=\"_blank\"\u003eSign up\u003c/a\u003e to create a free trial account.\u003c/li\u003e\n \t\u003cli\u003eHave a Bluemix account? Use \u003ca title=\"(Opens in a new tab or window)\" href=\"https://console.ng.bluemix.net/catalog/services/conversation\" target=\"_blank\"\u003ethis link\u003c/a\u003e.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n \t\u003cli\u003eIn the \u003cstrong\u003eService name\u003c/strong\u003e field, type a unique name for your new instance of the Conversation service.\nCheck the “Pricing Plans” for data limits for the Conversation service\u003c/li\u003e\n \t\u003cli\u003eClick \u003cstrong\u003eCreate\u003c/strong\u003e. You’ll see details about your new instance in the “Service Details” page.\u003c/li\u003e\n\u003c/ol\u003e\n\n\n\u003ch3\u003eCreating a Workspace\u003c/h3\u003e\nYou use the Conversation tool to create workspaces by either creating a new workspace from scratch, or  by importing a workspace from a \u003ca href=\"https://github.com/VidyasagarMSC/WatBot/blob/master/sample.json\"\u003eJSON file\u003c/a\u003e. You can also duplicate an existing workspace within the same service instance.\n\u003col\u003e\n \t\u003cli\u003eIf the Service Details page is not already open, click your Conversation service instance on the Bluemix console. (When you create a service instance, the Service Details page displays.)\u003c/li\u003e\n \t\u003cli\u003eOn the “Service Details” page, scroll down to \u003cstrong\u003eConversation tooling\u003c/strong\u003e and click \u003cstrong\u003eLaunch tool\u003c/strong\u003e.\u003c/li\u003e\n \t\u003cli\u003eClick \u003cstrong\u003eCreate\u003c/strong\u003e to create a new workspace.\u003c/li\u003e\n \t\u003cli\u003eSpecify the details for the new workspace:\n\u003cul\u003e\n \t\u003cli\u003e\u003cstrong\u003eName\u003c/strong\u003e: A name no more than 64 characters in length. This value is required.\u003c/li\u003e\n \t\u003cli\u003e\u003cstrong\u003eDescription\u003c/strong\u003e: A description no more than 128 characters in length.\u003c/li\u003e\n \t\u003cli\u003e\u003cstrong\u003eLanguage\u003c/strong\u003e: The language of the user input the workspace will be trained to understand. The service supports Brazilian Portuguese, English, French, Italian, and Spanish.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n \t\u003cli\u003eClick \u003cstrong\u003eCreate\u003c/strong\u003e. The new workspace is created and now appears as a tile on the Workspaces page.\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch3\u003eCreating an intent\u003c/h3\u003e\nYou use the Conversation tool to create intents. The number of intents and examples you can create in a single service instance depends on your Conversation service plan:\n\nCreate some intents.\n\u003col\u003e\n \t\u003cli\u003eIn the Conversation tool, open your workspace and then click the \u003cstrong\u003eIntents\u003c/strong\u003e tab.\u003c/li\u003e\n \t\u003cli\u003eClick \u003cstrong\u003eCreate new\u003c/strong\u003e.\u003c/li\u003e\n \t\u003cli\u003eIn the Intent name field, type a descriptive name for the intent. The intent name can contain letters (in Unicode), numbers, underscores, hyphens, and dots. Intent names cannot contain spaces and must not exceed 128 characters. The following are examples of intent names:\n\u003cul\u003e\n \t\u003cli\u003e\u003ccode\u003e#weather_conditions\u003c/code\u003e\u003c/li\u003e\n \t\u003cli\u003e\u003ccode\u003e#pay_bill\u003c/code\u003e\u003c/li\u003e\n \t\u003cli\u003e\u003ccode\u003e#escalate_to_agent\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cstrong\u003eTip\u003c/strong\u003e: Don’t include the \u003ccode\u003e#\u003c/code\u003e character in the intent names when you create them in the Conversation tool.\u003c/li\u003e\n \t\u003cli\u003eIn the \u003cstrong\u003eUser example\u003c/strong\u003e field, type the text of a user example for the intent. An example can be any string up to 1024 characters in length. The following might be examples for the \u003ccode\u003e#pay_bill\u003c/code\u003e intent:\n\u003cul\u003e\n \t\u003cli\u003e\u003ccode\u003eI need to pay my bill.\u003c/code\u003e\u003c/li\u003e\n \t\u003cli\u003e\u003ccode\u003ePay my account balance\u003c/code\u003e\u003c/li\u003e\n \t\u003cli\u003e\u003ccode\u003emake a payment\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cstrong\u003eImportant\u003c/strong\u003e: Intent names and example text can be exposed in URLs when an application interacts with the service. Do not include sensitive or personal information in these artifacts.\n\nPress Enter or click \u003cstrong\u003e+\u003c/strong\u003e to save the example.\u003c/li\u003e\n \t\u003cli\u003eRepeat the same process to add more examples. Provide at least 5 examples for each intent. The more examples you provide, the more accurate your application can be.\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/VidyasagarMSC/WatBot/initial/Images/define_intent.png\" alt=\"Screen\" /\u003e\u003c/p\u003e\n\u003c/li\u003e\n \t\u003cli\u003eWhen you have finished adding examples, click \u003cstrong\u003eCreate\u003c/strong\u003e to finish creating the intent.\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch3\u003eResults\u003c/h3\u003e\nThe intent you created is added to the Intents tab, and the system begins to train itself on the new data.\n\nYou can click any intent in the list to open it for editing. You can make the following changes:\n\u003cul\u003e\n \t\u003cli\u003eRename the intent.\u003c/li\u003e\n \t\u003cli\u003eDelete the intent.\u003c/li\u003e\n \t\u003cli\u003eAdd, edit, or delete examples.\u003c/li\u003e\n \t\u003cli\u003eMove an example to a different intent.\u003c/li\u003e\n\u003c/ul\u003e\nTo move an example, select the example by clicking the check box and then click \u003cstrong\u003eMove to\u003c/strong\u003e.\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/VidyasagarMSC/WatBot/initial/Images/move_example.png\" alt=\"“Screen\" /\u003e\u003c/p\u003e\n\n\u003ch3\u003eTesting your intents\u003c/h3\u003e\nAfter you have finished creating new intents, you can test the system to see if it recognizes your intents as you expect.\n\u003col\u003e\n \t\u003cli\u003eIn the Conversation tool, click the \u003cimg src=\"https://raw.githubusercontent.com/VidyasagarMSC/WatBot/initial/Images/ask_watson.png\" alt=\"“Ask\" /\u003e icon.\u003c/li\u003e\n \t\u003cli\u003eIn the Try it out panel, enter a question or other text string and press Enter to see which intent is recognized. If the wrong intent is recognized, you can improve your model by adding this text as an example to the correct intent.\u003cstrong\u003eTip\u003c/strong\u003e: If you have recently made changes in your workspace, you might see a message indicating that the system is still retraining. If you see this message, wait until training completes before testing:\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/VidyasagarMSC/WatBot/initial/Images/training.png\" alt=\"Screen\" /\u003e\u003c/p\u003e\nThe response indicates which intent was recognized from your input.\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/VidyasagarMSC/WatBot/initial/Images/test_intents.png\" alt=\"Screen\" /\u003e\u003c/p\u003e\n\u003c/li\u003e\n \t\u003cli\u003eIf the system did not recognize the correct intent, you can correct it. To correct the recognized intent, click the displayed intent and then select the correct intent from the list. After your correction is submitted, the system automatically retrains itself to incorporate the new data.\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/VidyasagarMSC/WatBot/initial/Images/correct_intent.png\" alt=\"Screen\" /\u003e\u003c/p\u003e\nIf your intents are not being correctly recognized, consider making the following kinds of changes:\n\u003cul\u003e\n \t\u003cli\u003eAdd the unrecognized text as an example to the correct intent.\u003c/li\u003e\n \t\u003cli\u003eMove existing examples from one intent to another.\u003c/li\u003e\n \t\u003cli\u003eConsider whether your intents are too similar, and redefine them as appropriate.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch3\u003eCreating an entity\u003c/h3\u003e\nYou use the Conversation tool to create entities. The number of entities, entity values, and synonyms you can create in a single service instance depends on your Conversation service plan:\n\u003col\u003e\n \t\u003cli\u003eIn the Conversation tool, open your workspace and then click the \u003cstrong\u003eEntities\u003c/strong\u003e tab.\u003c/li\u003e\n \t\u003cli\u003eClick \u003cstrong\u003eCreate new\u003c/strong\u003e.\u003c/li\u003e\n \t\u003cli\u003eIn the \u003cstrong\u003eAdd the entity name\u003c/strong\u003e field, type a descriptive name for the entity.The entity name can contain letters (in Unicode), numbers, underscores, and hyphens. For example:\n\u003cul\u003e\n \t\u003cli\u003e\u003ccode\u003e@location\u003c/code\u003e\u003c/li\u003e\n \t\u003cli\u003e\u003ccode\u003e@menu_item\u003c/code\u003e\u003c/li\u003e\n \t\u003cli\u003e\u003ccode\u003e@product\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cstrong\u003eTips\u003c/strong\u003e:\n\u003cul\u003e\n \t\u003cli\u003eDon’t include the \u003ccode\u003e@\u003c/code\u003e character in the entity names when you create them in the Conversation tool.\u003c/li\u003e\n \t\u003cli\u003eEntity names can’t contain spaces or be longer than 64 characters. And entity names can’t begin with the string \u003ccode\u003esys-\u003c/code\u003e, which is reserved for system entities.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n \t\u003cli\u003eIn the \u003cstrong\u003eValue\u003c/strong\u003e field, type the text of a possible value for the intent. An entity value can be any string up to 64 characters in length.\u003cstrong\u003eImportant\u003c/strong\u003e: Don’t include sensitive or personal information in entity names or values. The names and values can be exposed in URLs in an app.\u003c/li\u003e\n \t\u003cli\u003eIn the \u003cstrong\u003eSynonyms\u003c/strong\u003e field, type any synonyms for the entity value. A synonym can be any string up to 64 characters in length. Press Enter to save each synonym.\u003cimg src=\"https://raw.githubusercontent.com/VidyasagarMSC/WatBot/initial/Images/define_entity.png\" alt=\"Screen\" /\u003e\u003c/li\u003e\n \t\u003cli\u003eClick \u003cstrong\u003e+\u003c/strong\u003e and repeat the process to add more entity values.\u003c/li\u003e\n \t\u003cli\u003eWhen you are finished adding values and synonyms, click \u003cstrong\u003eCreate\u003c/strong\u003e.\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch3\u003eBuilding a Dialog\u003c/h3\u003e\nThe dialog component of the Conversation service uses the intents and entities that are identified in the user’s input to gather required information and provide a useful response. Your dialog is represented graphically as a tree; create a branch to process each intent that you define.\n\nPost branching Intents and entities, this is how my Conversation Dialog on Bluemix looks like\n\n![](https://github.com/VidyasagarMSC/WatBot/blob/initial/Images/Conversation_Service_Bluemix.png)\n\n## Configure the App\n\n  \u003cp\u003eTo configure  the App you need to get the Watson Conversation service \u003cstrong\u003eUsername\u003c/strong\u003e, \u003cstrong\u003ePassWord\u003c/strong\u003e and \u003cstrong\u003eWorkSpaceId\u003c/strong\u003e\u003c/p\u003e\n\n* In the \u003cstrong\u003eMainActivity\u003c/strong\u003e class locate the method named \u003cstrong\u003esendMessage()\u003c/strong\u003e.\n\n   ```\n     ConversationService service = new ConversationService(ConversationService.VERSION_DATE_2017_02_03);\n\n     service.setUsernameAndPassword(\"Your Watson service UserName\", \"Your watson service PassWord\");\n\n     MessageRequest newMessage = new MessageRequest.Builder().inputText(inputmessage).build();\n\n     MessageResponse response = service.message(\"Your Workspace Id\", newMessage).execute();\n   ```\n\n* Go to the Conversation service , and select the \u003cstrong\u003eService Credentials\u003c/strong\u003e tab. Select \u003cstrong\u003epassword\u003c/strong\u003e and \u003cstrong\u003eusername\u003c/strong\u003e.\n\n![Conversation Credentials](https://github.com/VidyasagarMSC/WatBot/blob/initial/Images/usernamePassword.png)\n\n \u003c/p\u003eAdd the `password` and `username` in the following code,\u003c/p\u003e\n\n ```\n service.setUsernameAndPassword(\"Your Watson service UserName\", \"Your watson service PassWord\");\n\n ```\n\n* Next is to get the \u003cstrong\u003eworkspace Id\u003c/strong\u003e.\n\n\u003cp\u003eLaunch the conversation service workspace and from the options select the \u003cstrong\u003eView details\u003c/strong\u003e.\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/VidyasagarMSC/WatBot/blob/initial/Images/workspace1.png\" width=\"350\"\u003e \n\u003cimg src=\"https://github.com/VidyasagarMSC/WatBot/blob/initial/Images/workspace2.png\" width=\"350\"\u003e\n\u003c/p\u003e\n\n\u003cp\u003eGet the \u003cstrong\u003eWorkspace ID:\u003c/strong\u003e and add it in the below code,\u003c/p\u003e\n\n```\nMessageResponse response = service.message(\"Your Workspace Id\", newMessage).execute();\n```\nGradle Entry \n\n```\ncompile 'com.ibm.watson.developer_cloud:conversation:3.8.0'\n```\n\n* Build and Run your app.\n\n## Enable Text to Speech \n\n* Create a Watson Text to Speech(TTS) service on [Bluemix](https://console.ng.bluemix.net/catalog/services/text-to-speech/?taxonomyNavigation=apps) \n* Navigate to Service Credentials tab and click on \"View Credentials\".\n\nOn Line 68 of MainActivity.kt, replace the username and password placeholders with the TTS service credentials\n\n```\nservice.setUsernameAndPassword(\"Your Text-to-Speech service username\", \"Your Text-to-Speech password\");\n```\n* Build and Run your app.\n\nNow when you TAP on any message, the text will be heard via a Voice (Voice.EN_LISA). You can change the voice formats in the code of MainActivity.kt\n\n\u003cstrong\u003eNote: \u003c/strong\u003e The required gradle entries for TTS is already included in the build.gradle file \n```\ncompile 'com.ibm.watson.developer_cloud:text-to-speech:3.8.0'\ncompile 'com.ibm.watson.developer_cloud:android-sdk:0.2.3'\n```\n\n## Enable Speech to Text\n\n* Create a Watson Speech-To-Text (STT) service on [Bluemix](https://console.ng.bluemix.net/catalog/services/speech-to-text/?taxonomyNavigation=apps) \n* Navigate to Service Credentials tab and click on \"View Credentials\".\n* Add the credentials to config.xml\n* Build and Run your app.\n\n\u003cstrong\u003eNote: \u003c/strong\u003e The required gradle entries for STT is already included in the build.gradle file \n```\ncompile 'com.ibm.watson.developer_cloud:speech-to-text:3.8.0'\ncompile 'com.ibm.watson.developer_cloud:android-sdk:0.2.3'\ncompile 'com.squareup.okhttp3:okhttp-ws:3.4.2'\n```\n\n### Chat with your own WatBot \n\nIf you have followed all the above instructions, you should be happily chatting with your Wat(son)Bot. \n\n** Remember your bot will be talking to your Conversation Service (Intents, Entities and Dialog).**\n\n### Don't stop here!!! Keep coding and using Bluemix","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVidyasagarMSC%2FWatBot-Kotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FVidyasagarMSC%2FWatBot-Kotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVidyasagarMSC%2FWatBot-Kotlin/lists"}