[英]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.