Skip to main content

Handling Recording Format

Recordings will be sent to your webhooks in the key recording_wav as base64 string buffers. Use Buffer.from to convert the base64 string into a writable buffer, like so:
router.post('/webhook', securityMiddleware, async (req: Request, res: Response) => {
  const payload: WebhookPayload = req.body as WebhookPayload;
  if (payload.type === "call") {
    const data: Call = payload.data as Call;
    if (data.recording_wav) {
      // convert base64 string to a buffer
      const recordingBuffer = Buffer.from(data.recording_wav, "base64");
      const fileName = `RECORDING-${Date.now()}.wav`;

      // write the file locally or upload to cloud
      await fs.writeFile(fileName, recordingBuffer);
      // await uploadFileToS3('recordings', fileName, recordingBuffer);
    }
  }
});

Extra Server Middleware

Make sure to use the express.json({ limit: '1gb' }) middleware on your server to allow incoming large payloads.

Getting an API Key

Get your docs set up locally for easy development

Access your dashboard

Preview your changes before you push to make sure they’re perfect