2017-11-25 2 views
2

Ich erstelle DialogFlow App und implementierte Fulfillment mit Cloud-Funktionen für Firebase, die XMLHttpRequest verwendet. Aber folgender Fehler ist aufgetreten.DialogFlow Webhook: Fehler: EROFS: schreibgeschütztes Dateisystem, öffnen '.node-xmlhttprequest-sync-2'

Error: EROFS: read-only file system, open '.node-xmlhttprequest-sync-2' at Error (native) at Object.fs.openSync (fs.js:642:18) at Object.fs.writeFileSync (fs.js:1348:33) at send (/user_code/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:477:10)

Mein Code ist so etwas.

'use strict'; 

const admin = require('firebase-admin'); 
const functions = require('firebase-functions'); 

const DialogflowApp = require('actions-on-google').DialogflowApp; 
const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; 
const googleAssistantRequest = 'google'; 

const Actions = { 
    UNRECOGNIZED_DEEP_LINK: 'deeplink.unknown', 
    TEST_HTTPREQUEST: 'test.httprequest' 
}; 

const testHttpRequest = app => { 
    var req = new XMLHttpRequest(); 
    req.open('GET', 'http://www.google.com', false); 
    req.send(); 
    if (req.status === 200) { 
     console.log(req.responseText); 
    } 
} 

const actionMap = new Map(); 
actionMap.set(Actions.TEST_HTTPREQUEST, testHttpRequest); 

exports.mytestapp = functions.https.onRequest((request, response) => { 
    const app = new DialogflowApp({ request, response }); 
    console.log(`Request headers: ${JSON.stringify(request.headers)}`); 
    console.log(`Request body: ${JSON.stringify(request.body)}`); 
    app.handleRequest(actionMap); 
}); 

Hat jemand eine Idee, wie man diesen Fehler löst?

Antwort

0

Ihre Funktion muss app verwenden, um auf die Benutzeranfrage von Dialogflow zu antworten. Verwenden Sie die Methoden ask oder tell, um auf die Anforderung zu antworten. Zum Beispiel nach dem if-Anweisung in testHttpRequest könnte man hinzufügen:

app.tell('This response came from Cloud Functions for Firebase!'); 

, die die Aktion auf Google-Client-Bibliothek erzählt die Zeichenfolge als eine Antwort auf Ihre Anfrage zu senden, wenn Sie Ihren Assistenten App aus dem Action auf Google Simulator aufrufen oder Google Assistant-Gerät (siehe Aktion in Google-Testdokumenten).

Möglicherweise tritt auch ein Problem mit Aktionsnamen auf. Die Aktion, auf die Sie sich hier beziehen (deeplink.unknown und test.httprequest), muss auch als an action in an intent in your Dialogflow agent aufgeführt sein, andernfalls wird Ihr Code niemals ausgelöst. Der Google Assistant erfordert auch eine Willkommensabsicht. Standardmäßig hat die Willkommensabsicht in Dialogflow eine Aktion von input.welcome, die nicht in Ihrem Code enthalten ist. Daher wird der Code möglicherweise erst ausgelöst, wenn Sie die in Ihrem Code und in Ihrem Dialogflow-Agenten aufgeführten Aktionen abgleichen.

Außerdem externe HTTP-Anrufe (außerhalb des Google-Netzwerks) are not permitted on Cloud Functions without setting up billing first.

Verwandte Themen