AmateurNoob
AmateurNoob

Reputation: 25

Twilio function giving invalid content-type error

I'm trying to make an outgoing call to an automated phone system, but I'm running into a content-type error. I don't understand what a content-type error is, so if someone could help me understand that would be great. Here's the code I have right now.

exports.handler = function(context, event, callback) {

    const accountSid = 'AC5ca0acd115283b6d7ed38279';
    const authToken = 'not my real auth token';
    const client = require('twilio')(accountSid, authToken);

    client.calls
          .create({
             to: '+14805402416',
             from: '+18448345500',
             record: 'True',
             transcribe: 'True',
             sendDigits: 'wwww1wwww123#wwww1', // w's are .5 second delays to navigate pauses in the automated system 
                                               // '1' - English, '123#' - PIN #, '1' - Confirm PIN
           });

    callback(null, client);
};

Upvotes: 0

Views: 339

Answers (1)

Alan
Alan

Reputation: 10781

You are missing either url or twiml in your construct.

https://www.twilio.com/docs/voice/api/call-resource

url The absolute URL that returns the TwiML instructions for the call. We will call this URL using the method when the call connects. For more information, see the Url Parameter section in Making Calls.

TwiML instructions for the call Twilio will use without fetching Twiml from url parameter. If both twiml and url are provided then twiml parameter will be ignored.

Upvotes: 1

Related Questions