繁体   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