Twilio功能可将语音邮件或录音发送至电子邮件。

问题描述 投票:0回答:1

Twilio Stuido不提供通过电子邮件发送录音的原生方式,因此需要对其进行编码。在这个例子中,一个用户电话的语音邮件已经被采集。现在我们有了录音,我们创建了一个Twilio函数(NodeJS)来将这个录音发送到电子邮件。

在下面的示例代码中,该函数是失败的,但是在Twilio Console里面没有可用的调试工具来处理函数。NodeJS对我们来说是相当新的,所以这也许很容易被人发现。

然而可能的其他错误可能是。

  1. 不正确的Gmail认证(虽然用户名和密码的细节是正确的,但也许这不是你配置google应用程序发送邮件的方式)。
  2. 无法导入或错误导入nodemailer依赖关系到Twilio。
  3. NodeJS技能不好

输入的变量是

附件 {{widgets.Voicemail_Recording.RecordingUrl}}。 - 其中包含语音邮件录音的URL。

lang - 来电者的语言(根据前面的IVR选择)。

电话号码{{trigger.call.From}}。

NodeJS Twilio函数

var mailer = require('nodemailer');
mailer.SMTP = {
    host: 'smtp.gmail.com', 
    port:587,
    use_authentication: true, 
    user: '[email protected]',
    pass: '*********'
};

exports.handler = function(context, event, callback) {

    mailer.send_mail({       
        sender: event.phone_number + '<[email protected]>',
        to: '[email protected]',
        subject: 'Voicemail (' + event.lang + ')',
        body: 'mail content...',
        attachments: [{'filename': event.attachment, 'content': data}]
    }), function(err, success) {
        if (err) {

        }

    }
};
node.js email twilio nodemailer
1个回答
2
投票

我是来自Twilio支持团队的Sam--我刚刚发布了一篇博客文章,应该可以帮助你解决这个问题。它展示了如何使用Studio、Functions和SendGrid转发语音邮件。点击这里查看。https:/www.twilio.comblogforward-voicemail-recordings-to-email

© www.soinside.com 2019 - 2024. All rights reserved.