如果我設置在沃森的對話上下文對象的方式工作,我希望它保持它以前訪問過的節點我的意思是:語境在沃森的談話是不是在它應該工作
在發出問候意圖後,如果我輸入'再見'(再見意圖)。它應該激發一個再見的意圖,但它只是在測試工具中工作。
這裏是我的應用程序的NodeJS代碼:
let context = {}
const conversation = new ConversationV1({
username: 'myUsername',
password: 'myPassword',
url: 'https://gateway.watsonplatform.net/conversation/api',
version_date: '2017-05-26'
})
conversation.message({ workspace_id: workspaceId}, function (err, response) {
if (err) {
console.log(err)
} else {
context = response.context
}
})
sendMessage = (message = null) => new Promise((resolve, reject) => {
conversation.message({
input: {text: message},
workspace_id: workspaceId,
context: context
}, function (err, response) {
if (err) {
reject(err)
} else {
resolve(response.output.text)
}
})
}
雖然conversation_id始終是相同的。我總是得到anythingelse的Intent響應 ,而不是告別的意圖。
{ intents: [ { intent: 'greetings', confidence: 1 } ],
entities: [],
input: { text: 'hi' },
output:
{ text: [ 'It is nice to talk to you, again !' ],
nodes_visited: [ 'greetings' ],
log_messages: [] },
context:
{ conversation_id: '7cc96494-d108-4dc9-95c4-63c174f20b4c',
system:
{ dialog_stack: [Object],
dialog_turn_counter: 2,
dialog_request_counter: 2,
_node_output_map: [Object] } } }
{ intents: [ { intent: 'goodbytes', confidence: 1 } ],
entities: [],
input: { text: 'bye' },
output:
{ text: [ 'I didn\'t understand. You can try rephrasing.' ],
nodes_visited: [ 'Anything else' ],
log_messages: [] },
context:
{ conversation_id: '7cc96494-d108-4dc9-95c4-63c174f20b4c',
system:
{ dialog_stack: [Object],
dialog_turn_counter: 2,
dialog_request_counter: 2,
_node_output_map: [Object],
branch_exited: true,
branch_exited_reason: 'completed' } } }
非常感謝,它確實指出了我在正確的道路上,但是我要爲這個問題添加具體解決方案的答案。 – Luillyfe