I'm trying to programmatically receive and download MMS images/videos from Twlio using a webhook in Zapier
I would like to download images and place them in Google Drive
I’m building a chatbot in Voiceflow to be deployed using Twilio
Everything works except downloading the image and video
I’m using ChatGPT to help with the code but I keep getting errors
Here is the code ChatGPT gave me:
// Input Data from previous step
const mediaUrl = inputData.MediaUrl0; // Assuming MediaUrl0 is the field name for the media URL from Twilio's POST request
// Function to download image from Twilio
async function downloadImage(url) {
const response = await fetch(url);
const buffer = await response.arrayBuffer();
const base64Image = Buffer.from(buffer).toString('base64');
return base64Image;
}
// Call the function to download image
downloadImage(mediaUrl)
.then(base64Image => {
callback(null, {base64Image});
})
.catch(error => {
callback(error);
});
Any help from someone more experienced would be great!