Reputation: 85
Is it possible to integrate API.Ai into a web channel? Microsoft Bot framework has an option that the bot can be invoked through a web chat along with FB messenger, skype etc. For this MSFT provies a chat url which can be embedded in any html page. Can the same happen through API.AI?
Is it also possible to invoke the NLP part of API.Ai, like the trained intents, context etc. from any stand-alone application?
Upvotes: 1
Views: 558
Reputation: 79
Yes you can invoke the NLP part of api.ai with the help of events.
First create events with the help of the following URL : https://docs.api.ai/docs/concept-events
Now from your web application you could use the following code to invoke these events,
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("https://api.api.ai/v1/query?v=20150910");
StringEntity params =new StringEntity("{\"event\":{ \"name\": \"custom_event\", \"data\": {\"name\": \"Sam\"}}, \"timezone\":\"America/New_York\", \"lang\":\"en\", \"sessionId\":\"123abc\"}");
request.addHeader("content-type", "application/json");
request.addHeader("Authorization", "Bearer 0651225b57464d209936252796106e59");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null)
{
System.out.println(line);
}
This would then return you the appropriate response.
Upvotes: 2
Reputation: 4228
Yes you can. You need to build a frontend application ables to invoke api.ai services (by api.ai sdk).
Upvotes: 0