【发布时间】:2021-05-12 21:38:28
【问题描述】:
我想将我从与 Dialogflow 聊天机器人聊天中获得的用户回复发送到特定电子邮件。这是因为我希望聊天机器人处理用户订单,捕获它们并将它们发送给销售人员。
我对 Dialogflow 还很陌生,所以我对 webhook 和履行不是那么精通。请帮忙:)
【问题讨论】:
标签: dialogflow-es webhooks dialogflow-es-fulfillment
我想将我从与 Dialogflow 聊天机器人聊天中获得的用户回复发送到特定电子邮件。这是因为我希望聊天机器人处理用户订单,捕获它们并将它们发送给销售人员。
我对 Dialogflow 还很陌生,所以我对 webhook 和履行不是那么精通。请帮忙:)
【问题讨论】:
标签: dialogflow-es webhooks dialogflow-es-fulfillment
这里有两件事。
一个网络钩子只不过是一个服务器。您可以查看this 文章并进行设置。
nodemailer 模块发送电子邮件。mail.js
const nodemailer = require('nodemailer');
// create the configuration
const mailConfig = nodemailer.createTransport({
host: "smtpout.secureserver.net",
secure: true,
secureConnection: false, // TLS requires secureConnection to be false
tls: {
ciphers:'SSLv3'
},
requireTLS:true,
port: 465,
debug: true,
auth: {
user: emailUser,
pass: process.env.ADMIN_PASSWORD
}
});
//export the function to send the mail
exports.sendMail= async (myParam ) => {
const emailUser = process.env.ADMIN_EMAIL;
// TODO implement
let mailDetails = {
from: emailUser,
to: myParam.to,
cc: myParam.cc,
subject: myParam.subject,
html: myParam.message,
};
const data = await mailConfig.sendMail(mailDetails);
return data;
};
您可以简单地使用参数导入sendMail 函数,还可以更改其行为,例如aysnc 或synch。
您需要从您的网络挂钩中调用此函数。
【讨论】: