I have the following serverless lambda function code below...
export function incoming_calls(event, context, callback) {
var util = require("util");
const VoiceResponse = require('twilio').twiml.VoiceResponse;
const twiml = new VoiceResponse();
//Determine message to give based on parameters given
var theMessage = "Incoming Pool Service Leed";
var querystring = require("querystring");
var qMessage = querystring.stringify({message: theMessage});
var whisperURL = "https://" + process.env.DOMAIN_NAME + "/twilio/whisper?" + qMessage;
//twiml.say({ voice: 'woman' }, 'hello world!');
twiml.dial({ record: 'true'}).number({url: whisperURL},'407-947-0503');
//twiml.say({ voice: 'woman' }, 'This is a test!');
//Useful Info
var queryString = util.inspect(event.body);
console.log("queryString="+queryString)
sendemail("myemail@email.com","Incoming Call POST Request",queryString);
callback(null, successXml(twiml.toString()));
}
This code works and sends me an email with the POST variables but as one long string looking like this...
'Called=%2B15622222222&ToState=CA&CallerCountry=US&Direction=inbound&CallerState=CA&ToZip=90670&CallSid=CA47e5131dd5e7375190aaf5fab773a9b0&To=%2B15622221234&CallerZip=92606&CallerName=
... etc
How do I convert the POST parameters I am receiving from Twilio into a nicer format, maybe an Array or Object instead of a String?