Following this Dialogflow integration[1] with Twilio.
There is a server that receives the incoming webhook from Twilio. You’ll have to add the const `numMedia` and send the message.
Once you know how much media has been sent, you can access them in parameter `MediaUrl{N}` where N is an integer. The media is delivered as a URL, so you’ll need to download it.
The `server.js` file would look like this:
app.post('/', async function(req, res) {
const body = req.body;
const text = body.Body;
const id = body.From;
const numMedia = parseInt(body.NumMedia, 10);
if (numMedia > 0) {
for (let i = 0; i < numMedia; i++) {
console.log(body[`MediaUrl${i}`]);
}
}
const dialogflowResponse = (await sessionClient.detectIntent(
text, id, body)).fulfillmentText;
const twiml = new MessagingResponse();
const message = twiml.message(dialogflowResponse);
res.send(twiml.toString());
});
To deal with the audio in Dialogflow, you can use Auto Speech Adaptation[2].