I'm trying to keep the context in Watson Conversation, but it isn't working.. I already tried this answer, but it didn't worked. I'm trying to integrate the bot to the html.
I tried this in the conversation configuration:
var payload = {
workspace_id: workspace,
context: {}};
if (req.body) {
if (req.body.input) {
payload.input = req.body.input;
}
if(req.body.context) {
payload.context = req.body.context;
}}
And this in the code to html/javascript:
var payload = {};
var context = {};
function callWatson(){
alert("watson");
$.ajax({
type: 'POST',
dataType: 'JSON',
contentType: "application/json",
url: '/api/message',
data: JSON.stringify(payload)
}).done(function (json) {
if (json.output.text[0]) {
context = payload.context;
$'<div class="message">+ json.output.text[0]+</div>').appendTo($('.container'));
function insertMessage() {
msg = $('.message-input').val();
$'<div class="message">+ msg+</div>').appendTo($('.container'));
I'm a beginner in coding and I tried coping the conversation-simple js, but I wanted something more simple and direct.. Thanks in advance!
via barbs
No comments:
Post a Comment