小编Mar*_*nti的帖子

在actions-on-google Nodejs v2中构建列表

我可能会遗漏一些非常明显的东西,但我还没弄明白如何在动作在谷歌Nodejs客户端库的v2中以编程方式构建List.

换句话说,我想做类似下面的conv.ask代码,但事先不知道项目,因此需要创建一个列表,将项目添加到列表中,然后以动态方式询问列表.我可以在v1中执行以下操作:

var rList = app.buildList("Please select one option:");
for (var r =0; r < resp_text.length; r++) {
  rList.addItems(app.buildOptionItem(resp_value[r], resp_matches[r]).setTitle(resp_text[r]));
}
app.askWithList(question_str, rList);
Run Code Online (Sandbox Code Playgroud)

...所以基本上我正在寻找上面的v2等价物.

任何帮助表示感谢,谢谢!

conv.ask(new List({
    title: 'Things to learn about',
    items: {
      // Add the first item to the list
      'MATH_AND_PRIME': {
        synonyms: [
          'math',
          'math and prime',
          'prime numbers',
          'prime',
        ],
        title: 'Title of the First List Item',
        description: '42 is an abundant number',
        image: new Image({
          url: 'https://example.com/math_and_prime.jpg',
          alt: 'Math & prime numbers',
        }),
      },
      // …
Run Code Online (Sandbox Code Playgroud)

actions-on-google

2
推荐指数
1
解决办法
307
查看次数

标签 统计

actions-on-google ×1