将 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 (将#修改为@)