我写了一个小js文件,返回公共交通工具的出发。这是我所期望的:
const dvb = require("dvbjs");
dvb.findStop("NUP").then((data) => {
console.log( "Abfahrten für "+data[0].name+ " in " +data[0].city+":" );
dvb.monitor(data[0].id, 0, 1).then((data) => {
for (const bus of data){
console.log(bus.mode.title +" "+ bus.line+" Richtung "+bus.direction+ " in "+bus.arrivalTimeRelative+ " Minuten.")
}
});
});
我的控制台上的输出如下所示:
Abfahrten für Nürnberger Platz in Dresden:
Straßenbahn 8 Richtung Hellerau in 3 Minuten.
这可以。现在我改变了它,所以 Google Assistant 可以读取输出:
app.intent('Haltestellenabfrage', (conv, {haltestelle}) => {
//conv.ask("Debug 1");
dvb.findStop("NUP").then((data) => {
//conv.ask("Debug 2");
conv.ask( "Abfahrten für "+data[0].name+ " in " +data[0].city+":" );
dvb.monitor(data[0].id, 0, 1).then((data) => {
for (const bus of data){
//conv.ask("Debug 3");
conv.close(bus.mode.title +" "+ bus.line+" Richtung "+bus.direction+ " in "+bus.arrivalTimeRelative+ " Minuten.");
}
});
});
//conv.ask("Debug 3");
});
当我在模拟器中启动我的 Action on Google 时,我收到以下错误并且没有响应:
{
"responseMetadata": {
"status": {
"code": 10,
"message": "Failed to parse Dialogflow response into AppResponse because of empty speech response",
"details": [
{
"@type": "type.googleapis.com/google.protobuf.Value",
"value": "{\"id\":\"bad774a2-9e35-4ced-980f-d4e75d710727\",\"timestamp\":\"2019-03-13T11:50:56.405Z\",\"lang\":\"de\",\"result\":{},\"alternateResult\":{},\"status\":{\"code\":206,\"errorType\":\"partial_content\",\"errorDetails\":\"Webhook call failed. Error: 500 Internal Server Error\"},\"sessionId\":\"ABwppHHpg1lcJFHtSSM8Pmg4gWWkjgICLeZhBuwFb_UJTXuvVyVc5jE5QWLIpGYRCQOHAVmHTzunZw\"}"
}
]
}
}
}
无论我做什么,Dialogflow 都不会执行 .then() 子句中的部分。我是 javascript 的绝对初学者,所以我不知道还能尝试什么。