I am trying to make a google actions using DialogFlow api in java. I am using Webhook for request Response for actions on DialogFlow Shown in below image.
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. The request is sent from AoG to Dialogflow which invokes your webhook. 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
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.
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.