Расширенные ответы Google Assistant с API.AI

У меня уже есть веб-перехватчик, и я использую его для изменения ответов помощника. Но я не могу понять, как отправить карточку с предложениями или ссылку, так как вы можете отправить их из веб-интерфейса API.AI (с помощью кнопки добавления содержимого).

Должен ли я послать их как JSON object под именем data.

https://api.ai/docs/fulfillment#responseДокументация по API.AI для веб-перехватчика


person Omar Elrefaei    schedule 24.08.2017    source источник


Ответы (1)


Общая форма тела JSON ответа на вызов веб-перехватчика выполнения API.AI, который будет включать расширенный ответ Action on Google для простого ответа и карточку, приведена ниже. Если вы хотите использовать списки или карусель, документация находится здесь:

{
  "speech": "This is a API.AI default speech response",
  "displayText": "This is a API.AI default display text response",
  "data": {
    "google": {
      "expectUserResponse": true,
      "isSsml": false,
      "noInputPrompts": [],
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "This is a simple speech response for Actions on Google.",
              "displayText": "This is a simple display text response for Action on Google."
            }
          },
          {
            "basicCard": {
              "title": "Title: this is a title",
              "subtitle": "This is a subtitle",
              "formattedText": "This is a basic card.  Text in a basic card can include \"quotes\" and most other unicode characters including emoji ????.  Basic cards also support some markdown formatting like *emphasis* or _italics_, **strong** or __bold__, and ***bold itallic*** or ___strong emphasis___ as well as other things like line  \nbreaks",
              "image": {
                "url": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
                "accessibilityText": "Image alternate text"
              },
              "buttons": [
                {
                  "title": "This is a button",
                  "openUrlAction": {
                    "url": "https://assistant.google.com/"
                  }
                }
              ]
            }
          }
        ]
      }
    }
  }
}
person matthewayne    schedule 26.08.2017