简体   繁体   中英

Getting list of options in my chatbot from IBM Watson Assistant

image of ibm watson and options (2nd image) 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
            }

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM