Reputation: 1622
I'm implementing a watson conversation chat, now i'm wondering, how i can import this chat in a existing website?
any helps?
Upvotes: 2
Views: 452
Reputation: 5330
You can see one example conversation-simple in Nodejs and Conversation-with-discovery in Java.
This repository it is from IBM Developers.
This example show one example how to call the API and has some front-end for show the conversation flow and Watson understands, all you have to know how to use Watson, context variables, intents, entities, etc.
In this case, you call conversation API with Service Credentials and Workspace_id from your Conversation created inside IBM Bluemix:
Example to call and invoke the result with Javascript language (nodejs):
var conversation = new Conversation({
// If unspecified here, the CONVERSATION_USERNAME and CONVERSATION_PASSWORD env properties will be checked
// username: '<username>', paste the Service Credentials here or paste in env archive
// password: '<password>',
url: 'https://gateway.watsonplatform.net/conversation/api',
version_date: '2016-10-21',
version: 'v1'
});
// Endpoint to be call from the client side
app.post('/api/message', function(req, res) {
var workspace = process.env.WORKSPACE_ID || '<workspace-id>'; //workspace id can be check inside Conversation Service, click View details
if (!workspace || workspace === '<workspace-id>') {
return res.json({
'output': {
'text': 'The app has not been configured with a <b>WORKSPACE_ID</b> environment variable.' //error if workspace_id is not set
}
});
}
var payload = {
workspace_id: workspace,
context: req.body.context || {},
input: req.body.input || {}
};
// Send the input to the conversation service
conversation.message(payload, function(err, data) {
if (err) {
return res.status(err.code || 500).json(err);
}
return res.json(updateMessage(payload, data));
});
});
You can use other languages (Python, curl, Java) see this Documentation.
Check the example here running.
Upvotes: 3