1

I have implemented twilio client calling future using PHP. But sometimes the call is getting disconnected after ringing. When I look into the error log in twilio I can see the message 'You attempted to initiate an outbound phone call to a phone number that is not enabled on your account.'. I am calling from browser to browser and browser to mobile app, so why this message is shown ?.

I am not sure whether this is an issue in caller side or the receiver side.

Twiml code For eg : $to = 'CLIENT3150'

function get_voice_response($to,$from,$name,$image, $group) {
     $response = new VoiceResponse();

     if (!empty($to) && strlen($to) > 0) {
        $number = htmlspecialchars($to);
        $dial = $response->dial('', ['callerId' => $from]);
    
        // wrap the phone number or client name in the appropriate TwiML verb
        // by checking if the number given has only digits and format symbols
        if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) {
           $dial->number($number);
        } else {
           $client = $dial->client($number);
           $client->parameter(['name' => 'FirstName', 'value' => $name]);
           $client->parameter(['name' => 'Image', 'value' => $image]);
           $client->parameter(['name' => 'Group', 'value' => $group]);
        }
     } else {
       $response->say("Thanks for calling!");
     }
     return (string)$response;
 }

Thank you

8
  • Both numbers are your twilio numbers? Jun 9, 2021 at 13:17
  • I am not calling to a phone number. I am calling from browser to browser and browser to mobile app
    – skm
    Jun 9, 2021 at 14:28
  • The question says you are not calling from browser to browser. Jun 9, 2021 at 14:29
  • Sorry edited now
    – skm
    Jun 9, 2021 at 14:50
  • Can you share the code you are using in your TwiML app to place the outbound call?
    – philnash
    Jun 10, 2021 at 5:47

1 Answer 1

0

Twilio developer evangelist here.

It looks like you are making a call to another client and trying to pass parameters along with the call. When you do this, you need to pass the client name as an <Identity> element within the <Client>, along with the <Parameter> elements.

In PHP this looks like:

$client = $dial->client();
$client->identity($number);
$client->parameter(['name' => 'FirstName', 'value' => $name]);
$client->parameter(['name' => 'Image', 'value' => $image]);
$client->parameter(['name' => 'Group', 'value' => $group]);

Let me know if that helps at all.

7
  • @philansh No nothing has changed. The call is getting diconnected immediatly after I accept the call
    – skm
    Jun 10, 2021 at 9:53
  • And this is not happening all the time. Sometimes I am able to accept the call and speak
    – skm
    Jun 10, 2021 at 10:24
  • Are there any differences between the calls you can answer and those you can't? Different clients, calls coming from different places, device on which you are taking the calls, error messages in the developer tools? Anything at all?
    – philnash
    Jun 11, 2021 at 2:34
  • No this happens randomly and I cannot figure it out. It even happens when I call from browser to browser or sometimes from browser to mobile. I couldnt find any error in the twilio dashbord error log
    – skm
    Jun 11, 2021 at 6:26
  • If it's random then there might be something else going on. I'd try to get some examples of Call SIDs where this happened and submit them with this description to Twilio support.
    – philnash
    Jun 11, 2021 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.