簡體   English   中英

DialogFlow Webhook:錯誤:EROFS:只讀文件系統,打開“ .node-xmlhttprequest-sync-2”

[英]DialogFlow Webhook : Error: EROFS: read-only file system, open '.node-xmlhttprequest-sync-2'

我正在創建DialogFlow應用程序,並通過使用XMLHttpRequest的Cloud Functions for Firebase部署了實現。 但是發生以下錯誤。

錯誤:EROFS:只讀文件系統,在Object.fs.writeFileSync(fs.fs.openSync(fs.js:642:18),錯誤(native),在錯誤(本機)打開'.node-xmlhttprequest-sync-2'。 js:1348:33)發送(/user_code/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:477:10)

我的代碼是這樣的。

'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);
});

有誰知道如何解決這個錯誤?

您的函數testHttpRequest需要使用app來響應Dialogflow用戶的請求。 使用asktell方法來響應請求。 例如,在testHttpRequest的if語句之后,您可以添加:

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

當您從Google模擬器上的Action或Google Assistant設備上調用Assistant應用時,它會告訴Google客戶端庫上的Action發送字符串作為對您請求的響應(請參閱Google測試文檔上的Action)。

您可能還會遇到動作名稱問題。 您在實現中引用的操作( deeplink.unknowntest.httprequest )也必須作為Dialogflow代理中的意圖操作列出,否則將永遠不會觸發您的代碼。 Google助手還需要一個歡迎的意圖。 默認情況下,在Dialogflow歡迎有意向的動作input.welcome這是不是在你的代碼中包含了,直到你匹配你的代碼,並在您Dialogflow劑中的動作,你的代碼可能無法觸發。

此外, 在未先設置結算功能的情況下,不允許在Cloud Functions上進行外部HTTP調用(在Google網絡外部)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM