How to add an extension number in twilio click to call using node js

203 Views Asked by At

As per the documentation here & the github source code here, I have cloned the application, its working perfectly.

Suppose if my sales person having some extension then how can I give that extension in this script. Normally, using senddigit I can pass the extension in twilio but I dont know how to implement that with this salesNumber.

  twilioClient.createCall(salesNumber, phoneNumber, headersHost)
    .then((result) => {
    response.send({message: result});
    })
    .catch((error) => {
    response.status(500).send(error);
    });

Please some one help on this.

1

There are 1 best solutions below

0
On

I think you're looking at the wrong code snippet here. The code above doesn't call the Twilio client directly. Instead, it calls the helper function from this file to initiate the call.

Once the user picks up, they will be connected to the sales person via TwiML in this function:

  voiceResponse: (salesNumber, Voice = VoiceResponse) => {
    let twimlResponse = new Voice();

    twimlResponse.say('Thanks for contacting our sales department. Our ' +
                      'next available representative will take your call. ',
                      { voice: 'alice' });
    twimlResponse.dial(salesNumber);

    return twimlResponse.toString();
  }

In this function, you'll be able to send digits along as mentioned here.