Search code examples
twiliourl-parametersrecording

twilio recordingStatusCallback is not sending parameters to url


I want to send a number with recordingStatusCallback url. But, when I receive the log of the parameters in web-hook url, I don't see the parameter I passed in the URL. I was parsing the parameters as url-endcoded format. Below code, I am sending chunkStartNumber=18 in url,but there is no trace of chunkStartNumber in log below

   var recLenDivided=18;
   let twiml = new Twilio.twiml.VoiceResponse();
    twiml.record({
        action:`https://xyz`,
        method: 'GET',
        finishOnKey: '5',
        recordingStatusCallback:`http://xyz/hookFolder?chunkStartNumber=${recLenDivided}`
    });
      return callback(null, twiml);
   }

The parser code

const express = require ('express')
const bodyParser = require ('body-parser')
const app = express()
const PORT = 3000


app.use(express.static("public"))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended:true}))

app.post("/hookFolder",(req, res) => {
    console.log(req.body)
     
    res.status(200).end()
}) 

The log

{ RecordingSource: 'RecordVerb',RecordingSid: 'RE', RecordingUrl: 'https://api.twilio.com/2010-04-01/', RecordingStatus: 'completed', RecordingChannels: '1', ErrorCode: '0', CallSid: 'CA', RecordingStartTime: 'Tue, 22 Dec 2020 18:09:44 +0000', AccountSid: 'AC', RecordingDuration: '9' }


Solution

  • Try req.query.

    Also, no need to use Bodyparser. Built in with later versions of Express.

    app.use(express.json());

    app.use(express.urlencoded({ extended: false }));