英文:
How to build Java webhook for new Google actions builder
问题
我曾经为Dialogflow创建过Java Webhook,其中进行了意图的一一映射。现在我正在使用Actions Builder,并且不知道如何使用Java定义和构建处理程序。
之前使用 @ForIntent 来将意图与Java方法进行映射。现在我应该如何将这些方法与任何场景或处理程序进行映射。
英文:
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.
答案1
得分: 1
目前还没有针对Java的Actions Builder的客户端库或SDK可用于实现webhook。
您需要手动实现此功能,公开一个能够接收带有HandlerRequest
对象作为输入参数的POST请求的端点,如此json-schema所指定的那样。
创建完您的webhook之后,要选择要使用的处理程序,您需要检查请求中handler.name
字段下的值,并调用正确的处理程序。为了避免硬编码的if/switch语句,您可以使用策略模式和反射/bean加载来调用特定的处理程序,使用字段handler.name
获取到的值。
英文:
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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论