twilio / twilio-voice-ios

Programmable Voice SDK by Twilio
https://www.twilio.com/voice
38 stars 14 forks source link

Error: callerId must be provided for TwilioClient and SIP calls when using Dial (after VoiceResponse TwiML steps) #103

Closed blazorin closed 1 year ago

blazorin commented 1 year ago

Description

callerId must be provided for TwilioClient and SIP calls when using Dial. This error is notified to the the action callback (parameter) of the TwiML VoiceResponse instance, before sdk finally shows a 403 (forbidden).

Steps to Reproduce

  1. iOS SDK starts the call

  2. The TwiML post action is called, linked to a serverless function.

  3. The function returns correctly the TwiML steps.

  4. However error is notified to the action URI on my server with the following (form) properties:
    => DialCallStatus: failed, ErrorMessage: callerId must be provided for TwilioClient and SIP calls when using Dial

  5. On client (sdk) end, this is is logged as a SIP/2.0 403 Forbidden (not relevant).

Code

Serverless / TwiML steps creation

If you are from Twilio team, the endpoint (protected) is: https://wheat-bat-8252.twil.io/live

Code of the function:

exports.handler = async (context, event, callback) => {
  // set-up the variables that this Function will use to forward a phone call using TwiML

  // generate the TwiML to tell Twilio how to forward this call
  let voiceResponse = new Twilio.twiml.VoiceResponse();

    ......

    const { callId, numberFrom } = response.data;

    let dialParams = {};
    dialParams.callerId = numberFrom
    dialParams.answerOnBridge = true
    dialParams.method = 'POST'
    dialParams.action = 'myserver'
    dialParams.recordingStatusCallback = 'myserver'
    dialParams.record = 'record-from-answer-dual'
    dialParams.recordingStatusCallbackEvent = 'in-progress completed absent'
    dialParams.timeout = 23

    const dialObj = voiceResponse.dial(dialParams);
    dialObj.number(numberTo);

    // return the TwiML
    callback(null, voiceResponse);

Generated TwiML (voiceResponse value at the end):

VoiceResponse: 

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial callerId="+34mynumber" answerOnBridge="true" method="POST" action="myserver" recordingStatusCallback="myserver" record="record-from-answer-dual" recordingStatusCallbackEvent="in-progress completed absent" timeout="23">
        <Number>+34destnumber</Number>
    </Dial>
</Response>

The weird thing is that the TwiML response looks correct. And yes, I can guarantee it has nothing to do with the + character. Happens with or without it.

Expected Behavior

Call starts and following callbacks/actions occurr.

Actual Behavior

Call does not start because of the callerId error, which has been notified to the action endpoint (myserver).

Reproduces How Often

100%

Logs

Provided before. The following screenshot is the parameters section of the function call. (I triggered an exception before the return callback to show this):

Screenshot 2022-12-10 at 19 23 24

Above data is from a forced exception execution, the following CallSid is from a real one: CallSid: "CAbe5a4f0be368ca7bf4aa7eae79691703"

Versions

All relevant version information for the issue.

Voice iOS SDK

6.5.0 via CocoaPods

Xcode

14.0

iOS Version

16.1.1

iOS Device

iPhone SE 2020.

blazorin commented 1 year ago

https://www.twilio.com/docs/global-infrastructure/regional-product-and-feature-availability Custom CallerID feature not available outside us1 region.