通过Firebase项目上的节点发送电子邮件

我正在研究一个我已经写在node上的google动作,并且正在部署到firebase,通过在API.AI上定义的intent进行交互。

我想实现一个function,当一个特定的意图被激活时,发送一个电子邮件到一个特定的地址。 我试过使用nodemail和sendmail软件包,但是在部署完它们之后,当正确的意图被调用时,他们似乎不会发送电子邮件。 我不确定是否问题在于我编写了错误(鉴于我的经验不足),或者在Firebase部署中指定这些软件包时存在一些固有的问题。 我已经能够通过简单地从API中返回对API.AI的响应来validation我正在执行sendmail的代码; 如果我能够访问firebase或API.AI日志,我不知道如何。 API.AI显示了一个JSON响应,但就这一点而言,据我所知。

这里有一些简化的代码(只有相关的部分):

 const sendmail = require('sendmail')(); const getSuggestion = app => { const rawInput = app.getRawInput(); sendmail({ from: 'no-reply@yourdomain.com', to: 'myemail@gmail.com', subject: 'test sendmail', html: rawInput, }, function(err, reply) { console.log(err && err.stack); console.dir(reply); return app.ask('You said ' + rawInput + '. Do you have any further input?'); }); }; 

以下是使用Firebase(又名Firebasefunction),nodemailer和Gmail的云端函数的示例: https : //github.com/firebase/functions-samples/tree/master/quickstarts/email-users

当webhook调用失败时,API.AI在API.AI的模拟器中指示206,因为即使webhook调用失败,某些内容也被API.AI通知。 如果您在点击“显示JSON”之后看到206,请检查您的webhook(在这种情况下,Firebase)是否logging到debugging。 以下是一些截图: 在这里输入图像描述

点击“SHOW JSON”创build以下popup窗口:

在这里输入图像描述

206 partial_content Webhook call failed. Error: Webhook response was empty. 206 partial_content Webhook call failed. Error: Webhook response was empty. 表明你的webhook出现了一些错误,无论是500错误还是无法正确格式化的成功响应,或者你错误地input了webhook的HTTPS URL。

Interesting Posts