davos
davos

Reputation: 211

Twilio Cloud Based Functions and Libraries

@philnash had a solution [here][1] that I tried and had a problem - I'm using Twilio's Cloud Functions and getting no intellisense on client.messages - any idea how to reference the correct library

client.messages.create({

enter image description here

enter image description here

Upvotes: 0

Views: 43

Answers (1)

Alan
Alan

Reputation: 10781

In the screenshot, you spelled client wrong, cleint.

exports.handler = function(context, event, callback) {
    const twilioClient = context.getTwilioClient();
    
twilioClient.messages
  .create({
    body: 'Hello World',
    to: '+14075551212',
    from: '+18025551212 ',
  }).then(message =>  {
        console.log('Created call using callback');
        console.log(message.sid);
        callback();
  })
    .catch(error => {
        console.log(error);
           callback("error");
    });
};

You should update the Twilio client library version as well, 3.29.2 is pretty old.

Upvotes: 1

Related Questions