Working with VoIP Drupal scripts

“VoIP scripts” (a.k.a. "dialplan scripts") enable the creation of the voice menus and interactivity that are so characteristic of Internet telephony.

In technical terms, they are objects of the class VoipScript and contain, among other things, a sequence of commands and a set of variables that, together, define the behavior and the current state of calls within the VoIP Drupal framework.

The main methods of the VoipScript class include:

Input and output methods

  • addBeep(), to play a beep sound
  • addSetLanguage(), to set the default text-to-speech language of the script
  • addSetVoice(), to set the default text-to-speech voice of the script
  • addGetInput(), to read input from the telephone keypad
  • addRecord(), to record audio input from the user
  • addRunIvrMenu(), to execute an interactive voice menu
  • addSay(), to play audio and use text-to-speech to read text to the user

Variable-related commands

  • addSet(), to set specific variables with the result of calls to PHP and Drupal functions

Script control commands

  • addGosub(), to load a different script and store the existing one in a stack
  • addReturn(), to return to the last script stored in the stack
  • addGoto(), to skip to a different command inside the current script
  • addGotoIf(), to skip to a different command inside the script only if the specified condition is TRUE.
  • addLabel(), to define the destination of goto and gotoIf commands

Call control commands

  • addHangup(), to hangup the call
  • addReject(), to reject an incoming call before its answered
  • addDial(), to divert an ongoing call to a different destination
  • addJoinConference(), to organize conference calls
  • addSendSms(), to send text messages from inside the call

Error handling commands

  • addLog(), to log messages from inside the script execution
  • isError(), to check if a script error occurred
  • getErrorMessage(), to retrieve the error description

Note: To learn about the specific parameters and outputs associated with the commands above, please check their definition in the voipscript.inc file of the voipdrupal project.

Calling PHP and Drupal functions from inside a script

When handling VoipScript parameters, VoIP Drupal processes strings that start with the ^ symbol as expressions to be evaluated. For

Command execution

With the exception of isError() or getErrorMessage(), the majority of VoipScript methods simply add commands to an internal list maintained

Handling script variables

Most VoipScript commands receive parameters as input and set script variables as output.

Guide maintainers

leoburd's picture