Voice - can Record be directed from connect instead of Dial

Using voice-javascript-sdk-quickstart-csharp as example.

A Twilio.Device is created in the Browser which then has a "connect" call to it to call a phone number.

Twilio does a call-back to a server side C# controller that return a Dial with possible "Record" option.

I want to make the Record option of Dial to be conditional to the CalledID.

Is there a way to add the "Record" option to the connect call?

Is there a way to tell Twilio to pass a "Non-Twilio" parameter from a "connect" call to the C# server side controller so the Record parameter can be set or not-set depending on a Non-Twilio parameter being received?


Best Answer

  • pnash
    pnash mod
    Accepted Answer

    In the code there is this line:

    const call = await device.connect({ params });

    This is already sending two parameters:

    var params = {
      To: phoneNumberInput.value,

    Those parameters are then sent on as part of the webhook to the URL defined in your TwiML app, which directs to the VoiceController in the C# app. The controller action reads the parameters in this line.

    So, the answer to your question is: there are no specific "Twilio parameters" that are sent when you make a call with device.connect, but all parameters that you pass to the connect function under the params property are sent on to your application in the request, either as query string parameters for GET requests or in the request body for POST requests. See the documentation under ConnectOptions for the device object here for more detail.

If this is an emergency, please contact Twilio Support. This is not an official Support channel. https://support.twilio.com/
Have an urgent question?
Please contact Twilio Support. This is not an official Support channel.
Contact Support