javawebhooksactions-on-googleactions-builder

How to build Java webhook for new Google actions builder


I created the java webhook in past for dialogflow where 1-1 mapping of intent used to be done. Now I am working with actions builder & not getting how to define and build the handlers using Java.

Before @ForIntent was used to map the intents with java methods. Now how should I map the methods with any scene or handlers.


Solution

  • At the moment there isn't a client library or a SDK to use in order to implement a webhook in Java for the Actions Builder.

    You have to implement this manually, exposing and endpoint able to receive POST requests with a HandlerRequest object as input param, as specified in this json-schema

    Once created your webhook, to select the handler to use you have to check the value under handler.name field of the request and invoke the right handler. To avoid hardcoded if/switch you could use a strategy pattern and reflection/bean loading to invoke the specific handler, using the value achieved by the field handler.name.