Java POJOs / DTOs / domain objects for the Actions on Google Conversation API: https://developers.google.com/actions/reference/conversation
The artifact is available in Maven Central.
Example:
<dependency>
<groupId>com.macasaet.google.conversation</groupId>
<artifactId>google-actions-conversation-api</artifactId>
<version>0.0.14</version>
</dependency>
These objects can be used with JAX-RS like so:
@Path("/webhook/guessnumber")
@Consumes("application/json")
@Produces("application/json")
@POST
public ConversationResponse guessNumber(final ConversationRequest request,
@Context final HttpServletResponse servletResponse) {
servletResponse.setHeader("Google-Assistant-API-Version", "v1");
return ConversationResponse.ask().withConversationToken("42")
.withInitialTextToSpeech("What is your next guess?")
.withNoInputTextToSpeech("I didn't hear a number.")
.withNoInputTextToSpeech("If you're still there, what's your guess?")
.withNoInputTextToSpeech("We can stop here. Let's play again soon.")
.withExpectedIntentId("assistant.intent.action.TEXT").build();
}
See the full example and more in the test directory.
Ensure that your JSON library is configured to:
- not fail if it encounters unknown properties (during deserialisation of JSON to POJO)
- exclude fields that are
null
or empty (during serialisation of POJO to JSON)
mvn --batch-mode -Prelease clean release:clean release:prepare release:perform
Then, commit and push changes.