有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

用于Java客户端库的Dialogflow实现

我正在迁移我们的对话流代理以使用V2 API。我们的V1实现使用来自对话流(api ai)的Java客户端库。我们的web服务在webhook端点上接收请求,该端点被配置为调用“DoWebBook”方法

下面是我使用AIWebhookRequest和Fulfillment的V1实现

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    Fulfillment output = new Fulfillment();
    doWebhook(gson.fromJson(request.getReader(), AIWebhookRequest.class), output);

    response.setCharacterEncoding(RESPONSE_CHARACTER_ENCODING);
    response.setContentType("application/json");
    gson.toJson(output, response.getWriter());
}

/** handle the actions passed by Google Home intents **/
protected void doWebhook(AIWebhookRequest input, Fulfillment output) {.....}

我现在正在尝试使用google-cloud-dialogflow-v2 java库,并做了以下更改

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    Fulfillment output = new Fulfillment(); // ** This is still V1, What could I use from V2 here??**
    doWebhook(gson.fromJson(request.getReader(), *WebhookRequest*.class), output);

    response.setCharacterEncoding(RESPONSE_CHARACTER_ENCODING);
    response.setContentType("application/json");
    gson.toJson(output, response.getWriter());
}

/** handle the actions passed by Google Home intents **/
protected void doWebhook(*WebhookRequest* input, *WebhookResponse* output) {.....}

我的问题马上就到

履行输出=新履行();//这仍然是V1,我可以从V2中使用什么


共 (0) 个答案