在“ Google上的操作”中构建列表; [英] building a list in "actions on google"

查看:76
本文介绍了在“ Google上的操作”中构建列表;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个项目,其中Google Assistant会生成有关研究文章信息的卡片列表。列表中的每张卡片都会有研究文章的标题和URL。 Google助理会询问您要研究的主题,而用户会用一两个字回答该主题。我有以下问题

I'm doing a project where the Google Assistant generates a list of cards about information on research articles. Each card on the list would have the title and URL to the research article. The Google Assistant would ask what subject you wants to research about and the user would reply with the subject matter in one or two words. I have the following questions


  1. 我知道 app.buildList()命令需要别名 key 变量。我可以在代码中将它们归为空白或 null 吗,因为我认为我不需要它们

  1. I understand that the app.buildList() command requires an alias and key variable. Could I level them as blank or null in my code because I don't think I need them

如果用户单击卡中的URL,浏览器会自动打开链接吗?我记得曾经读过Google必须过滤和批准Google助手应用程序中的URL

If the user clicks on the URL in a card, will the browser automatically open the link? I remember reading that Google must filter and approve URLs in Google assistant apps

任何帮助,我们都会感谢

Any help would be appreciated

推荐答案

您可能应该为每个API调用填充相关字段,以便处理各种类型的用户输入。 用于识别正在说的项目。如果显示列表,则需要使用来确定单击了哪个。用户可以单击列表项以将其选中。但是,他们也可以说他们想要的东西。

You should probably populate the relevant fields for each API call in order to handle various types of user inputs. The key is used to identify the item that is being said. If a list is shown, you will need to use the key to identify which is clicked. The user may click on the list item to select it. However, they could also say the thing they want. That is where the aliases are useful.

假设您要获取一系列学术文章。虽然长篇文章可能无法很好地表达自己的声音,但可以将其设计为:

Let's say you were grabbing a list of scholarly articles. While long articles may not lend themselves well to voice, it could be designed like:

function list () {
  const app = new DialogflowApp({request, response});
  app.askWithList('Alright! Here are some articles about memristors! Which do you want?',
  // Build a list
  app.buildList('Memristor Research')
    // Add the first item to the list
    .addItems(app.buildOptionItem('TITLE_OF_FIRST_PAPER',
      ['title of first paper', 'first'])
      .setTitle('Title of First Paper')
      .setDescription('S. Smith, Ph. D')
    // Add the second item to the list
    .addItems(app.buildOptionItem('TITLE_OF_SECOND_PAPER',
      ['title of second paper', 'second'])
      .setTitle('Title of Second Paper')
      .setDescription('H. Paul, Ph. D')
    )
);

}

在此代码段中,如果我说我想第一篇文章,它将使我无需我给出完整标题,而仍然无需动手即可进行交互。 code> key 让我确定应该阅读的文章。

In this snippet, if I say I want the first article, it will give me that one without me having to give the full title while still keeping the interaction hands-free. The key will let me identify the article that should be read.

您可以使用论文标题或链接URL来对其进行处理并出示,并提供包括网址在内的更多信息。

You can use the title of the paper or perhaps the link URL in order to handle it and present a card with more information including the URL.

您不需要手动批准每个URL。该文档指出:

You do not need to have each URL manually approved. The documentation states:



  • 允许链接到开发人员域外的网站。

  • 链接文本不会引起误解。

只要您很简单,用户将可以通过单击卡中的链接直接在浏览器中打开论文。

As long as you are being straightforward about it, users will be able to directly open the paper in a browser by clicking on the link in the card.

更多信息,请参见文档

这篇关于在“ Google上的操作”中构建列表;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆