Я пытаюсь сделать действия Google, используя DialogFlow API в Java.
Я использую Webhook для ответа на действия для DialogFlow, показанного в
ниже изображение.
при попытке использования этого кода он работает нормально и дает правильный ответ, поскольку в диалоговом потоке есть предопределенная возможность действий.
Код:
@PostMapping("/webhook")
public ResponseEntity payload(RequestBody FulfillmentResponse fulfillmentResponse) {
log.info(fulfillmentResponse.getQueryResult().getQueryText());
return ResponseEntity.ok(HttpStatus.OK);
}
Но когда я даю ответ динамически. Это дает мне ошибку.
Код:
@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" +
"}");
}
Ошибка:
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"
}
та же ошибка в виде скриншота: