简体   繁体   English

如何将随机输入值作为 Google Actions NLP(谷歌助手)控制台中的插槽变量?

[英]How can I take a random input value as a slot variable in Google Actions NLP (google assistant) Console?

Let say I have an app where I want to give someone the weather in a city.假设我有一个应用程序,我想在其中向某人提供某个城市的天气。

The first scene has a prompt: "What city would you like the weather of?"第一个场景有一个提示:“你喜欢哪个城市的天气?”

I then have to collect a slot/parameter called conv.param.city: and then use it in my node webhook which is:然后我必须收集一个名为 conv.param.city: 的槽/参数,然后在我的节点 webhook 中使用它,它是:

const { conversation } = require('@assistant/conversation');
const functions = require('firebase-functions');
const app = conversation();

app.handle('schedule', (conv, {location}) => {  
  let temperature = callApi(location);// this part doesn't matter right now

  **conv.add(`You want to know the weather in ${location}`);
  conv.close(`The weather in ${location} is ${temperature}`);
});

exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app);

From what I can tell, you can only take in parameters/slots that are predefined by types/intents.据我所知,您只能接受由类型/意图预定义的参数/插槽。 I cannot make a list of all cities that exist to train with.我无法列出所有可供训练的城市。 How can I basically say: Whatever the user says at this point, make that word into this variable.我该怎么说:无论用户在这一点上说什么,都将这个词放入这个变量中。

How can i do this with the Google Actions SDK?如何使用 Google Actions SDK 执行此操作?

You can accomplish this by setting your intent parameter type to be free text (here's an example from one of the sample repos).您可以通过设置你的意图参数类型为自由文本(这里是一个完成这个例子从样品回购之一)。

freeText: {}

If you apply this type to an intent parameter, you can use the training phrases to provide the necessary context on where in the phrase that "word" should be matched ( example from the same repo).如果将此类型应用于意图参数,则可以使用训练短语提供有关“单词”应在短语中匹配的位置的必要上下文(来自同一存储库的示例)。

I cannot make a list of all cities that exist to train with.我无法列出所有可供训练的城市。

Another option exists if your API can return the set of locations supported.如果您的 API 可以返回支持的位置集,则存在另一个选项。 You can also use runtime type overrides to dynamically generate the type from the list of list of locations the API provides.您还可以使用运行时类型覆盖从 API 提供的位置列表列表中动态生成类型。 This will be more accurate, but is dependent on what your data source looks like.这会更准确,但取决于您的数据源是什么样的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 Google Assistant 深度链接应用程序? - how can I deeplink an app from Google Assistant? 如何在没有对话流程的情况下使用Google助手 - How to use Google assistant without dialog flow 如何从 Google Chrome 扩展程序调用 Google NLP Api - How to call Google NLP Api from a Google Chrome extension Dialogflow 禁用 Google 助理 - Dialogflow disable Google Assistant GCP:如何备份安装到文件存储的实例,或者基本上我想备份谷歌云平台中的文件存储 - GCP: How can I take backup of an instance that is mount to the file store or basically I want to take a backup of file store in google cloud platform 即使我没有更改示例项目中的任何内容,使用 Google Actions 控制台也会出现错误 - Using the Google Actions console gives me an error, even if I didn't change anything in the sample project 如何设置环境变量GOOGLE_APPLICATION_CREDENTIALS? - How can i set the environment variable GOOGLE_APPLICATION_CREDENTIALS? 我如何将变量传递给谷歌云函数 - How can i pass variable to a google cloud function 作为 Google NLP 中的人的一部分,我如何训练说泰米尔人姓名(泰米尔人种族) - How do I train say Tamil names (Tamil ethnicity) as part of Person in Google NLP 如何从Google Cloud pubsub中获取数据到Firebase实时数据库 - How can I take data from google cloud pubsub to firebase realtime data base
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM