dialogflow-es - 想要保留持久值
问题描述
我们希望保留持久的价值观。我们使用以下简单代码进行了尝试,但没有保留该值。我们犯了什么错误?
index.js
'use strict';
const functions = require('firebase-functions');
const { dialogflow } = require('actions-on-google');
const app = dialogflow();
app.intent('FirstIntent', conv => {
conv.user.storage.value = 'A';
conv.followup('SecondEvent');
});
app.intent('SecondIntent', conv => {
conv.close('value is ' + conv.user.storage.value);
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
包.json
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.6.1"
}
}
FirstIntent 在启动时被调用。将持久值保存在 FirstIntent 中并引发 SecondEvent。调用 SecondIntent。读取 SecondIntent 中的持久值以创建响应。显示“值未定义”。
我们找到了以下日志。
Billing account not configured.
External network is not accessible and quotas are severely limited.
Configure billing account to remove these restrictions
我们升级到flame,确认日志没有显示,但是持久值还没有保存。不收费能解决这个问题吗?
解决方案
这种行为(即设置为 的值user.storage
不是通过followup()
函数传递的)是 actions-on-google-nodejs SDK 的规范。
实际上,这不仅是 SDK 的规范,也是由于该user.storage
功能与该功能使用的 Dialogflow 后续事件功能不兼容造成的followup()
。调用该followup()
函数时,“followupEventInput”响应从履行返回到 Dialogflow。收到响应后,Dialogflow 会决定一个可以处理指定事件的 Intent 并直接触发 Intent,而不向 Actions on Google 返回任何响应。这user.storage
是 Actions on Google 的一项功能,因此,Dialogflow 必须将新值返回到 Actions on Google 以更新user.storage
值,以便 Actions on Google 将新值发送到下一个请求。但是,Dialogflow 在调用followup()
. 结果,即使将值设置为user.storage
,不幸的是这些值也会被忽略。
相反,SDK 可以临时存储新user.storage
值,以便在下一个 webhook 处将这些值返回给 Actions on Google。但是,后续事件触发的意图并不总是调用 webhook。因此,这个想法不能涵盖所有情况。经过讨论,目前的 SDK 不支持这种想法。
该规范在以下 API 参考中进行了描述。
此外,您可以在以下位置阅读有关决定此规范的讨论:
https://github.com/actions-on-google/actions-on-google-nodejs/pull/211#issuecomment-412942410
推荐阅读
- jupyter-notebook - 为什么我的光标在 Jupyter Notebook 中偏移?
- node.js - 循环 json 数据并将项目添加到 DynamoDB
- python - CUDA 在推理过程中内存不足并给出 InternalError: CUDA 运行时隐式初始化 GPU:0 失败。状态:内存不足
- python - 使用python翻译Excel工作表
- algorithm - 编写一个 O(n) 算法,使用上述扩展来计算 n ≥ 1 的任意值的 sin(x),x 类型为 float
- mongodb - Mongoose / MongoDB 聚合查询深度填充
- php - 如果帖子由 Wordpress 中的作者用户角色撰写,则显示文本
- javascript - 制作需要帮助 - 会员只能在票务频道中使用命令
- python - 如何遍历python中的目录树以及扩展名为.py或.txt的文件将它们添加到zipfile中。?
- clojure - 如何重命名 clojure 文件和命名空间