Search code examples
twiliotwilio-twimltwilio-click-to-call

Twilio Programmable Voice Custom Params Issue


We aren't able to receive customerparameters sent from the caller side. Here how we are sending

  func performVoiceCall(uuid: UUID, client: String?, completionHandler: @escaping (Bool) -> 
      Void) {
      let connectOptions = ConnectOptions(accessToken: accessToken) { builder in
      builder.params = [twimlParamTo: self.callToUserId, "displayName": "zeshan"] 

       builder.uuid = uuid
    }

    let call = TwilioVoiceSDK.connect(options: connectOptions, delegate: self)
    activeCall = call
    activeCalls[call.uuid!.uuidString] = call
    callKitCompletionCallback = completionHandler
 }

and here how we are receiving but cannot get any customer parameter at call receiving end

     func callInviteReceived(callInvite: CallInvite) {
       NSLog("callInviteReceived:")

       UserDefaults.standard.set(Date(), forKey: kCachedBindingDate)

       let callerInfo: TVOCallerInfo = callInvite.callerInfo
       if let verified: NSNumber = callerInfo.verified {
       if verified.boolValue {
          NSLog("Call invite received from verified caller number!")
       }
   }

   let from = (callInvite.from ?? "Voice Bot").replacingOccurrences(of: "client:", with: "")
   let customParam = callInvite.customParameters?["displayName"]

   // Always report to CallKit
   reportIncomingCall(from: from, uuid: callInvite.uuid)
   activeCallInvites[callInvite.uuid.uuidString] = callInvite
   }

customParam is received null Please advice


Solution

  • Twilio developer evangelist here.

    When you set parameters through the Twilio Voice SDK connect method, that send the parameters to the webhook of your TwiML application.

    In order to send those parameters on so that they can be read by the Twilio Voice SDK client receiving an incoming call you need to set them again using the <Parameter> TwiML element that is nested within the <Client> element. For example:

    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
       <Dial>
         <Client>
            <Identity>user-jane</Identity>
            <Parameter name="displayName" value="zeshan"/>
          </Client>
        </Dial>
    </Response>