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:
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 apiaiFor the Nashorn host, CapeCode includes a port of the apiai module that works under Nashorn.
||string||A query that the service is to respond to.|
||object||The full response from the service.|
||string||The fulfillment text within the response.|
||string||The client access token for the service.|
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().