0

image of ibm watson and options (2nd image) image of options in ibm watson

How can I get list of options in my chatbot from IBM Watson Assistant? I am using IBM Watson AI platform. The chatbot code is below and a screenshot of options is given above. How can I get those options in my code?

final ConversationService myConversationService =
                new ConversationService(
                        "2017-05-26",
                        getString(R.string.username),
                        getString(R.string.password)
                );
    sendImg.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            Toast.makeText(MainActivity.this, "working", Toast.LENGTH_SHORT).show();
            inputText = etTypingMsg.getText().toString();



    MessageRequest request = new MessageRequest.Builder()
                            .inputText(inputText)
                            .build();

    myConversationService.message(getString(R.string.workspace), request)
                            .enqueue(new ServiceCallback<MessageResponse>() {
                                @Override
                                public void onResponse(MessageResponse response) {

                                    outputText = "";
                                    int length=response.getText().size();
                                    Log.i("testing", "run: "+length);
                                    if(length>1) {
                                        for (int i = 0; i < length; i++) {
                                            outputText += '\n' + response.getText().get(i).trim();
                                        }

                                    }
                                    else
                                        outputText = response.getText().get(0);

                                    runOnUiThread(new Runnable() {
                                        @Override
                                        public void run() {
                                            btnInvisisble.setVisibility(View.GONE);
                                            String chatkey= databaseReference.push().getKey();
                                            chatModel=new ChatModel(inputText,outputText,chatkey);
                                            databaseReference.child(userid).child("MainChatting").child(chatkey).setValue(chatModel);

                                            if(outputText.toLowerCase().contains("You should meet with".toLowerCase())){
                                                btnInvisisble.setVisibility(View.VISIBLE);
                                                btnInvisisble.startAnimation(shake);
                                                 }


                                        }
                                    });
                                }
                                @Override
                                public void onFailure(Exception e) {}
                            });

            etTypingMsg.setText("");
            try {
                InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
            } catch (Exception e) {
                // TODO: handle exception
            }
  • Any errors or any specific questions? What is not working? What did you try? – data_henrik Jul 12 '19 at 07:30
  • I don't know how to show this options(Given picture) of ibm watson assistance in my chatbot – jannat suha Jul 12 '19 at 10:09
  • I am not 100% sure what you are asking. I believe you are asking how do you display these options within the UI of your chat bot. - If that's the case, then you have a number of options. You could show these options as buttons, the list label being whats shown on the button, and the value the result when the button is selected. Or you could so a list, again when one of the list is selected, the value is what gets returned. I must also note that usually the value when the button/list is selected is the value that gets shown in the conversation, as if you had typed the value. – timd Jul 12 '19 at 22:56
  • yes. You got it. I want to display these options within the UI of my chat bot. Can you please show me any demo code related to this problem? I didn't understand, how will I do that? – jannat suha Jul 14 '19 at 04:38

1 Answers1

0

I know exactly why this isn't working for you. You need to use a more recent "version date". Your code shows that you are using "2017-05-26". That date is before the "options" feature was added to Assistant. Try using a recent date, like "2019-07-01". It will work then.

Mike Kistler
  • 437
  • 2
  • 10
  • I changed version to "2019-07-01". But still it is not working. options are not displaying within the UI of my chatbot. It is only working in "Try It out" of Watson. I added another image of ibm watson with my post. – jannat suha Jul 14 '19 at 04:33
  • I suppose you are asking how to display the options -- not how to retrieve them from Assistant. I can't help you with the UI part, but you should be getting the options values back now. They will be in `output.generic[0].options`. – Mike Kistler Jul 15 '19 at 00:19