Actions Sdk get this error TypeError: Cannot read property 'output' of undefined
Actions Sdk get this error TypeError: Cannot read property 'output' of undefined
我正在尝试连接 IBM Watson 和 Google Assistant,但我一直收到此错误 "TypeError: Cannot read property 'output' of undefined" 和此 "Function execution took 3323 ms, finished with status: 'crash'"
这是我的代码:
const {actionssdk} = require('actions-on-google');
const functions = require('firebase-functions');
const app = actionssdk({debug: true});
app.intent('actions.intent.MAIN', (conv) => {
conv.ask('Olá, como posso lhe ajudar?');
});
app.intent('actions.intent.TEXT', (conv, input) => {
var AssistantV1 = require('watson-developer-cloud/assistant/v1');
var assistant = new AssistantV1({
username: '###################################',
password: '###################################',
url: '###################################',
version: '2018-07-10'
});
conv.ask("eeeeeeeeeeeeeeeee");
return new Promise( (resolve, reject) => {
assistant.message(
{
workspace_id: '###################################',
input: { text: input },
headers: {'Content-Type':'application/json'}
},
function(err, response) {
conv.ask(response.output.text[0]);
resolve();
}
);
})
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
Rebeca,只是为了添加信息,您正在尝试添加一些出站访问权限,但您需要配置您的帐户才能执行此操作。
"Billing account not configured. External network is not accessible
and quotas are severely limited. Configure billing account to remove
these restrictions"
如果您想打电话给一些 API(IBM Watson,已验证),您需要启用计费。
对于其他配额,take a look here to see prices - 如您所见,使用免费套餐的调用次数有限制。
您的response
对象为空。在使用之前检查它是否不等于 null:
let speech;
if (response !== null) {
speech = response.output.text[0];
}
else{
speech = "I'm sorry, there was an error and I'm unable to answer";
}
conv.ask(speech);
我正在尝试连接 IBM Watson 和 Google Assistant,但我一直收到此错误 "TypeError: Cannot read property 'output' of undefined" 和此 "Function execution took 3323 ms, finished with status: 'crash'"
这是我的代码:
const {actionssdk} = require('actions-on-google');
const functions = require('firebase-functions');
const app = actionssdk({debug: true});
app.intent('actions.intent.MAIN', (conv) => {
conv.ask('Olá, como posso lhe ajudar?');
});
app.intent('actions.intent.TEXT', (conv, input) => {
var AssistantV1 = require('watson-developer-cloud/assistant/v1');
var assistant = new AssistantV1({
username: '###################################',
password: '###################################',
url: '###################################',
version: '2018-07-10'
});
conv.ask("eeeeeeeeeeeeeeeee");
return new Promise( (resolve, reject) => {
assistant.message(
{
workspace_id: '###################################',
input: { text: input },
headers: {'Content-Type':'application/json'}
},
function(err, response) {
conv.ask(response.output.text[0]);
resolve();
}
);
})
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
Rebeca,只是为了添加信息,您正在尝试添加一些出站访问权限,但您需要配置您的帐户才能执行此操作。
"Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions"
如果您想打电话给一些 API(IBM Watson,已验证),您需要启用计费。
对于其他配额,take a look here to see prices - 如您所见,使用免费套餐的调用次数有限制。
您的response
对象为空。在使用之前检查它是否不等于 null:
let speech;
if (response !== null) {
speech = response.output.text[0];
}
else{
speech = "I'm sorry, there was an error and I'm unable to answer";
}
conv.ask(speech);