簡體   English   中英

message": "Webhook 調用失敗。 錯誤:不可用,State:URL_UNREACHABLE,原因:UNREACHABLE_5xx,HTTP 狀態代碼:500。”在對話流實現中

[英]message": "Webhook call failed. Error: UNAVAILABLE, State: URL_UNREACHABLE, Reason: UNREACHABLE_5xx, HTTP status code: 500." in dialogflow fulfillment

我正在嘗試使用來自我的 gmail 的對話流意圖發送 email。 但它每次都會拋出相同的錯誤,我無法理解這背后的問題。 從我的代碼中獨立出來的同一件事能夠將電子郵件發送到各種 email 地址。 所以我猜代碼工作得很好。 請看一下我的代碼。

'use strict';
 
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const nodemailer = require("nodemailer");
const admin = require("firebase-admin");
const axios = require("axios");
admin.initializeApp({
 credential:admin.credential.applicationDefault(),
databaseUrl:'ws://***************/'
});
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
 
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
 
  function welcome(agent) {
    agent.add(`Welcome to my agent!`);
  }
 
  function fallback(agent) {
    agent.add(`I didn't understand`);
    agent.add(`I'm sorry, can you try again?`);
  }
function emailSend(){
    const email= agent.parameters.email;
    const name= agent.parameters.name;
    const subject= agent.parameters.subject;
    const message = agent.parameters.message;

}





const nodemailer = require('nodemailer');

var transporter = nodemailer.createTransport({
  service: 'gmail',
  auth: {
    user: '*****@gmail.com',
    pass: '***********'
  }
});

var mailOptions = {
  from: 'Mamuni',
  to: 'email' ,
  subject: 'subject' ,
  text: 'message' 
};

transporter.sendMail(mailOptions, function(error, info){
  if (error) {
    console.log(error);
  } else {
    console.log('Email sent: ' + info.response);
  }
});

let intentMap = new Map();  
intentMap.set('emailSend',emailSend);
 
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
agent.handleRequest(intentMap);
});

該錯誤可能表明您的代碼無法訪問或可能無法通過 HTTPS 端點提供服務。 我建議如下:

  • 代碼是否可通過可公開訪問的端點獲得?
  • 如果以上是肯定的,它是否通過安全通道提供服務,即 HTTPS?

暫無
暫無

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

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