If I set the context object in a Watson's conversation I expect that it remains the nodes it previously visited I mean:
After firing an greetings' Intent, if I type 'bye' (a goodbyes Intent). It should fire a goodbyes's Intent but it just works in the test tool.
Here is the code in my Nodejs app:
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)
}
})
}
Although the conversation_id is always the same. I am always getting the anythingelse's Intent response instead of goodbyes' 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' } } }
via Luillyfe
No comments:
Post a Comment