How to add parameters to twimlResponse dial by nodejs

There is no information anywhere to add params to the twmil response throw node.js.

I wanna add the tag param <param to the dial method in node.js but i couldn find informatio related to this.

24 thoughts on “How to add parameters to twimlResponse dial by nodejs”

  1. Twilio developer evangelist here.

    To add a custom <Parameter> to a <Client> in Node.js you can use code like so:

    const twiml = new Twilio.twiml.VoiceResponse();
    
    const dial = twiml.dial({
      callerId: CALLER_ID
    });
          
    const client = dial.client();
    client.identity("alice");
    const parameter = client.parameter({
      name: "customerID", 
      value: "YOUR_CUSTOMER_ID"
    });
    
    console.log(twiml.toString());
    // => <?xml version="1.0" encoding="UTF-8"?>
    // <Response>
    //   <Dial callerId="+1234557567">
    //     <Client>
    //       <Identity>alice</Identity>
    //       <Parameter customerID="YOUR_CUSTOMERID"/>
    //     </Client>
    //   </Dial>
    // </Response>
    

    Note, that you can’t add parameters directly to the <Dial> element, just the <Client> element within it. If you need to pass information on after the <Dial> completes, then you should add URL parameters to the URL you provide as the action attribute.

    Let me know how you get on with that.

    Reply

Leave a Comment