image of ibm watson and options (2nd image)
如何从IBM Watson Assistant获得我的聊天机器人中的选项列表?我正在使用IBM Watson AI平台。聊天机器人代码在下面,选项屏幕快照在上面。如何在代码中获得这些选项?
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
}
答案 0 :(得分:0)
我完全知道为什么这对您不起作用。您需要使用更新的“版本日期”。您的代码显示您正在使用“ 2017-05-26”。该日期是在“选项”功能添加到助手之前的。尝试使用最近的日期,例如“ 2019-07-01”。这样就可以了。