如何解决将 google chat 与 dialogflow 集成到电子邮件中
我正在尝试创建一个可以执行此操作的谷歌聊天机器人
@mail_bot any_message abc.gmail.com
这应该会向 abc.gmail.com 的收件箱发送一封包含消息的电子邮件。
我在 dialogflow 中有以下实现代码,它接受参数但不发送电子邮件。可以请一些人帮忙吗。
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card,Suggestion} = require('dialogflow-fulfillment');
const nodemailer = require("nodemailer");
const transporter = nodemailer.createTransport({
service: 'Gmail',auth: {
user: 'yyy@gmail.com',pass: '12345'
}
});
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 sendEmailBot(agent){
const {email,message} = agent.parameters;
transporter.sendMail({
from: "Carry",// sender address
to: email,// receiver
subject: "VBot",// Subject line
text: message},function (err,info) {
if(err)
{
console.log(err);
}
});
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent',welcome);
intentMap.set('Default Fallback Intent',fallback);
intentMap.set('Vmail',sendEmailBot);
agent.handleRequest(intentMap);
});
我得到的错误如下 -
错误:没有为平台定义响应:DIALOGFLOW_CONSOLE 在 WebhookClient.send ...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。