Unable to record active call

98 views
Skip to first unread message

Chris Grimmett

unread,
Jun 8, 2015, 3:15:03 PM6/8/15
to plivo...@googlegroups.com
I'm using node and the plivo-node module. What I'm trying to do is call a plivo number, it plays a message then starts recording.

The problem I'm having is that plivo can't seem to find the active call uuid when I do api.record(...)

Here's my code (record is not in the right order. right now I'm just trying to get a proof of concept):

var express = require('express');
var nconf = require('nconf');
var plivo = require('plivo-node');
var bodyParser = require('body-parser');
var urlencodedParser = bodyParser.urlencoded({
    extended
: true
});
var app = express();

nconf
.file('./config.json');

var api = plivo.RestAPI({
    authId
: nconf.get('PLIVO_ID'),
    authToken
: nconf.get('PLIVO_TOKEN')
});



app
.post('/call/answer', urlencodedParser, function(req, res) {

   
var uuid = req.body.CallUUID;
   
var recordAttributes = {
        call_uuid
: uuid,
        time_limit
: 30,
        file_format
: "wav"
   
};
   
var r = plivo.Response();


    console
.log('got call', uuid);

    api
.record(recordAttributes, function(status, response) {
        console
.log('got response:', response);

       
if (status >= 400) {
            console
.log('could not record', status);
            r
.addSpeak('could not record');
            res
.set({
               
'Content-Type': 'text/xml'
           
});
           
return res.end(r.toXML());
       
}
       
else {
            r
.addPlay('https://s3.amazonaws.com/plivocloud/Trumpet.mp3');
            res
.set({
               
'Content-Type': 'text/xml'
           
});
           
return res.end(r.toXML());
       
}
   
});
});


app
.listen(process.env.PORT);



Here's what plivo returns as the response to api.record():

got response: { api_id: '847e1bf4-0e11-11e5-b483-22000afb8d0a',
  error
: 'call not found' }

Using the plivocloud web debug interface, it looks to me like it received good data (I've masked out my auth id):


             
Message : response error
             
Status : 404

             
URI:  /v1/Account/xxxxxxxxxxxx/Call/83a03dc0-0e11-11e5-b86c-6f59143e3963/Record/
             
Method:  POST
           
             
Params : {
           
      time_limit : 30
           
      file_format : wav
           
    }
           
             
Response : {
           
      api_id : 847e1bf4-0e11-11e5-b483-22000afb8d0a
           
      error : call not found
           
    }
     


...yet It wasn't able to find the call and record it.

Does anything look really wrong in my code?

Ramya R

unread,
Jun 9, 2015, 5:26:38 AM6/9/15
to plivo...@googlegroups.com
Hello Chris,

Assuming that "/call/answer" is your answer_URL for the call, you are trying to start the record api before returning a valid XML (Play music). Instead of using Record API to record the call, you could use Record XML. The XML returned by the answer URL would look something like this:

<Response> <Play>https://s3.amazonaws.com/plivocloud/Trumpet.mp3</Play> <Record action="http://foo.com/get_recording/" maxLength="30" finishOnKey="*" /> </Response>

For better support, please reach out to us at sup...@plivo.com
Reply all
Reply to author
Forward
0 new messages