0

我想在我的 Google Assistant Bot 中为用户添加建议。我正在使用 API.ai 进行机器人开发并使用实现,我正在与我的后端进行数据通信。
我无法使用建议芯片向我的机器人发送建议。

我已按照此处的回答使用“建议芯片” 以及https://developers.google.com/actions/assistant/responses#json上的文档进行Webhook 响应。但是,我仍然只能在设备和模拟器上的机器人上看到简单的文本响应。 我还查看了https://discuss.api.ai/t/google-assistant-rich-message-responses/5134/19。但是没有找到任何方法切换到V1或V2。示例格式也不起作用! 这是我的 2 个 JSON:在 API.ai





"fulfillment": {
  "speech": "want to proceed further?",
  "messages": [
    {
      "type": 0,
      "speech": "want to proceed further?"
    }
  ],
  "data": {
    "google": {
      "conversationToken": "[\"AS-PER-JSON-FROM-SIMULATOR\"]",
      "expectedInputs": [
        {
          "inputPrompt": {
            "richInitialPrompt": {
              "items": [
                {
                  "simpleResponse": {
                    "textToSpeech": "want to proceed further?",
                    "displayText": "want to proceed further?"
                  }
                }
              ],
              "suggestions": [
                {
                  "title": "Yes"
                },
                {
                  "title": "No"
                }
              ]
            }
          }
        }
      ]
    }
  }
},


在 Google 上采取行动

"expectUserResponse": true,
    "expectedInputs": [
        {
            "inputPrompt": {
                "richInitialPrompt": {
                    "items": [
                        {
                            "simpleResponse": {
                                "textToSpeech": "want to proceed?"
                            }
                        }
                    ]
                },
                "noMatchPrompts": [],
                "noInputPrompts": []
            },
            "possibleIntents": [
                {
                    "intent": "assistant.intent.action.TEXT"
                }
            ],
            "speechBiasingHints": [
                "$subject",
                "$answer"
            ]
        }
    ]


蟒蛇服务器

return = '{"speech":"want to proceed?", "data": {"google":{"expectedInputs":[{"inputPrompt":{"richInitialPrompt":{"items":[{"simpleResponse":{"textToSpeech":"want to proceed?","displayText":"want to proceed?"}}],"suggestions":[{"title":"Yes"},{"title":"No"}]}}}]}}}'
4

3 回答 3

0

使用此处解释的格式解决https://developers.google.com/actions/apiai/webhook

于 2017-06-07T16:01:33.930 回答
0

你的JSON是错误的,去掉数据对象前的引号:

"data" : { ... }

代替

"data" : "{ ... }"

所以基本上,您发送的是一个包含对象而不是 JSON 对象的字符串。

于 2017-06-07T11:25:04.930 回答
0

添加'expectUserResponse'data->google

'expectUserResponse': true,
'isSsml': false,
于 2017-06-09T04:03:55.697 回答