0

I am attempting to play an audio (a voicemail greeting) uploaded on AWS S3 with twilio-node. When I am testing this feature I am getting this voice response at the end of the call : "An application error has occured..."

I have uploaded the file with nestjs-s3 (in ContentType file.mimetype = 'audio/x-wav') :

 await this.s3
      .putBucketVersioning({
        Bucket: 'abc',
        VersioningConfiguration: {
          MFADelete: 'Disabled',
          Status: 'Enabled',
        },
      })
      .promise()
      .catch(error => {
        console.error(error);
        throw new ServiceUnavailableException(error, error.message);
      });

    // check mimetype audio/*
    if (file.mimetype.indexOf('audio/') === -1) {
      throw new UnsupportedMediaTypeException();
    }
    this.logger.debug(`file.mimetype: ${file.mimetype}`);
    await this.s3
      .upload({
        Bucket: 'abc',
        Key: `voicemail-greetings/${slugify(file.originalname, {
          lower: true,
          locale: 'fr',
        })}`,
        Body: file.buffer,
        CacheControl: 'no-cache',
        ContentType: file.mimetype,
        ACL: 'public-read',
      })
      .promise()
      .catch(error => {
        if (error.code === 'NoSuchBucket') {
          this.logger.warn("Bucket doesnt exist");
          throw new UnprocessableEntityException(error, error.message);
        }
        throw new InternalServerErrorException(error, error.message);
      });

I made the file public readable (ACL: 'public-read')

Here is the audio file file uploaded on my bucket. The file have public access permissions and I can play it correctly in browser.

In twilio console it tells me that it's an Error 11200, HTTP retrieval failure. Also, if I manually upload an other audio file in the same S3 emplacement as the file uploaded with nestjs it work perfectly fine.

Here the code to play the audio with twilio :

const url = `https://abc.s3.eu-west-3.amazonaws.com/voicemailgreetings/${proTarget.proOrganizationId}.wav`;
voiceResponse.play(url);

And this this is the XML response :

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Play>https://abc.s3.eu-west-3.amazonaws.com/voicemail-greetings/18.wav</Play>
    <Record playBeep="true" action="/beta/pro/call/record-end"/>
</Response>
LamsaLL
  • 11
  • 2
  • If the same exact file works when uploaded to another location for Twilio to use, then double check MIME types of the location which doesn’t work and stare and compare the postman response headers between the success and fail locations. – Alan Jul 22 '22 at 13:27

1 Answers1

1

Problem fix !

Actually the problem came from my flutter app that handles the audio recording to upload to the S3. Needed to specify the audio encoder

await _audioRecorder.start(path: filePath, encoder: AudioEncoder.wav);
LamsaLL
  • 11
  • 2