Twilio 录音和语音信箱功能 [英] Twilio recording and voicemail function

查看:30
本文介绍了Twilio 录音和语音信箱功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在为我的 twilio 号码实施一个新的呼叫转发 ivr 系统,但我的一个功能出现问题,我希望你们能以某种方式提供帮助.

Hello guys im treyng to implement a new call foward ivr system for my twilio number but i been having a problem with one of my function and i hope you guys cam help in some way.

所以我试图记录我收到的所有电话,此外还有一个语音邮件选项.这是我的方式.

So Im trying to record all the calls that i receive and on top of that have a voicemail option. Here is how im going.

在 twiml 上,我创建了一个操作,以便在超时后转到 reddirect 到语音邮件,而不是我使用 RecordingStatusCallback 来录制不转到语音邮件的呼叫,并且两者都可以完美运行,但是当我从在 RecordingStatusCallback 上执行的函数中收到记录时电子邮件没有显示 callFrom 和 Callto(回来并没有定义),我做了我的研究,发现 thar recordingStatusCallback 参数结果没有 callFrom 和 callTo 参数.我想知道是否有一种方法可以从我接到电话时临时存储该结果,以便我在电子邮件中保存或从其他功能获取结果.请参阅下面的部分代码.这是 twiml 拨号和号码参数.

On twiml i crate an action to go to reddirect to voicemail after time out, Than i use recordingStatusCallback to record the call tha dont go to voicemail and both work perfectly but when i receive the record from the function that i execute on recordingStatusCallback the email doesnt show the callFrom and Callto (come back ans undefined) and i did my research anf find out thar recordingStatusCallback parameter results dont have the callFrom and callTo parameters. Im wondering if is a way to store that result temporarlly from when i receive the call so i have on my email or get the results from other functions. Please see part of the code below. This is the twiml dial and number parameters.

const dial = twiml.dial({
timeout: 20,
method: 'GET',
action: 'voicemail',
record: 'record-from-answer',
recordingStatusCallback: 'recording',
callerId: context.TWILIO_PHONE_NUMBER,
});

dial.number({url: 'whisper',}, context.MY_PHONE_NUMBER);

dial.number({url: 'whisper',}, context.MY_PHONE_NUMBER);

这是发送录制对话的副本的功能.

This is the sfunction to send a copu of the recorded conversation.

        //Initialize SendGrid Mail Client
const sgMail = require('@sendgrid/mail');

// Define Handler function required for all Twilio Functions
exports.handler = function(context, event, callback) {

// Build SG mail request
sgMail.setApiKey(context.SENDGRID_API_SECRET);
// Define message params
const msg = {
to: context.TO_EMAIL_ADDRESS,
from: context.FROM_EMAIL_ADDRESS,
subject: 'New Call Received',

      html: `Hi ${context.LEADGEN_NAME},<br> 
      <p><strong>This is a friendly notification that you received the follwing call:</strong></p>
      <p><strong>Call From (Client): </strong></p>${event.Caller}<br>
      <p><strong>Call to: </strong></p>${event.To}<br>
      <p>You are receiving this email because you are subscribed to email alerts for ${context.LEADGEN_NAME} tracking numbers.</p>
      <p>Thanks, </p>
      <p><strong>Recorded link </strong></p>${event.RecordingUrl}<br>
      <p><strong>Fuel Marketing Solutions </strong></p>`,
   };
    // Send message
    sgMail.send(msg)
    .then(response => {
        console.log("Neat.")
        callback();
    })
    .catch(err => {
        console.log("Not neat.")
        callback(err);
    });

推荐答案

您可以通过在 loggingStatusCallback url 中添加参数来解决此问题.

You can fix this by adding parameters in the recordingStatusCallback url.

let actionUrl = `https://${DOMAIN_NAME}/${URL_PATH}?callTo=${callTo}&callFrom=${callFrom}`;

const dial = twiml.dial({
timeout: 20,
method: 'GET',
action: 'voicemail',
record: 'record-from-answer',
recordingStatusCallback: actionUrl,
callerId: context.TWILIO_PHONE_NUMBER,
});

这篇关于Twilio 录音和语音信箱功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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