I'm currently working with Wit.ai on a webpage in CodePen.io. I was wondering if it is possible to retrieve a Wit.ai bot's text response ("Bot says") using the HTTP API.
For example: If a user was to prompt the bot with:
How's it going?
I would like to, after making an API call with this message, be able to retrieve the bot's typical response:
I am well, thank you human.
I've looked through the HTTP API Documentation. It seems like this done using a a 'POST' to api.wit.ai/converse. The JSON response contains a "msg" field, which is exactly what I need! Here is the code I'm currently using:
$.ajax({
url: baseUrl + "converse",
data: {
'q': text, // The message to send the bot
'session_id': "123abc",
'access_token' : accessToken // Authorisation key for using our bot
},
dataType: 'json',
crossDomain: true,
method: 'POST',
success: function(data) {
prepareResponse(data);
},
error: function() {
respond(messageInternalError);
}
});
However, Wit.Ai does not support CORS at the moment, the only way to make Cross-domain requests is using JSONP, which only works for GET requests. As can be expected, the code above results in HTTP 400 error.
Can anyone confirm whether it is possible to use the HTTP API to retrieve a bot's textual response to a user message? Is there a work around to what I am currently doing?