Last updated 17 February 2012. Created on 2 March 2011.
Edited by Fishboy1669, ben.bunk, Matt V., leoburd. Log in to edit this page.

VoIP Drupal’s voip.module defines a set of basic functions to manage server configuration as well as to make and cancel calls. In order to make a phone call from inside Drupal, the developer should invoke voip_dial() passing an instance of the VoipCall class as parameter:

  $call = new VoipCall();
  $phone_number = '+13331234567'; // use the phone number of your choice,
                                    // but make sure the number is authorized by
                                    // your VoIP server
  $script_name = "voipscript_say_demo";
  $script = VoipScript::loadScript($script_name);
  $result = voip_dial($call);
  if ($result) {
     watchdog('mymodule', "call successfully queued for $phone_number");
  else {
     $msg = $call->getErrorMessage();
     $details = array('@msg' => $msg);
     watchdog('mymodule', 'Call failed with the following error: @msg',$details, WATCHDOG_WARNING);

In the example above, voip_dial() places the call in a server queue and returns immediately.

In case the call fails for any reason (invalid number, non-authorized caller id, processing error, etc.), voip_dial() returns FALSE and the $call variable is updated with the failure description.

If the call is placed successfully, the system will then try execute the script defined by the $script variable.

Developers should periodically invoke $call->getCallStatus() to monitor the evolution of the call until it is hangup.

Note about getCallStatus or isHangup and outgoing_calls:
Because the outgoing call will almost certainly occur on a different thread/process you must use the following snippet to get the correct call status or you will be using a stale local copy of the call:

 $call = VoipCall::load($call->getCid());
 $status = $call->getCallStatus();

Other useful VoipCall methods include getStartTime(), getDuration(), and getAnsweredBy(). The latter can be used to determine whether the call has been answered by a human being or an answering machine.

Looking for support? Visit the forums, or join #drupal-support in IRC.


tamerzg’s picture

To see how to send SMS message only check


eftakhairul’s picture

I want to use this voip module with Twilio account. But, I am not clearly understood where I put this script and how do I make and receive call after properly configured with twilio? would anybody suggest me any good tutorial for drupal voip with twilio.