在对话框流中添加输入选项(或卡片,标签)

时间:2018-07-03 18:00:19

标签: actions-on-google dialogflow

我想添加建议的输入选项(或卡片或标签),如Dialogflow的下图所示,我将进一步与google Assistant集成。任何人都可以帮助我从哪里开始或从哪里开始。我已经看到了插槽填充,内容和后续意图。谢谢。ignore the first 2 lines

2 个答案:

答案 0 :(得分:1)

您可能想使用Carousel丰富的回复。

如果您使用的是Google行动库,则代码可能类似于以下内容:

conv.ask(new Carousel({
  items: {
    // Add the first item to the carousel
    [SELECTION_KEY_ONE]: {
      synonyms: [
        'synonym of title 1',
        'synonym of title 2',
        'synonym of title 3',
      ],
      title: 'Title of First Carousel Item',
      description: 'This is a description of a carousel item.',
      image: new Image({
        url: IMG_URL_AOG,
        alt: 'Image alternate text',
      }),
    },
    // Add the second item to the carousel
    [SELECTION_KEY_GOOGLE_HOME]: {
      synonyms: [
        'Google Home Assistant',
        'Assistant on the Google Home',
    ],
      title: 'Google Home',
      description: 'Google Home is a voice-activated speaker powered by ' +
        'the Google Assistant.',
      image: new Image({
        url: IMG_URL_GOOGLE_HOME,
        alt: 'Google Home',
      }),
    },
    // Add third item to the carousel
    [SELECTION_KEY_GOOGLE_PIXEL]: {
      synonyms: [
        'Google Pixel XL',
        'Pixel',
        'Pixel XL',
      ],
      title: 'Google Pixel',
      description: 'Pixel. Phone by Google.',
      image: new Image({
        url: IMG_URL_GOOGLE_PIXEL,
        alt: 'Google Pixel',
      }),
    },
  },
}));

如果您使用多声库,则响应的配置可能类似于

Local: {
  en: {
    Response: {
      "Action.options.get": {
        Template: {
          Text: "Here are the results"
          Option: {
            Type: "carousel",
            Items: [
              {
                Title: "First Option",
                Body: "First Body"
              },
              {
                Title: "Second Option",
                Body: "Second Body"
              },
              {
                Title: "Third Option",
                Body: "You guessed it, third body"
              }
            ]
          }
        }
      }
    }
  }
}

如果您使用的是JSON,您的响应应该看起来像这样

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "Choose a item"
            }
          }
        ]
      },
      "systemIntent": {
        "intent": "actions.intent.OPTION",
        "data": {
          "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
          "carouselSelect": {
            "items": [
              {
                "optionInfo": {
                  "key": "first title"
                },
                "description": "first description",
                "image": {
                  "url": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
                  "accessibilityText": "first alt"
                },
                "title": "first title"
              },
              {
                "optionInfo": {
                  "key": "second"
                },
                "description": "second description",
                "image": {
                  "url": "https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw",
                  "accessibilityText": "second alt"
                },
                "title": "second title"
              }
            ]
          }
        }
      }
    }
  }
}

(这些示例都没有包含建议筹码,您也曾表示过想要。)

处理响应时,您的意图应处理操作actions_intent_OPTION

答案 1 :(得分:0)

在屏幕截图底部是建议的输入芯片,它们很容易添加。请按照以下说明进行操作:How to create suggested input in actions on google while creating an google assistant app in dialogflow?