Google cloud platform 如何在Google Actions NLP(Google assistant)控制台中将随机输入值作为插槽变量?

Google cloud platform 如何在Google Actions NLP(Google assistant)控制台中将随机输入值作为插槽变量?,google-cloud-platform,nlp,actions-on-google,nlu,Google Cloud Platform,Nlp,Actions On Google,Nlu,比如说,我有一个应用程序,我想给某人一个城市的天气 第一个场景有一个提示:“你喜欢哪个城市的天气?” 然后,我必须收集一个名为conv.param.city:的插槽/参数,然后在我的节点webhook中使用它,即: const { conversation } = require('@assistant/conversation'); const functions = require('firebase-functions'); const app = conversation(); app

比如说,我有一个应用程序,我想给某人一个城市的天气

第一个场景有一个提示:“你喜欢哪个城市的天气?”

然后,我必须收集一个名为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);

据我所知,您只能接受由类型/意图预定义的参数/插槽。我无法列出所有可供训练的城市。基本上,我怎么说:无论用户在这一点上说什么,都要把这个词放到这个变量中


如何使用Google Actions SDK实现这一点?

您可以通过将意图参数类型设置为自由文本来实现这一点(以下是一个示例repo中的示例)

如果将此类型应用于意图参数,则可以使用培训短语提供短语中“word”应在何处匹配(来自同一repo)的必要上下文

我无法列出所有可供训练的城市

如果API可以返回支持的位置集,则存在另一个选项。您还可以使用从API提供的位置列表中动态生成类型。这将更加准确,但取决于数据源的外观

freeText: {}