【问题标题】:Firebase webhooksFirebase 网络挂钩
【发布时间】:2019-05-02 06:57:20
【问题描述】:

我已经购买了云功能的火焰计划。我正在使用对话流部署我的 webhook 仍然遇到同样的错误:

错误:getaddrinfo ENOTFOUND jsonplaceholder.typicode.com/ jsonplaceholder.typicode.com/:8080

在 errnoException (dns.js:28:10)

在 GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

'use strict';

var https = require ('https');
const functions = require('firebase-functions');
const DialogFlowApp = require('actions-on-google').DialogFlowApp;



exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, 
response) => {


let action = request.body.queryResult.action;

var chat = "here is a sample response: trump sucks";

response.setHeader('Content-Type','application/json');

if (action!= 'input.getStockPrice'){
  console.log('Inside input function');
 response.send(buildChatResponse("I'm sorry, I don't know this"));
 return;
 }

getStockPrice (response);

});

function getStockPrice (CloudFnResponse) {


 var pathString = "users/2";

 var request = https.get({
    host: "jsonplaceholder.typicode.com/",
    path: pathString,


   }, function (response) {
    var json = "";
    response.on('data', function(chunk) {
        console.log("received JSON response: " + chunk);
        json += chunk;


    });

    response.on('end', function(){
        var jsonData = JSON.parse(json);
        console.log("1");
        var stockPrice = jsonData.name

        console.log ("the stock price received is:" + stockPrice);

        CloudFnResponse.send(buildChatResponse(stockPrice ));

      });

   });

   }

     function buildChatResponse(chat) {
    return JSON.stringify({"fulfillmentText": chat});
    }

【问题讨论】:

    标签: firebase google-cloud-functions dialogflow-es


    【解决方案1】:

    使用完整的 URL,而不是部分 URL。你错过了计划部分。应该是https:

    host: "https://jsonplaceholder.typicode.com/",
    

    【讨论】:

      猜你喜欢
      • 2021-03-22
      • 2015-07-05
      • 2015-10-11
      • 2012-09-26
      • 1970-01-01
      • 1970-01-01
      • 2015-11-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多