我正在尝试在 java 中使用 DialogFlow api 进行 google 操作。我正在使用 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" +
"}");
}
浮云间
相关分类