在Dialogflow中使用NodeMailer [英] Use NodeMailer in Dialogflow

查看:83
本文介绍了在Dialogflow中使用NodeMailer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想发送电子邮件以执行我在Dialogflow中进行的程序中的操作。

i would like to send an email for an operation in my program i make in Dialogflow.

我想使用NodeMailer,但是在部署项目时出现此错误消息:

I wanna use NodeMailer but when i deploy my project i have this error message:


云功能的部署失败:函数加载错误:
文件index.js中的代码无法已加载。您是否在package.json依赖项中列出了所有必需的
模块?详细的堆栈跟踪:错误:
找不到模块'nodemailer'

The deployment of your Cloud Function failed: Function load error: Code in file index.js can't be loaded. Did you list all required modules in the package.json dependencies? Detailed stack trace: Error: Cannot find module 'nodemailer'

是否可以在DialogFlow中使用NodeMailer?

Is this possible to use NodeMailer in DialogFlow ?

谢谢

推荐答案

听起来您正在使用内置的对话框流程中的实现编辑器。

It sounds like you're using the built-in Fulfillment Editor in Dialogflow.

如果是这样,则使用NodeMailer会有两个问题

If so, you have two issues with using NodeMailer


  1. 您需要将其包含在package.json文件中

  2. 默认情况下,您的代码将在网络访问受限的Firebase Cloud Function中运行。

两者都是可修复的。

但是请记住,您不需要 使用Dialogflow编辑器。欢迎您在任何可公开访问的HTTPS服务器上运行实现。

Remember, however, that you don't need to use the Dialogflow editor. You are welcome to run fulfillment on any publicly accessible HTTPS server.

将NodeMailer添加到package.json

在实现页面的内联编辑器部分中,您将单击标签为 package.json 的选项卡。您会在其中看到一些JSON,其中包括标题为 dependencies的部分。您需要在该部分添加行,以指示需要其他哪些npm模块-在您的情况下为 nodemailer软件包。

On the Fulfillment page, in the Inline Editor section, you'll click on the tab labeled package.json. You'll see some JSON in there, including a section titled "dependencies". You need to add lines to that section indicating what other npm modules are necessary - in your case, the "nodemailer" package.

您的新依赖项部分可能看起来像这样:

Your new "dependencies" section might look something like this:

  "dependencies": {
    "actions-on-google": "^1.5.x",
    "firebase-admin": "^4.2.1",
    "firebase-functions": "^0.5.7",
    "nodemailer": "^4.4.2",
    "apiai": "^4.0.3"
  }

进行测试以确保其正确部署。但是一旦部署,您可能会遇到另一个问题。

Test this out to make sure it deploys correctly. But once it deploys, you'll probably run into another problem.

有限的网络访问权限

对于nodemailer的某些配置,似乎它可能想连接到某处的邮件服务器。 Firebase Cloud Functions的基本级别限制您仅连接到Google网络服务。如果您要连接到Gmail,则可以。但是,如果没有,则需要升级。

For some configurations of nodemailer, it seems likely that it will want to connect to a mail server somewhere. The base level of Firebase Cloud Functions limits you to connect to Google network services only. If you're connecting to GMail - you may be fine. But if not, you'll need to upgrade.

您可以通过转到 Firebase控制台,然后选择要用于Dialogflow的项目,然后升级到Blaze计划。尽管这需要您输入信用卡,并且需要支付使用费,但仍然有一个免费的套餐,足以用于测试和试验。

You can do this by going to the Firebase Console and selecting the same project that you're using for Dialogflow and then upgrading to the Blaze Plan. Although this requires you to enter a credit card, and is subject to usage billing, there is still a free tier that is sufficient for testing and experimentation.

这篇关于在Dialogflow中使用NodeMailer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆