如何为新的Google Actions Builder构建Java Webhook

huangapple go评论75阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年10月13日 05:26:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/64325561.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定