Im using TwiML to get the recipients feedback from a phone survey, the survey is pre recorded and sent out as an audio file in the gather request, altough if the recipient speaks, the playback gets cut off and the purpose of the exercise is lost , since the recipient can not listen to the complete survey, in my test people answers with "Hello" so the playback gets cut right at the beginning , this is my code
const fromPhoneNumber = '+52xxxxxxxx';
const audioUrl = 'url';
const VoiceResponse = require('twilio').twiml.VoiceResponse;
// Create a webhook endpoint to receive the user's response
const webhookEndpoint = 'https://hook.us1.make.com/8w93jvblq7kel319zvtdkqbqv8mgbwu5';
// Read the list of phone numbers from a JSON file
const phoneNumberList = JSON.parse(fs.readFileSync('call.json', 'utf8')).map(item => item.TEL);
// Function to initiate calls
const makeCalls = async () => {
let callCount = 0;
// Iterate through the phone number list
for (const phoneNumber of phoneNumberList) {
if (callCount >= 40) {
// Pause for 1 minute after making 40 calls
await new Promise(resolve => setTimeout(resolve, 60000));
callCount = 0;
}
// Create a response object and gather user input
const response = new VoiceResponse();
const gather = response.gather({
input: 'speech',
language: 'es-MX',
action: webhookEndpoint,
speechTimeout: 10, // Set the gathering timeout to 10 seconds
method: 'POST' // Specify the method for the webhook
});
gather.play(audioUrl);
const twiml = response.toString();
// Initiate the call
await client.calls.create({
twiml: twiml,
from: fromPhoneNumber,
to: `+52${phoneNumber}`,
record: true,
language: 'es-MX',
transcribe: true
})
.then(call => {
console.log('Call initiated:', call.sid);
callCount++;
})
.catch(error => {
console.error('Failed to make the call:', error);
});
}
};
// Call the function to start making the calls
makeCalls()
.then(() => console.log('All calls completed.'))
.catch(error => console.error('An error occurred:', error));
Thanks in advance
I tried severa timeout parameters like speechTimeout with no luck, how can I make the gather command starts at 16 seconds right when the audioplayback has finished, or after the beep