대화 서비스에서 샘플 교육 데이터를 만들고 이제 해당 서비스에 대한 게시 통화를 만들려고합니다. 노드 js를 사용하여 채팅 응용 프로그램을 만듭니다. 나는 게시물 호출을 만들었지 만 예상대로 작동하지 않습니다. 모든 호출에 대한 기본 응답을 제공합니다.노드 js에서 게시 통화를 만들 때 Watson 대화가 모든 요청에 대해 동일한 기본 응답을 반환하는 이유
나는 흐름을 수행하기 위해 다음 호출에 대한 응답에서 얻은 컨텍스트 값을 전달해야한다는 것을 알게되었다. 그러나 어떻게해야하는지 잘 모르겠다. 누군가 나를 도와 줄 수 있어요. 다음은 누군가가 우리가 help.U 테스트 현지에서 코드를 실행할 수있는 사람을 work..Can 만들 수있는 컨텍스트를 전달할 수있는 방법을 좀 도와 줄래 내 코드
var express = require('express');
var conversationV1 = require('watson-developer-cloud/conversation/v1');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));
var conversation = new conversationV1({
username: 'xxxxxx-1a06-4a90-xxxxx-xxxxxxxxxxx',
password: 'xxxxxxxxxx',
version_date: conversationV1.VERSION_DATE_2016_09_20
});
const updateMessage = (input, response) => {
var responseText = null;
if (!response.output) {
response.output = {};
} else {
return response;
}
if (response.intents && response.intents[0]) {
var intent = response.intents[0];
if (intent.confidence >= 0.75) {
responseText = 'I understood your intent was ' + intent.intent;
} else if (intent.confidence >= 0.5) {
responseText = 'I think your intent was ' + intent.intent;
} else {
responseText = 'I did not understand your intent';
}
}
response.output.text = responseText;
return response;
};
app.post('/api/message', (req, res, next) => {
const workspace = '254654de-2bfe-423a-92ec-6aa66620625a';
if (!workspace || workspace === '<workspace-id>') {
return res.json({
output: {
text: 'Please check the workspace'
}
});
}
const payload = {
workspace_id: workspace,
input: req.body.input || {},
context: req.body.context || {}
};
// Send the input to the conversation service
conversation.message(payload, (error, data) => {
if (error) {
return next(error);
}
return res.json(updateMessage(payload, data));
});
});
app.listen(process.env.PORT || 3000);
exports.app = app
입니다.
이것은 대화의 단순한 사본입니다. 간단합니까? 그래서 그것은 밖으로 작동합니다. 대화 ID가 변경되지 않는 것을 확인하는 것이 좋습니다. 그렇다면 앱에 문제가 있습니다. 그렇지 않은 경우 대화에 문제가 있으므로 디버그해야합니다. –
@ SimonO'Doherty 대화 ID가 매번 변경 중입니다. – user7350714
대화 단순 응용 프로그램을 변경 한 경우 거기에서 확인하십시오. 게시 한 내용으로 계속 진행하기에 충분하지 않습니다. –