Accessor: services/NaturalLanguage

services/NaturalLanguage

Respond to textual inputs using the natural-language server from Google called API.AI (see http://api.ai). To use this, you need to create an agent at API.AI, using for example the tutorial here:

https://developers.google.com/actions/develop/apiai/tutorials/getting-started

An agent parses input text (natural language) and matches queries against rules defined in the agent to issue responses. For example, the above tutorial walks you through creating an agent that asks for your favorite number and color and then constructs a silly name by concatenating the two.

Once you have created an agent, you should set the '''clientAccessToken''' parameter to the hex key that identifies the agent. Without this token this accessor will not do anything.

This accessor is just a starting point. It should be extended to support multiple languages, for example. Also, it would be nice if there were a public agent that we could provide a default client access token for so that the accessor would work out of the box, without having to go create your own agent.

This accessor uses the apiai modeul, which is supported by at least the Nashorn (and CapeCode) hosts and the Node.js host. To use this under the Node.js host, install the apiai NPM module as follows:

   npm apiai
 
For the Nashorn host, CapeCode includes a port of the apiai module that works under Nashorn.

Version:
  • $$Id$$
Author:
  • Edward A. Lee
Source:
Inputs:
Name Type Description
textQuery string A query that the service is to respond to.
Outputs:
Name Type Description
response object The full response from the service.
fulfillment string The fulfillment text within the response.
Parameters:
Name Type Description
clientAccessToken string The client access token for the service.

Methods

(inner) extractFulfillment()

Given a response structure, find the fulfillment speech within it and return that. If there is no fulfillment speech in the response, then just return the entire response formatted using util.inspect().

Source: