其他 SDK 或 REST API 用于 Google 上的操作?

Other SDK or REST API for actions on Google?

是否可以或在路线图中在不使用 API.ai 或 NodeJS SDK 的情况下在 Google 上开发自己的 Action?

这已经成为可能:我在 Java 中使用 Vert.x: https://github.com/Ithildir/actions-on-google-vertx-sample

构建了一个非常小的对话操作示例

您可以在此处找到有关 HTTP 协议的更多信息:https://developers.google.com/actions/reference/conversation

您可以使用 JAX-RS 在 Google 兼容的 webhook 上实施操作。例如,这个 Java 库模拟了 Google 记录的 HTTP 协议: https://github.com/l0s/google-actions-conversation-api 。有关详细信息,请参阅文档。示例实现如下所示:

@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;
}

请注意,您需要配置 JSON serialiser/deserialiser 在反序列化期间忽略未知属性并在序列化期间排除 null 或空字段。

您不一定需要使用该库,但它会让您了解如何使用 servlet 实现 webhook。此外,这种方法(有或没有库)不一定需要与 JAX-RS 一起使用。同样的技术可以应用于无服务器解决方案,例如 AWS API Gateway with Lambda。

现在 Kotlin/Java 多了一个选项。这是官方 Actions on Google SDK 的开源端口。官方 node.js SDK 同时支持 API.ai 和 Actions SDK(直接集成),Kotlin/Java SDK 也支持。它正在开发中,但已接近 100% 完成,并且还会有更多 documentation/examples。 https://github.com/TicketmasterMobileStudio/actions-on-google-kotlin