简体   繁体   English

尝试使用 Webhook On Dialogflow 动态提供响应时出现 Webhook 响应错误 (206)

[英]getting Webhook response error (206) when trying to give response Dynamically using webhook On Dialogflow

I am trying to make a google actions using DialogFlow api in java.我正在尝试在 java 中使用 DialogFlow api 进行 google 操作。 I am using Webhook for request Response for actions on DialogFlow Shown in below image.我正在使用 Webhook 对 DialogFlow 上的操作进行请求响应,如下图所示。

在此处输入图片说明

when Trying This Code it works fine and gives proper response as dialogflow have predefined actions facility.当尝试此代码时,它工作正常并提供适当的响应,因为对话流具有预定义的操作设施。

Code:代码:

@PostMapping("/webhook")
public ResponseEntity payload(RequestBody FulfillmentResponse fulfillmentResponse) {
   log.info(fulfillmentResponse.getQueryResult().getQueryText());
   return ResponseEntity.ok(HttpStatus.OK);
}

But When I am giving response Dynamically.但是当我动态给出响应时。 It gives me an error.它给了我一个错误。

Code:代码:

@PostMapping("/webhook")
public ResponseEntity payload(RequestBody FulfillmentResponse fulfillmentResponse) {
    log.info(fulfillmentResponse.getQueryResult().getQueryText());
    return ResponseEntity.ok("{\n" + 
            "  \"data\": {\n" + 
            "    \"google\": {\n" + 
            "      \"expectUserResponse\": true,\n" + 
            "      \"richResponse\": {\n" + 
            "        \"items\": [\n" + 
            "          {\n" + 
            "            \"simpleResponse\": {\n" + 
            "              \"textToSpeech\": \"Choose a item\"\n" + 
            "            }\n" + 
            "          }\n" + 
            "        ]\n" + 
            "      },\n" + 
            "      \"systemIntent\": {\n" + 
            "        \"intent\": \"assistant.intent.action.TEXT\",\n" + 
            "        \"data\": {\n" + 
            "          \"@type\": \"type.googleapis.com/google.actions.v2.OptionValueSpec\",\n" + 
            "          \"listSelect\": {\n" + 
            "            \"title\": \"Hello\",\n" + 
            "            \"items\": [\n" + 
            "              {\n" + 
            "                \"optionInfo\": {\n" + 
            "                  \"key\": \"first title\"\n" + 
            "                },\n" + 
            "                \"description\": \"first description\",\n" + 
            "                \"image\": {\n" + 
            "                  \"url\": \"https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png\",\n" + 
            "                  \"accessibilityText\": \"first alt\"\n" + 
            "                },\n" + 
            "                \"title\": \"first title\"\n" + 
            "              },\n" + 
            "              {\n" + 
            "                \"optionInfo\": {\n" + 
            "                  \"key\": \"second\"\n" + 
            "                },\n" + 
            "                \"description\": \"second description\",\n" + 
            "                \"image\": {\n" + 
            "                  \"url\": \"https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw\",\n" + 
            "                  \"accessibilityText\": \"second alt\"\n" + 
            "                },\n" + 
            "                \"title\": \"second title\"\n" + 
            "              }\n" + 
            "            ]\n" + 
            "          }\n" + 
            "        }\n" + 
            "      }\n" + 
            "    }\n" + 
            "  }\n" + 
            "}");
}

Error:错误:

2018-11-02 16:14:43.906 IST Error in fulfillment status received from app endpoint. See ResponseMetadata in the response. Status code: 14. Error message: Webhook error (206)
 { 
   insertId: "6nwj8wf153t5q"  
   labels: {
            channel:  "preview"   
            querystream:  "GOOGLE_USER"   
            source:  "AOG_REQUEST_RESPONSE"   
           }
   logName: "projects/elysiot-217606/logs/actions.googleapis.com%2Factions"  
   receiveTimestamp:  "2018-11-02T10:44:43.940057016Z"  
   resource: {
             labels: {
                     action_id:  "actions.intent.TEXT"    
                     project_id:  "elysiot-217606"    
                     version_id:  ""    
                     }
             type:  "assistant_action"   
             }
   severity:  "ERROR"  
   textPayload:  "Error in fulfillment status received from app endpoint. See ResponseMetadata in the response. Status code: 14. Error message: Webhook error (206)"  
   timestamp:  "2018-11-02T10:44:43.906927701Z"  
   trace:  "projects/847724381623/traces/ABwppHFGjhCqYgY_YpSxJp5p9-s6NpvBRVzWdzGRhfypm0eZcqzYjDqjCVsdpxVXofc4xpOFLs4eAtWf9Ek"  
  }

same error in the form of screenshot:屏幕截图形式的相同错误:

在此处输入图片说明

I assume you are building the JSON response using Java.我假设您正在使用 Java 构建 JSON 响应。 The request is sent from AoG to Dialogflow which invokes your webhook.请求从 AoG 发送到调用您的 webhook 的 Dialogflow。 In this case, Dialogflow wraps the original AoG request into a "originalDetectIntentRequest" as described in https://developers.google.com/actions/build/json/dialogflow-webhook-json在这种情况下,Dialogflow 将原始 AoG 请求包装到“originalDetectIntentRequest”中,如https://developers.google.com/actions/build/json/dialogflow-webhook-json 中所述

Since you are parsing the JSON request and building the response in your webhook, you should refer to the above URL for the raw JSON protocol.由于您正在解析 JSON 请求并在您的 webhook 中构建响应,因此您应该参考上述原始 JSON 协议的 URL。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM