【发布时间】:2019-07-08 16:12:18
【问题描述】:
我找到了一个属性 record-on-answer,我正在尝试将其集成到我的 twiml 响应中,但它不起作用。我试图只记录用户回答的时间。 就像我当前的录音有 5 秒的“您的电话无法转接”一样。然后记录了5秒的沉默。然后是实际连接时的呼叫,时间为 26 秒并正确记录。我只想要第三次录音的 26 秒。如果我用普通电话打电话,我永远不会听到“您的电话无法转移”。
我将如何实现这一目标?
这是我的代码:然后是请求正文。如果 twilio 的任何人可以帮助解决这个编码问题,我将非常感激,因为我非常沮丧。我尝试过启用双声道和单声道录制。 敲击键盘
function callUA(twilNum, uaNum){
console.log('in call ua')
client.calls.create({
url: 'http://www.REMOVED.com/sendT',
to: '+1'+uaNum,
from: '+1'+twilNum,
method: 'POST',
status_callback_method: 'POST',
status_callback: 'https://www.REMOVED.com/tS'
})
}//end callua
app.post('/sendT', urlencodedParser, function (req, res) {
console.log(req.body);
var rt = new VoiceResponse();
rt.record({
recordingChannels: 'dual',
recordOnAnswer: true,
transcribe: true,
transcribeCallback: 'http://www.autosecurelogin.com/rT'
});
rt.hangup();
res.status(200);
res.send(rt.toString());
console.log(' finish sendt')
})//end post
app.post('/rT', urlencodedParser, function (req, res) {
console.log('made to receiveT post');
console.log(req.body);
var ttemp = req['body'].TranscriptionText;
var rightNow = Date.now();
console.log('transcription text ' + ttemp);
var masterFile = __dirname + "/master/transcriptions/"+rightNow+".json";
fs.writeFile(masterFile, ttemp, function (err) {
})//
res.status(200);
res.send();
console.log('Transcribe Finish');
});
app.post('/tS', urlencodedParser, function (req, res) {
console.log('req');
var ttemp = req['body'];
res.status(200);
res.send();
console.log('in call back tS');
});
in call ua
{ Called: 'REMOVED',
ToState: 'CO',
CallerCountry: 'US',
Direction: 'outbound-api',
CallerState: 'CO',
ToZip: '80265',
CallSid: 'REMOVED',
To: '+REMOVED',
CallerZip: '',
ToCountry: 'US',
ApiVersion: '2010-04-01',
CalledZip: '80265',
CalledCity: 'DENVER',
CallStatus: 'in-progress',
From: 'REMOVED',
AccountSid: 'REMOVED',
CalledCountry: 'US',
CallerCity: '',
Caller: '+17205752321',
FromCountry: 'US',
ToCity: 'DENVER',
FromCity: '',
CalledState: 'CO',
FromZip: '',
FromState: 'CO' }
finish sendt
in call ua
{ Called: '+REMOVED',
ToState: 'CO',
CallerCountry: 'US',
Direction: 'outbound-api',
CallerState: 'CO',
ToZip: '80265',
CallSid: 'REMOVED',
To: '+REMOVED',
CallerZip: '',
ToCountry: 'US',
ApiVersion: '2010-04-01',
CalledZip: '80265',
CalledCity: 'DENVER',
CallStatus: 'in-progress',
From: '+REMOVED',
AccountSid: 'REMOVED',
CalledCountry: 'US',
CallerCity: '',
Caller: '+REMOVED',
FromCountry: 'US',
ToCity: 'DENVER',
FromCity: '',
CalledState: 'CO',
FromZip: '',
FromState: 'CO' }
finish sendt
{ Called: '+REMOVED',
RecordingUrl: 'https://api.twilio.com/2010-04-01/Accounts/REMOVED/Recordings/REMOVED',
ToState: 'CO',
CallerCountry: 'US',
Direction: 'outbound-api',
CallerState: 'CO',
ToZip: '80265',
CallSid: 'REMOVED',
To: '+REMOVED',
CallerZip: '',
ToCountry: 'US',
ApiVersion: '2010-04-01',
CalledZip: '80265',
CalledCity: 'DENVER',
CallStatus: 'in-progress',
RecordingSid: 'REMOVED',
From: '+REMOVED',
AccountSid: 'REMOVED',
CalledCountry: 'US',
CallerCity: '',
Caller: '+REMOVED',
FromCountry: 'US',
ToCity: 'DENVER',
FromCity: '',
CalledState: 'CO',
FromZip: '',
FromState: 'CO',
RecordingDuration: '31' }
finish sendt
{ Called: '+REMOVED',
RecordingUrl: 'https://api.twilio.com/2010-04-01/Accounts/REMOVED/Recordings/REMOVED',
ToState: 'CO',
CallerCountry: 'US',
Direction: 'outbound-api',
CallerState: 'CO',
ToZip: '80265',
CallSid: 'REMOVED',
To: '+REMOVED',
CallerZip: '',
ToCountry: 'US',
ApiVersion: '2010-04-01',
CalledZip: '80265',
CalledCity: 'DENVER',
CallStatus: 'in-progress',
RecordingSid: 'REMOVED',
From: '+REMOVED',
AccountSid: 'REMOVED',
CalledCountry: 'US',
CallerCity: '',
Caller: '+REMOVED',
FromCountry: 'US',
ToCity: 'DENVER',
FromCity: '',
CalledState: 'CO',
FromZip: '',
FromState: 'CO',
RecordingDuration: '5' }
finish sendt
made to receiveT post
{ ApiVersion: '2010-04-01',
TranscriptionType: 'fast',
TranscriptionUrl: 'https://api.twilio.com/2010-04-01/Accounts/REMOVED/Recordings/REMOVED/Transcriptions/REMOVED',
TranscriptionSid: 'REMOVED',
Called: '+REMOVED',
RecordingSid: 'REMOVED',
CallStatus: 'in-progress',
RecordingUrl: 'https://api.twilio.com/2010-04-01/Accounts/REMOVED/Recordings/REMOVED',
From: '+REMOVED',
Direction: 'outbound-api',
url: 'http://www.REMOVED.com/rT',
AccountSid: 'REMOVED',
TranscriptionText: '',
Caller: '+REMOVED',
TranscriptionStatus: 'completed',
CallSid: 'REMOVED',
To: '+REMOVED' }
transcription text
Transcribe Finish
{ Called: '+REMOVED',
Digits: 'hangup',
RecordingUrl: 'https://api.twilio.com/2010-04-01/Accounts/REMOVED/Recordings/REMOVED',
ToState: 'CO',
CallerCountry: 'US',
Direction: 'outbound-api',
CallerState: 'CO',
ToZip: '80265',
CallSid: 'REMOVED',
To: '+REMOVED',
CallerZip: '',
ToCountry: 'US',
ApiVersion: '2010-04-01',
CalledZip: '80265',
CalledCity: 'DENVER',
CallStatus: 'completed',
RecordingSid: 'REMOVED',
From: '+REMOVED',
AccountSid: 'REMOVED',
CalledCountry: 'US',
CallerCity: '',
Caller: '+REMOVED',
FromCountry: 'US',
ToCity: 'DENVER',
FromCity: '',
CalledState: 'CO',
FromZip: '',
FromState: 'CO',
RecordingDuration: '5' }
finish sendt
made to receiveT post
{ ApiVersion: '2010-04-01',
TranscriptionType: 'fast',
TranscriptionUrl: 'https://api.twilio.com/2010-04-01/Accounts/REMOVED/Recordings/REMOVED/Transcriptions/REMOVED',
TranscriptionSid: 'REMOVED',
Called: '+17202147065',
RecordingSid: 'REMOVED',
CallStatus: 'completed',
RecordingUrl: 'https://api.twilio.com/2010-04-01/Accounts/REMOVED/Recordings/REMOVED',
From: '+17205752321',
Direction: 'outbound-api',
url: 'http://www.REMOVED.com/rT',
AccountSid: 'ACcf28aac96af5890681f35809fb0b62eb',
TranscriptionText: 'Today is Thursday June 27th and the colors of the day are Aqua Baracuda beige and blue confetti the litter Gray Line the melon Onyx are Ange red. And very day thank you.',
Caller: '+REMOVED',
TranscriptionStatus: 'completed',
CallSid: 'REMOVED',
To: '+REMOVED' }
transcription text Today is Thursday June 27th and the colors of the day are Aqua Baracuda beige and blue confetti the litter Gray Line the melon Onyx are Ange red. And very day thank you.
Transcribe Finish
made to receiveT post
{ ApiVersion: '2010-04-01',
TranscriptionType: 'fast',
TranscriptionUrl: 'https://api.twilio.com/2010-04-01/Accounts/REMOVED/Recordings/REMOVED/Transcriptions/REMOVED',
TranscriptionSid: 'REMOVED',
Called: '+REMOVED',
RecordingSid: 'REMOVED',
CallStatus: 'completed',
RecordingUrl: 'https://api.twilio.com/2010-04-01/Accounts/REMOVED/Recordings/REMOVED',
From: '+REMOVED',
Direction: 'outbound-api',
url: 'http://www.REMOVED.com/rT',
AccountSid: 'REMOVED',
TranscriptionText: 'Your call cannot be transferred please try again later thank you.',
Caller: '+17205752321',
TranscriptionStatus: 'completed',
CallSid: 'REMOVED',
To: '+REMOVED' }
transcription text Your call cannot be transferred please try again later thank you.
Transcribe Finish
【问题讨论】: