首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在Dialogflow webhooks APIV2中返回列表?

如何在Dialogflow webhooks APIV2中返回列表?
EN

Stack Overflow用户
提问于 2018-03-03 02:08:52
回答 1查看 678关注 0票数 0

我已经看到了大多数关于如何通过webhooks返回丰富内容的示例,只涉及基本的响应和Card。

https://github.com/dialogflow/fulfillment-webhook-nodejs/blob/master/functions/index.js

在dialogflow webhook V2响应中需要什么结构才能返回List或Carousel?

EN

回答 1

Stack Overflow用户

发布于 2018-08-09 08:08:11

如果您想将carousel和list与Dialogflow结合起来,您将需要导入actions-on-google模块,因为并非所有的富响应都由Dialogflow单独支持。你可以在Actions on Google Rich Responses reference docs上看到。还有一个Fulfillment-Actions on Google sample

代码语言:javascript
复制
const { WebhookClient } = require('dialogflow-fulfillment');
const { Carousel } = require('actions-on-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',
      }),
    },
  },
}));
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49074953

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档