如何使用 Dialoflow 发送电子邮件以进行 Google 操作

How do I send an email with Dialoflow for Google actions

我四处寻找解决方案来解决 运行 发送电子邮件但找不到任何解决方案的意图。有人可以帮忙吗?

您可以在 dialogflow webhook fulfillment intent 中使用 nodemailer 来发送电子邮件。

确保启用安全性较低的应用程序 here 以使用 gmail 发送电子邮件。

根据您的意图使用 nodemailer 发送电子邮件的代码:

app.intent('sendMail', (conv, params) => {

      const nodemailer = require('nodemailer');
      const transporter = nodemailer.createTransport({
        service: 'gmail',
        auth: {
          user: 'youremail@gmail.com',
          pass: 'yourPassword'
        }
      });

      var mailOptions = {
        from: 'youremail@gmail.com',
        to: email, //receiver email 
        subject: 'Mail subject',
        text: 'mail body'
      };

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

});

如果您使用的是内联编辑器,请按照 寻求帮助。

希望对您有所帮助!

没有特定的 API 从操作或通过 Dialogflow 发送电子邮件。

但是,如果您的 Intent 已启用 fulfillment,您可以从 webhook 中的该 Intent 处理程序调用任何 API 或库。