Reputation: 1010
Is it possible or in the Roadmap to develop your own Action on Google without to use API.ai or the NodeJS SDK?
Upvotes: 4
Views: 1277
Reputation: 19416
Now there is another option for Kotlin/Java. This is an open source port of the official Actions on Google SDK. The official node.js SDK supports both API.ai and Actions SDK (direct integration), and the Kotlin/Java one does as well. It is under development, but is nearing 100% complete and more documentation/examples will be coming. https://github.com/TicketmasterMobileStudio/actions-on-google-kotlin
Upvotes: 0
Reputation: 1176
You can implement an Actions on Google compatible webhook using JAX-RS. For example, this Java library models the HTTP protocol that Google documented: https://github.com/l0s/google-actions-conversation-api . See the documentation for more details. An example implementation looks like this:
@Path("/webhook")
@Consumes("application/json")
@Produces("application/json")
@POST
public ConversationResponse handle(final ConversationRequest request,
@Context final HttpServletResponse servletResponse) {
servletResponse.setHeader("Google-Assistant-API-Version", "v1");
final SpeechResponse speechResponse = new SpeechResponse();
speechResponse.setTextToSpeech("Hello!");
final FinalResponse finalResponse = new FinalResponse();
finalResponse.setSpeechResponse(speechResponse);
final ConversationResponse response = new ConversationResponse();
response.setConversationToken(request.getConversationToken());
response.setFinalResponse(finalResponse);
return response;
}
Note that you would need to configure the JSON serialiser/deserialiser ignore unknown properties during deserialisation and to exclude null or empty fields during serialisation.
You do not need to use the library necessarily, but it gives you an idea of how to implement the webhook with a servlet. Also, this approach (with or without the library) does not need to be used with JAX-RS necessarily. The same technique can be applied to a serverless solution such as AWS API Gateway with Lambda.
Upvotes: 2
Reputation: 967
It is already possible: I built a very small example of a Conversation Action in Java with Vert.x: https://github.com/Ithildir/actions-on-google-vertx-sample
Here you can find more information about the HTTP protocol: https://developers.google.com/actions/reference/conversation
Upvotes: 4