necroface
necroface

Reputation: 3465

node.js - Dial to Number with Twilio

I'm building myself a click-to-call website that utilizes Twilio. After I configured in TwiML app and wrote Twilio JavaScript SDK client-side to make request to Twilio, then Twilio will make a POST request to this route of mine:

 app.post('/callcenter',function(req,res){    
    const twilio=require('twilio');
    var twiml=new twilio.TwimlResponse();
        res.type('text/xml');
        twiml.dial({},function(node){
            node.number('MY_PHONE_NUMBER');
        });
        res.send(twiml.toString());
 );

This is the most simplified use of Dial in REST API for TwiML that I want to respond to Twilio to make a call to MY_PHONE_NUMBER. But I always ended up hearing voice of "An error occured..." Please someone help me point out what did I do wrong in this route handler? Server is built in ExpressJS

Upvotes: 1

Views: 950

Answers (1)

jazzmn77
jazzmn77

Reputation: 25

try this out:

twiml.dial({callerId : process.env.TWILIO_PHONE_NUMBER}, MY_PHONE_NUMBER);

which comes from: https://www.twilio.com/docs/tutorials/walkthrough/browser-calls/node/express There click to the page call.js.

Upvotes: 1

Related Questions