Last updated 19 March 2011. Created on 2 March 2011.
Edited by leoburd. Log in to edit this page.

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

For instance, the command "get input" receives, among other parameters, a "prompt" to be played to the user. After it is executed, the "get input" command sets the script variable input_digits with the digits typed in.

$prompt = 'Please type your zip code after the beep';
$script->addSay("You typed %input_digits");

In the example above, note the % symbol in the string passed to the "say" command. Whenever VoIP Drupal finds the % symbol in a string, it tries to replace it by the contents of the script variable whose name immediately follows that symbol.

Similarly, using the t() function to translate the parameter strings:

$prompt = 'Please type your zip code after the beep';
$args = array('@input' => '%input_digits');
$script->addSay(t("You typed @input", $args));

The "set" command can be used to store values in script variables. For instance, in the code below

global $user;
$script->addSet('name', $user->name);
$script->addSet('password', '%input_digits');

the variable "name" will be set to the user's name, whereas the variable "password" will be set to the contents of "input_digits".

Script variables are created during the first time that they are "set". In order to remove them, use the "unset" command:


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